Added changing user nicknames.

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

@ -1349,6 +1349,14 @@
"message": "Disappearing messages", "message": "Disappearing messages",
"description": "Conversation menu option to enable 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": { "timerOption_0_seconds_abbreviated": {
"message": "off", "message": "off",
"description": "description":

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

@ -174,6 +174,7 @@
name: item.getName(), name: item.getName(),
value: item.get('seconds'), value: item.get('seconds'),
})), })),
hasNickname: !!storage.getNickname(this.model.id),
onSetDisappearingMessages: seconds => onSetDisappearingMessages: seconds =>
this.setDisappearingMessages(seconds), this.setDisappearingMessages(seconds),
@ -204,6 +205,24 @@
onUnblockUser: () => { onUnblockUser: () => {
this.model.unblock(); 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({ this.titleView = new Whisper.ReactWrapperView({

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

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

Loading…
Cancel
Save