From aa52d2e8f893a49a0aebc7703f68e717cf60f4ef Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 6 Aug 2024 17:50:43 +0200 Subject: [PATCH] Resolve #1689 --- dev/App/User.js | 2 ++ dev/Common/UtilsUser.js | 10 ++++++++++ dev/Model/Identity.js | 11 +++------- dev/Settings/User/Accounts.js | 7 +++---- dev/Settings/User/General.js | 3 ++- dev/Stores/User/Identity.js | 3 +-- dev/View/Popup/Identity.js | 3 +-- .../app/libraries/RainLoop/Model/Identity.php | 5 ++++- .../RainLoop/Providers/Identities.php | 5 +++-- .../templates/Views/User/PopupsIdentity.html | 20 +++++++++---------- 10 files changed, 39 insertions(+), 30 deletions(-) diff --git a/dev/App/User.js b/dev/App/User.js index cd1ea93a1..5eeb8d909 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -88,6 +88,8 @@ export class AppUser extends AbstractApp { this.messageList = MessagelistUserStore; this.ask = AskPopupView; + + this.loadAccountsAndIdentities = loadAccountsAndIdentities; } /** diff --git a/dev/Common/UtilsUser.js b/dev/Common/UtilsUser.js index b0ddd745e..503cd793b 100644 --- a/dev/Common/UtilsUser.js +++ b/dev/Common/UtilsUser.js @@ -18,6 +18,9 @@ import { AccountUserStore } from 'Stores/User/Account'; import { IdentityUserStore } from 'Stores/User/Identity'; import { isArray } from 'Common/Utils'; +import { showScreenPopup } from 'Knoin/Knoin'; +import { IdentityPopupView } from 'View/Popup/Identity'; + export const // 1 = move, 2 = copy @@ -28,6 +31,8 @@ dropdownsDetectVisibility = (() => ).debounce(50), +editIdentity = Identity => showScreenPopup(IdentityPopupView, [Identity]), + loadAccountsAndIdentities = () => { AccountUserStore.loading(true); IdentityUserStore.loading(true); @@ -49,6 +54,11 @@ loadAccountsAndIdentities = () => { ? items.map(identityData => IdentityModel.reviveFromJson(identityData)) : [] ); + + // Invoke "Update Identity" pop up right after login + // https://github.com/the-djmaze/snappymail/issues/1689 + const main = IdentityUserStore.main(); + main && !main.exists() && setTimeout(()=>editIdentity(main), 1000); } }); }, diff --git a/dev/Model/Identity.js b/dev/Model/Identity.js index 9ec2551a8..ac38bc376 100644 --- a/dev/Model/Identity.js +++ b/dev/Model/Identity.js @@ -1,9 +1,6 @@ import { AbstractModel } from 'Knoin/AbstractModel'; import { addObservablesTo, addComputablesTo } from 'External/ko'; -import { showScreenPopup } from 'Knoin/Knoin'; -import { IdentityPopupView } from 'View/Popup/Identity'; - export class IdentityModel extends AbstractModel { /** * @param {string} id @@ -31,7 +28,9 @@ export class IdentityModel extends AbstractModel { smimeKey: '', smimeCertificate: '', - askDelete: false + askDelete: false, + + exists: false }); addComputablesTo(this, { @@ -50,8 +49,4 @@ export class IdentityModel extends AbstractModel { label = this.label(); return (name ? `${name} ` : '') + `<${email}>` + (label ? ` (${label})` : ''); } - - edit() { - showScreenPopup(IdentityPopupView, [this]); - } } diff --git a/dev/Settings/User/Accounts.js b/dev/Settings/User/Accounts.js index 92dc1eb41..6eec1e148 100644 --- a/dev/Settings/User/Accounts.js +++ b/dev/Settings/User/Accounts.js @@ -2,7 +2,7 @@ import ko from 'ko'; //import { koComputable } from 'External/ko'; import { SettingsCapa, SettingsGet } from 'Common/Globals'; -import { loadAccountsAndIdentities } from 'Common/UtilsUser'; +import { loadAccountsAndIdentities, editIdentity } from 'Common/UtilsUser'; import { AccountUserStore } from 'Stores/User/Account'; import { IdentityUserStore } from 'Stores/User/Identity'; @@ -12,7 +12,6 @@ import Remote from 'Remote/User/Fetch'; import { showScreenPopup } from 'Knoin/Knoin'; import { AccountPopupView } from 'View/Popup/Account'; -import { IdentityPopupView } from 'View/Popup/Identity'; export class UserSettingsAccounts /*extends AbstractViewSettings*/ { constructor() { @@ -44,11 +43,11 @@ export class UserSettingsAccounts /*extends AbstractViewSettings*/ { } addNewIdentity() { - showScreenPopup(IdentityPopupView); + editIdentity(); } editIdentity(identity) { - identity.edit(); + editIdentity(identity); } /** diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index cbbb2b8e0..27940f5ba 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -8,6 +8,7 @@ import { Settings, SettingsGet } from 'Common/Globals'; import { WYSIWYGS } from 'Common/HtmlEditor'; import { addSubscribablesTo, addComputablesTo } from 'External/ko'; import { i18n, translateTrigger, translatorReload, convertLangName } from 'Common/Translator'; +import { editIdentity } from 'Common/UtilsUser'; import { AbstractViewSettings } from 'Knoin/AbstractViews'; import { showScreenPopup } from 'Knoin/Knoin'; @@ -161,7 +162,7 @@ export class UserSettingsGeneral extends AbstractViewSettings { } editMainIdentity() { - IdentityUserStore.main()?.edit?.(); + editIdentity(IdentityUserStore.main()); } testSoundNotification() { diff --git a/dev/Stores/User/Identity.js b/dev/Stores/User/Identity.js index b8a3b4f22..94f5ce871 100644 --- a/dev/Stores/User/Identity.js +++ b/dev/Stores/User/Identity.js @@ -1,5 +1,4 @@ -import { koArrayWithDestroy } from 'External/ko'; -import { koComputable } from 'External/ko'; +import { koArrayWithDestroy, koComputable } from 'External/ko'; import { isArray } from 'Common/Utils'; export const IdentityUserStore = koArrayWithDestroy(); diff --git a/dev/View/Popup/Identity.js b/dev/View/Popup/Identity.js index 35c189b36..07c643e1b 100644 --- a/dev/View/Popup/Identity.js +++ b/dev/View/Popup/Identity.js @@ -2,7 +2,6 @@ import { addObservablesTo, koComputable } from 'External/ko'; import { getNotification } from 'Common/Translator'; -import { loadAccountsAndIdentities } from 'Common/UtilsUser'; import Remote from 'Remote/User/Fetch'; @@ -105,7 +104,7 @@ export class IdentityPopupView extends AbstractViewPopup { if (iError) { this.submitError(getNotification(iError)); } else { - loadAccountsAndIdentities(); + rl.app.loadAccountsAndIdentities(); this.close(); } }, data diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php index c18f13e0d..f31e77a9c 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Model/Identity.php @@ -27,6 +27,8 @@ class Identity implements \JsonSerializable private bool $pgpEncrypt = false; private bool $pgpSign = false; + public bool $exists = true; + private ?SensitiveString $smimeKey = null; private string $smimeCertificate = ''; @@ -155,7 +157,8 @@ class Identity implements \JsonSerializable 'pgpEncrypt' => $this->pgpEncrypt, 'pgpSign' => $this->pgpSign, 'smimeKey' => (string) $this->smimeKey, - 'smimeCertificate' => $this->smimeCertificate + 'smimeCertificate' => $this->smimeCertificate, + 'exists' => $this->exists ); } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Identities.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Identities.php index 5e258c166..956295bcd 100755 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Identities.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Identities.php @@ -48,8 +48,9 @@ class Identities extends AbstractProvider })); // If no primary identity is found, generate default one from account info - if ($primaryIdentity === null || $primaryIdentity === false) { - $primaryIdentity = $primaryIdentity = new Identity('', $account->Email()); + if (!$primaryIdentity) { + $primaryIdentity = new Identity('', $account->Email()); + $primaryIdentity->exists = false; $identities[] = $primaryIdentity; } diff --git a/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html b/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html index 042f65900..ebf739b65 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/PopupsIdentity.html @@ -14,12 +14,10 @@
- -
- -
+ +
@@ -31,10 +29,12 @@
- - + +
+ +