Added changing user nicknames.

pull/61/head
Mikunj 6 years ago
parent 6ce9d6a08c
commit 449f44cc5a

@ -1349,6 +1349,14 @@
"message": "Disappearing messages",
"description": "Conversation menu option to enable disappearing messages"
},
"changeNickname": {
"message": "Change nickname",
"description": "Conversation menu option to change user nickname"
},
"clearNickname": {
"message": "Clear nickname",
"description": "Conversation menu option to clear user nickname"
},
"timerOption_0_seconds_abbreviated": {
"message": "off",
"description":

@ -226,6 +226,9 @@
await Promise.all(
conversations.map(conversation => conversation.updateLastMessage())
);
// Update profiles
conversations.map(conversation => conversation.updateProfile());
window.log.info('ConversationController: done with initial fetch');
} catch (error) {
window.log.error(

@ -174,6 +174,7 @@
name: item.getName(),
value: item.get('seconds'),
})),
hasNickname: !!storage.getNickname(this.model.id),
onSetDisappearingMessages: seconds =>
this.setDisappearingMessages(seconds),
@ -204,6 +205,24 @@
onUnblockUser: () => {
this.model.unblock();
},
onChangeNickname: () => {
window.Whisper.events.trigger('showNicknameDialog', {
pubKey: this.model.id,
nickname: storage.getNickname(this.model.id),
onOk: async (newName) => {
if (_.isEmpty(newName)) {
await storage.removeNickname(this.model.id)
} else {
await storage.saveNickname(this.model.id, newName);
}
this.model.updateProfile();
},
});
},
onClearNickname: async () => {
await storage.removeNickname(this.model.id);
this.model.updateProfile();
},
};
};
this.titleView = new Whisper.ReactWrapperView({

@ -11,7 +11,7 @@
templateName: 'nickname-dialog',
initialize(options) {
this.message = options.message;
this.name = options.name;
this.name = options.name || '';
this.resolve = options.resolve;
this.okText = options.okText || i18n('ok');

@ -36,6 +36,7 @@ interface Props {
expirationSettingName?: string;
showBackButton: boolean;
timerOptions: Array<TimerOption>;
hasNickname?: boolean;
onSetDisappearingMessages: (seconds: number) => void;
onDeleteMessages: () => void;
@ -48,6 +49,9 @@ interface Props {
onBlockUser: () => void;
onUnblockUser: () => void;
onClearNickname: () => void;
onChangeNickname: () => void;
}
export class ConversationHeader extends React.Component<Props> {
@ -186,6 +190,9 @@ export class ConversationHeader extends React.Component<Props> {
timerOptions,
onBlockUser,
onUnblockUser,
hasNickname,
onClearNickname,
onChangeNickname,
} = this.props;
const disappearingTitle = i18n('disappearingMessages') as any;
@ -225,6 +232,12 @@ export class ConversationHeader extends React.Component<Props> {
{!isMe ? (
<MenuItem onClick={blockHandler}>{blockTitle}</MenuItem>
) : null}
{!isMe ? (
<MenuItem onClick={onChangeNickname}>{i18n('changeNickname')}</MenuItem>
) : null}
{!isMe && hasNickname ? (
<MenuItem onClick={onClearNickname}>{i18n('clearNickname')}</MenuItem>
) : null}
<MenuItem onClick={onDeleteMessages}>{i18n('deleteMessages')}</MenuItem>
</ContextMenu>
);

Loading…
Cancel
Save