Skip to content

Commit 93c6b06

Browse files
committed
Toast a hint of the likely reason for a failed global (un)ban.
1 parent 3f8327c commit 93c6b06

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

_locales/en/messages.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,14 @@
250250
"serverUnbanUser": "Unban User from Server",
251251
"userUnbanned": "User unbanned successfully",
252252
"userUnbanFailed": "Unban failed!",
253+
"globalUserUnbanFailed": "Unban failed! Are you a global admin/mod?",
253254
"banUser": "Ban User",
254255
"banUserAndDeleteAll": "Ban and Delete All",
255256
"serverBanUser": "Ban User from Server",
256257
"serverBanUserAndDeleteAll": "Ban from Server and Delete All",
257258
"userBanned": "Banned successfully",
258259
"userBanFailed": "Ban failed!",
260+
"GlobalUserBanFailed": "Ban failed! Are you a global admin/mod?",
259261
"leaveGroup": "Leave Group",
260262
"leaveAndRemoveForEveryone": "Leave Group and Remove for Everyone",
261263
"leaveGroupConfirmation": "Are you sure you want to leave this group?",

ts/components/dialog/BanOrUnbanUserDialog.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ async function banOrUnBanUserCall(
5656
if (!isChangeApplied) {
5757
window?.log?.warn(`failed to ${banType} user: ${isChangeApplied}`);
5858

59-
banType === 'ban' ? ToastUtils.pushUserBanFailure() : ToastUtils.pushUserUnbanFailure();
59+
banType === 'ban'
60+
? isGlobal
61+
? ToastUtils.pushGlobalUserBanFailure()
62+
: ToastUtils.pushUserBanFailure()
63+
: isGlobal
64+
? ToastUtils.pushGlobalUserUnbanFailure()
65+
: ToastUtils.pushUserUnbanFailure();
6066
return false;
6167
}
6268
window?.log?.info(`${pubkey.key} user ${banType}ned successfully...`);

ts/session/utils/Toast.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ export function pushUserBanFailure() {
117117
pushToastError('userBanFailed', window.i18n('userBanFailed'));
118118
}
119119

120+
export function pushGlobalUserBanFailure() {
121+
pushToastError('globalUserBanFailed', window.i18n('globalUserBanFailed'));
122+
}
123+
120124
export function pushUserUnbanSuccess() {
121125
pushToastSuccess('userUnbanned', window.i18n('userUnbanned'));
122126
}
@@ -125,6 +129,10 @@ export function pushUserUnbanFailure() {
125129
pushToastError('userUnbanFailed', window.i18n('userUnbanFailed'));
126130
}
127131

132+
export function pushGlobalUserUnbanFailure() {
133+
pushToastError('globalUserUnbanFailed', window.i18n('globalUserUnbanFailed'));
134+
}
135+
128136
export function pushMessageDeleteForbidden() {
129137
pushToastError('messageDeletionForbidden', window.i18n('messageDeletionForbidden'));
130138
}

ts/types/LocalizerKeys.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type LocalizerKeys =
22
| 'removePassword'
33
| 'classicDarkThemeTitle'
44
| 'userUnbanFailed'
5+
| 'globalUserUnbanFailed'
56
| 'changePassword'
67
| 'saved'
78
| 'startedACall'
@@ -39,6 +40,7 @@ export type LocalizerKeys =
3940
| 'video'
4041
| 'readReceiptSettingDescription'
4142
| 'userBanFailed'
43+
| 'globalUserBanFailed'
4244
| 'autoUpdateLaterButtonLabel'
4345
| 'maximumAttachments'
4446
| 'deviceOnly'

0 commit comments

Comments
 (0)