Correctly sync dictionary on login and create account
This commit is contained in:
parent
33e9193abb
commit
d3ef16b947
|
@ -38,6 +38,7 @@ export function logIn() {
|
|||
loginModal.parentElement.removeChild(loginModal);
|
||||
triggerLoginChanges();
|
||||
addMessage(`Welcome${window.account.publicName !== '' ? ', ' + window.account.publicName : ''}! You are logged in.`);
|
||||
syncDictionary();
|
||||
}
|
||||
}).catch(err => console.error(err));
|
||||
}
|
||||
|
@ -106,6 +107,11 @@ export function createAccount() {
|
|||
triggerLoginChanges();
|
||||
addMessage('Account Created Successfully!');
|
||||
addMessage(`Welcome${publicName !== '' ? ', ' + publicName : ''}! You are logged in.`);
|
||||
if (window.currentDictionary.hasOwnProperty('externalID')) {
|
||||
// Ensure dictionary uploads to overwrite the auto-created default dictionary
|
||||
delete window.currentDictionary.externalID;
|
||||
}
|
||||
syncDictionary(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ login
|
|||
-> upload anything that needs update
|
||||
*/
|
||||
|
||||
export function syncDictionary() {
|
||||
export function syncDictionary(uploadAsNewIfNoExternalID = true) {
|
||||
if (!window.currentDictionary.hasOwnProperty('externalID')) {
|
||||
uploadWholeDictionary(true);
|
||||
uploadWholeDictionary(uploadAsNewIfNoExternalID);
|
||||
} else {
|
||||
addMessage('Syncing...');
|
||||
request({
|
||||
|
|
|
@ -194,7 +194,7 @@ VALUES (?, ?, ?, ?, ?)';
|
|||
$user = $user_data->id;
|
||||
$dictionary = $user_data->dictionary;
|
||||
$details_updated = $this->dictionary->setDetails($user, $dictionary, $dictionary_data['details']);
|
||||
$words_updated = $this->dictionary->setWords($dictionary, $dictionary_data['words']);
|
||||
$words_updated = $this->dictionary->setWords($user, $dictionary, $dictionary_data['words']);
|
||||
if ($details_updated === true && $words_updated === true) {
|
||||
return $this->token->hash($dictionary);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue