diff --git a/core/src/components/friends-view/profile.js b/core/src/components/friends-view/profile.js index d1f369d7..cfb33051 100644 --- a/core/src/components/friends-view/profile.js +++ b/core/src/components/friends-view/profile.js @@ -816,10 +816,7 @@ class ProfileQdn extends connect(store)(LitElement) { ? html` 0 || this.resourceExists === false - ? 'active' - : 'notActive'} + class=${'notActive'} @click=${() => { const target = this.shadowRoot.getElementById( 'popover-notification' diff --git a/core/src/components/friends-view/save-settings-qdn.js b/core/src/components/friends-view/save-settings-qdn.js index 710813f7..4e4b00cf 100644 --- a/core/src/components/friends-view/save-settings-qdn.js +++ b/core/src/components/friends-view/save-settings-qdn.js @@ -7,6 +7,8 @@ import WebWorker from '../WebWorkerFile.js'; import '@polymer/paper-spinner/paper-spinner-lite.js'; import '@vaadin/tooltip'; import { get, translate } from 'lit-translate'; +import ShortUniqueId from 'short-unique-id'; + import { decryptGroupData, @@ -18,6 +20,7 @@ import { import { publishData } from '../../../../plugins/plugins/utils/publish-image.js'; import { parentEpml } from '../show-plugin.js'; import '../notification-view/popover.js'; +import { setNewTab } from '../../redux/app/app-actions.js'; class SaveSettingsQdn extends connect(store)(LitElement) { static get properties() { @@ -29,6 +32,9 @@ class SaveSettingsQdn extends connect(store)(LitElement) { resourceExists: { type: Boolean }, isSaving: { type: Boolean }, fee: { type: Object }, + hasName: {type: Boolean}, + error: {type: String}, + name: {type: String} }; } @@ -49,6 +55,11 @@ class SaveSettingsQdn extends connect(store)(LitElement) { this.valuesToBeSavedOnQdn = {}; this.isSaving = false; this.fee = null; + this.hasName = false; + this.error = ""; + this.uid = new ShortUniqueId(); + this.name = undefined; + } static styles = css` :host { @@ -311,13 +322,26 @@ class SaveSettingsQdn extends connect(store)(LitElement) { async getGeneralSettingsQdn() { try { + this.error = "" const arbFee = await this.getArbitraryFee(); this.fee = arbFee; this.hasAttemptedToFetchResource = true; let resource; - const nameObject = store.getState().app.accountInfo.names[0]; - if (!nameObject) throw new Error('no name'); + let nameObject + try { + nameObject = store.getState().app.accountInfo.names[0]; + + } catch (error) { + + } + if (!nameObject) { + this.name = null; + this.error = 'no name' + throw new Error('no name'); + } const name = nameObject.name; + this.name = name; + this.hasName = true this.error = ''; const url = `${this.nodeUrl}/arbitrary/resources/search?service=DOCUMENT_PRIVATE&identifier=qortal_general_settings&name=${name}&prefix=true&exactmatchnames=true&excludeblocked=true&limit=20`; const res = await fetch(url); @@ -365,8 +389,6 @@ class SaveSettingsQdn extends connect(store)(LitElement) { stateChanged(state) { if ( - state.app.accountInfo && - state.app.accountInfo.names.length && state.app.nodeStatus && state.app.nodeStatus.syncPercent !== this.syncPercentage ) { @@ -379,6 +401,15 @@ class SaveSettingsQdn extends connect(store)(LitElement) { this.getGeneralSettingsQdn(); } } + + if ( + state.app.accountInfo && + state.app.accountInfo.names.length && + state.app.nodeStatus && + state.app.nodeStatus.syncPercent === 100 && this.hasName === false && this.hasAttemptedToFetchResource && state.app.accountInfo && state.app.accountInfo.names && state.app.accountInfo.names.length > 0 + ) { + this.getGeneralSettingsQdn(); + } } async getArbitraryFee() { @@ -531,7 +562,78 @@ class SaveSettingsQdn extends connect(store)(LitElement) { style="display: block; margin: 0 auto;" > ` - : html` + : !this.name ? html` + { + const target = this.shadowRoot.getElementById( + 'popover-notification' + ); + const popover = + this.shadowRoot.querySelector( + 'popover-component' + ); + if (popover) { + popover.openPopover(target); + } + }} + style="user-select:none;cursor:pointer" + >save + + + +
+

+ ${translate('profile.profile1')} +

+
+
+
+ ${translate('profile.profile2')} +
+
+
+ ` : html`