-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start modifying settings * feat: Finish making block instance setting * feat: Add translations * fix: Handle first load fetch * chore: Fix linting error * fix: Fix broken import
- Loading branch information
1 parent
d9fe7d1
commit f0ccf93
Showing
6 changed files
with
206 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Choice } from "@utils/types"; | ||
import { Instance } from "lemmy-js-client"; | ||
|
||
export default function instanceToChoice({ id, domain }: Instance): Choice { | ||
return { | ||
value: id.toString(), | ||
label: domain, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { BlockInstanceResponse, Instance, MyUserInfo } from "lemmy-js-client"; | ||
import { I18NextService, UserService } from "../../services"; | ||
import { toast } from "../../toast"; | ||
|
||
export default function updateInstanceBlock( | ||
data: BlockInstanceResponse, | ||
id: number, | ||
linkedInstances: Instance[], | ||
myUserInfo: MyUserInfo | undefined = UserService.Instance.myUserInfo, | ||
) { | ||
if (myUserInfo) { | ||
const instance = linkedInstances.find(i => i.id === id)!; | ||
|
||
if (data.blocked) { | ||
myUserInfo.instance_blocks.push({ | ||
person: myUserInfo.local_user_view.person, | ||
instance, | ||
}); | ||
toast(`${I18NextService.i18n.t("blocked")} ${instance.domain}`); | ||
} else { | ||
myUserInfo.instance_blocks = myUserInfo.instance_blocks.filter( | ||
i => i.instance.id !== id, | ||
); | ||
toast(`${I18NextService.i18n.t("unblocked")} ${instance.domain}`); | ||
} | ||
} | ||
} |