From de7ae88ba4b2d556dfd43781c27b84786c0a255a Mon Sep 17 00:00:00 2001 From: PhilReact Date: Wed, 27 Dec 2023 21:56:53 +0200 Subject: [PATCH] save by address --- .../beginner-tour/sync-indicator.js | 5 ++- .../beginner-tour/tour-component.js | 12 +++--- .../friends-view/beginner-checklist.js | 39 ++++++++++++------- plugins/plugins/core/streams/onNewBlock.js | 4 -- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/core/src/components/beginner-tour/sync-indicator.js b/core/src/components/beginner-tour/sync-indicator.js index f4029800..1442df79 100644 --- a/core/src/components/beginner-tour/sync-indicator.js +++ b/core/src/components/beginner-tour/sync-indicator.js @@ -80,8 +80,10 @@ class SyncIndicator extends connect(store)(LitElement) { `; } async firstUpdated() { + this.address = store.getState().app.selectedAddress.address + const seenWelcomeSync = JSON.parse( - localStorage.getItem('welcome-sync') || 'false' + localStorage.getItem(`welcome-sync-${this.address}`) || 'false' ); this.seenWelcomeSync = seenWelcomeSync; } @@ -152,7 +154,6 @@ class SyncIndicator extends connect(store)(LitElement) { } stateChanged(state) { - console.log({state}) if ( state.app.nodeStatus && Object.keys(state.app.nodeStatus).length === 0 diff --git a/core/src/components/beginner-tour/tour-component.js b/core/src/components/beginner-tour/tour-component.js index 938cf393..9f331c9b 100644 --- a/core/src/components/beginner-tour/tour-component.js +++ b/core/src/components/beginner-tour/tour-component.js @@ -191,11 +191,11 @@ class TourComponent extends connect(store)(LitElement) { } } async firstUpdated() { + this.address = store.getState().app.selectedAddress.address const hasViewedTour = JSON.parse( - localStorage.getItem('hasViewedTour') || 'false' + localStorage.getItem(`hasViewedTour-${this.address}`) || 'false' ); - const selectedAddress = store.getState().app.selectedAddress || ''; - const name = await this.getName(selectedAddress.address); + const name = await this.getName(this.address); if (name) { this.hasName = true; } @@ -205,7 +205,7 @@ class TourComponent extends connect(store)(LitElement) { if (name) { this.hasViewedTour = true; this.hasName = true; - localStorage.setItem("hasViewedTour", JSON.stringify(true)) + localStorage.setItem(`hasViewedTour-${this.address}`, JSON.stringify(true)) } } catch (error) { console.log({ error }); @@ -309,7 +309,7 @@ class TourComponent extends connect(store)(LitElement) { steps: steps, allowClose: false, onDestroyed: () => { - localStorage.setItem("hasViewedTour", JSON.stringify(true)) + localStorage.setItem(`hasViewedTour-${this.address}`, JSON.stringify(true)) this.hasViewedTour = true; this.openWelcomeModal(); } @@ -346,7 +346,7 @@ class TourComponent extends connect(store)(LitElement) { } onClose() { - localStorage.setItem("welcome-sync", JSON.stringify(true)) + localStorage.setItem(`welcome-sync-${this.address}`, JSON.stringify(true)) this.dialogOpenedCongrats = false; } diff --git a/core/src/components/friends-view/beginner-checklist.js b/core/src/components/friends-view/beginner-checklist.js index be0e9dfe..3501d112 100644 --- a/core/src/components/friends-view/beginner-checklist.js +++ b/core/src/components/friends-view/beginner-checklist.js @@ -35,9 +35,7 @@ class BeginnerChecklist extends connect(store)(LitElement) { this.hasName = null; this.nodeUrl = this.getNodeUrl(); this.myNode = this.getMyNode(); - this.hasTourFinished = JSON.parse( - localStorage.getItem('hasViewedTour') || 'false' - ) + this.hasTourFinished = null; this._controlTourFinished = this._controlTourFinished.bind(this); this.uid = new ShortUniqueId(); } @@ -46,6 +44,13 @@ class BeginnerChecklist extends connect(store)(LitElement) { this.hasTourFinished = true; } + firstUpdated() { + this.address = store.getState().app.selectedAddress.address; + this.hasTourFinished = JSON.parse( + localStorage.getItem(`hasViewedTour-${this.address}`) || 'null' + ); + } + connectedCallback() { super.connectedCallback(); window.addEventListener( @@ -84,7 +89,7 @@ class BeginnerChecklist extends connect(store)(LitElement) { async getName(recipient) { try { - if(!recipient) return '' + if (!recipient) return ''; const endpoint = `${this.nodeUrl}/names/address/${recipient}`; const res = await fetch(endpoint); const getNames = await res.json(); @@ -107,7 +112,8 @@ class BeginnerChecklist extends connect(store)(LitElement) { this.syncPercentage = state.app.nodeStatus.syncPercent; if ( - !this.hasAttempted && state.app.selectedAddress && + !this.hasAttempted && + state.app.selectedAddress && state.app.nodeStatus.syncPercent === 100 ) { this.hasAttempted = true; @@ -126,7 +132,7 @@ class BeginnerChecklist extends connect(store)(LitElement) { state.app.accountInfo.names.length > 0 ) { this.hasName = true; - } + } } handleBlur() { @@ -137,10 +143,8 @@ class BeginnerChecklist extends connect(store)(LitElement) { }, 0); } - - render() { - return this.hasName === false || !this.hasTourFinished + return this.hasName === false || this.hasTourFinished === false ? html`
checklist
-
-
{ - store.dispatch( +
{ + store.dispatch( setNewTab({ url: `group-management`, id: this.uid.rnd(), @@ -216,8 +224,9 @@ class BeginnerChecklist extends connect(store)(LitElement) { openExisting: true, }) ); - this.handleBlur() - }}> + this.handleBlur(); + }} + >

Do you have a name registered?

${this.hasName ? html` diff --git a/plugins/plugins/core/streams/onNewBlock.js b/plugins/plugins/core/streams/onNewBlock.js index 2aceab39..4568a9ea 100644 --- a/plugins/plugins/core/streams/onNewBlock.js +++ b/plugins/plugins/core/streams/onNewBlock.js @@ -207,7 +207,6 @@ const initNodeStatusSocket = () => { const activeNodeStatusSocket = new WebSocket(activeNodeStatusSocketLink) // Open Connection activeNodeStatusSocket.onopen = (e) => { - console.log('onopen') nodeStatusSocketReconnectInterval = MIN_RECONNECT_INTERVAL; nodeStatusSocketcloseGracefully = false @@ -215,18 +214,15 @@ const initNodeStatusSocket = () => { } // Message Event activeNodeStatusSocket.onmessage = (e) => { - console.log('onmessage') doNodeStatus(JSON.parse(e.data)) } // Closed Event activeNodeStatusSocket.onclose = () => { - console.log('onclose') doNodeStatus({}); attemptReconnectNodeStatusSocket(); }; // Error Event activeNodeStatusSocket.onerror = (e) => { - console.log('onerror') doNodeStatus({}) } }