Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add ignore user confirmation dialog #6116

Merged
merged 9 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,21 +334,34 @@ const UserOptionsSection: React.FC<{
// Only allow the user to ignore the user if its not ourselves
// same goes for jumping to read receipt
if (!isMe) {
const onIgnoreToggle = () => {
const unignore = () => {
const ignoredUsers = cli.getIgnoredUsers();
if (isIgnored) {
const index = ignoredUsers.indexOf(member.userId);
if (index !== -1) ignoredUsers.splice(index, 1);
} else {
const index = ignoredUsers.indexOf(member.userId);
if (index !== -1) ignoredUsers.splice(index, 1);
cli.setIgnoredUsers(ignoredUsers);
};

const ignore = async () => {
const { finished } = Modal.createTrackedDialog('Ignore User', '', QuestionDialog, {
title: _t("Ignore %(user)s", { user: member.name }),
description: <div>
{ _t("All messages and invites from this user will be hidden. " +
"Are you sure you want to ignore them?") }
</div>,
button: _t("Ignore"),
});
const [confirmed] = await finished;

if (confirmed) {
const ignoredUsers = cli.getIgnoredUsers();
ignoredUsers.push(member.userId);
cli.setIgnoredUsers(ignoredUsers);
}

cli.setIgnoredUsers(ignoredUsers);
};

ignoreButton = (
<AccessibleButton
onClick={onIgnoreToggle}
onClick={isIgnored ? unignore : ignore}
className={classNames("mx_UserInfo_field", {mx_UserInfo_destructive: !isIgnored})}
>
{ isIgnored ? _t("Unignore") : _t("Ignore") }
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,8 @@
"%(count)s sessions|other": "%(count)s sessions",
"%(count)s sessions|one": "%(count)s session",
"Hide sessions": "Hide sessions",
"Ignore %(user)s": "Ignore %(user)s",
"All messages and invites from this user will be hidden. Are you sure you want to ignore them?": "All messages and invites from this user will be hidden. Are you sure you want to ignore them?",
"Jump to read receipt": "Jump to read receipt",
"Mention": "Mention",
"Invite": "Invite",
Expand Down