Moved profile name saving to account manager.

pull/68/head
Mikunj 6 years ago
parent d75dee4fef
commit c10e81355d

@ -48,16 +48,7 @@
.registerSingleDevice( .registerSingleDevice(
this.$('#mnemonic').val(), this.$('#mnemonic').val(),
this.$('#mnemonic-language').val(), this.$('#mnemonic-language').val(),
async (pubKey) => { this.$('#display-name').val()
await storage.setProfileName(this.$('#display-name').val());
// Update the conversation if we have it
const conversation = ConversationController.get(pubKey);
if (conversation) {
const newProfile = storage.getLocalProfile();
conversation.setProfile(newProfile);
}
}
) )
.then(() => { .then(() => {
this.$el.trigger('openInbox'); this.$el.trigger('openInbox');

@ -9,7 +9,7 @@
dcodeIO, dcodeIO,
StringView, StringView,
log, log,
libphonenumber, storage,
Event, Event,
ConversationController ConversationController
*/ */
@ -49,7 +49,7 @@
requestSMSVerification(number) { requestSMSVerification(number) {
// return this.server.requestVerificationSMS(number); // return this.server.requestVerificationSMS(number);
}, },
registerSingleDevice(mnemonic, mnemonicLanguage, callback) { registerSingleDevice(mnemonic, mnemonicLanguage, profileName) {
const createAccount = this.createAccount.bind(this); const createAccount = this.createAccount.bind(this);
const clearSessionsAndPreKeys = this.clearSessionsAndPreKeys.bind(this); const clearSessionsAndPreKeys = this.clearSessionsAndPreKeys.bind(this);
const generateKeys = this.generateKeys.bind(this, 0); const generateKeys = this.generateKeys.bind(this, 0);
@ -77,8 +77,7 @@
.then(confirmKeys) .then(confirmKeys)
.then(() => { .then(() => {
const pubKeyString = StringView.arrayBufferToHex(identityKeyPair.pubKey); const pubKeyString = StringView.arrayBufferToHex(identityKeyPair.pubKey);
registrationDone(pubKeyString); registrationDone(pubKeyString, profileName);
callback(pubKeyString);
}); });
} }
) )
@ -447,11 +446,17 @@
); );
}); });
}, },
async registrationDone(number) { async registrationDone(number, profileName) {
window.log.info('registration done'); window.log.info('registration done');
// Ensure that we always have a conversation for ourself // Ensure that we always have a conversation for ourself
await ConversationController.getOrCreateAndWait(number, 'private'); const conversation = await ConversationController.getOrCreateAndWait(number, 'private');
await storage.setProfileName(profileName);
// Update the conversation if we have it
const newProfile = storage.getLocalProfile();
await conversation.setProfile(newProfile);
this.dispatchEvent(new Event('registration')); this.dispatchEvent(new Event('registration'));
}, },

Loading…
Cancel
Save