diff --git a/_locales/en/messages.json b/_locales/en/messages.json index f05329f1e..414c3f783 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2001,26 +2001,22 @@ "banUser": { "message": "Ban user", - "description": - "Ban user from public chat by public key." + "description": "Ban user from public chat by public key." }, "banUserConfirm": { "message": "Are you sure you want to ban user?", - "description": - "Message shown when confirming user ban." + "description": "Message shown when confirming user ban." }, "userBanned": { "message": "User successfully banned", - "description": - "Toast on succesful user ban." + "description": "Toast on succesful user ban." }, "userBanFailed": { "message": "User ban failed!", - "description": - "Toast on unsuccesful user ban." + "description": "Toast on unsuccesful user ban." }, "copyChatId": { diff --git a/js/models/messages.js b/js/models/messages.js index efac82d32..7867b6975 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -12,7 +12,6 @@ Whisper, clipboard, libloki, - lokiPublicChatAPI, */ /* eslint-disable more/no-then */ @@ -656,8 +655,7 @@ !this.get('isPublic') || this.getConversation().isModerator(this.OUR_NUMBER) || this.getSource() === this.OUR_NUMBER, - hasModPerms: - this.getConversation().isModerator(this.OUR_NUMBER), + hasModPerms: this.getConversation().isModerator(this.OUR_NUMBER), onCopyText: () => this.copyText(), onSelectMessage: () => this.selectMessage(), @@ -981,18 +979,17 @@ const channelAPI = await conversation.getPublicSendData(); const success = await channelAPI.banUser(source); - + if (success) { window.Whisper.events.trigger('showToast', { message: i18n('userBanned'), }); - } - else{ + } else { window.Whisper.events.trigger('showToast', { message: i18n('userBanFailed'), }); } - } + }, }); }, diff --git a/js/modules/loki_app_dot_net_api.js b/js/modules/loki_app_dot_net_api.js index 44d9ed6a1..f8fe6a87c 100644 --- a/js/modules/loki_app_dot_net_api.js +++ b/js/modules/loki_app_dot_net_api.js @@ -545,10 +545,11 @@ class LokiPublicChannelAPI { // TODO: poll for group members here? } - async banUser(pubkey){ + async banUser(pubkey) { const res = await this.serverRequest( - `loki/v1/moderation/blacklist/@${pubkey}`, { - method: 'POST' + `loki/v1/moderation/blacklist/@${pubkey}`, + { + method: 'POST', } ); diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 70e1f61ae..6313d4f38 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -964,10 +964,8 @@ export class Message extends React.PureComponent { {i18n('copyPublicKey')} ) : null} - {(hasModPerms && isPublic) ? ( - - {i18n('banUser')} - + {hasModPerms && isPublic ? ( + {i18n('banUser')} ) : null} );