fix setting issue

This commit is contained in:
PhilReact 2023-10-21 16:07:01 +03:00
parent dfb7d234e8
commit d8694143f8
3 changed files with 113 additions and 74 deletions

View File

@ -588,7 +588,6 @@ class AppView extends connect(store)(LitElement) {
<notification-bell></notification-bell> <notification-bell></notification-bell>
<notification-bell-general></notification-bell-general> <notification-bell-general></notification-bell-general>
<save-settings-qdn></save-settings-qdn> <save-settings-qdn></save-settings-qdn>
<core-sync-status></core-sync-status>
</div> </div>
<div style="display: inline;"> <div style="display: inline;">
<span> <span>
@ -762,7 +761,6 @@ class AppView extends connect(store)(LitElement) {
await this.botArrrTradebook() await this.botArrrTradebook()
window.addEventListener('storage', async () => { window.addEventListener('storage', async () => {
console.log('testing')
this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.botBtcWallet) || "[]") this.tradeBotBtcBook = JSON.parse(localStorage.getItem(this.botBtcWallet) || "[]")
this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.botLtcWallet) || "[]") this.tradeBotLtcBook = JSON.parse(localStorage.getItem(this.botLtcWallet) || "[]")
this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.botDogeWallet) || "[]") this.tradeBotDogeBook = JSON.parse(localStorage.getItem(this.botDogeWallet) || "[]")

View File

@ -50,6 +50,9 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
this.fee = null; this.fee = null;
} }
static styles = css` static styles = css`
:host {
margin-right: 20px;
}
.header { .header {
display: flex; display: flex;
align-items: center; align-items: center;
@ -97,7 +100,7 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
font-size: 18px font-size: 18px;
} }
.accept-button:hover { .accept-button:hover {
@ -117,7 +120,7 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 10px;
font-size: 18px font-size: 18px;
} }
.undo-button:hover { .undo-button:hover {
@ -162,11 +165,11 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
const tempSettingsData = JSON.parse( const tempSettingsData = JSON.parse(
localStorage.getItem('temp-settings-data') || '{}' localStorage.getItem('temp-settings-data') || '{}'
); );
if (tempSettingsData) {
} console.log({ response });
const userLists = response.userLists || []; const userLists = response.userLists || [];
const friendsFeed = response.friendsFeed; const friendsFeed = response.friendsFeed;
const myMenuPlugs = response.myMenuPlugs const myMenuPlugs = response.myMenuPlugs;
this.valuesToBeSavedOnQdn = {}; this.valuesToBeSavedOnQdn = {};
if ( if (
@ -176,6 +179,8 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
tempSettingsData.userLists.timestamp < rawDataTimestamp)) tempSettingsData.userLists.timestamp < rawDataTimestamp))
) { ) {
const friendList = userLists[0]; const friendList = userLists[0];
const copyPayload = [...friendList];
localStorage.setItem( localStorage.setItem(
'friends-my-friend-list', 'friends-my-friend-list',
JSON.stringify(friendList) JSON.stringify(friendList)
@ -184,7 +189,7 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
new CustomEvent('friends-my-friend-list-event', { new CustomEvent('friends-my-friend-list-event', {
bubbles: true, bubbles: true,
composed: true, composed: true,
detail: friendList, detail: copyPayload,
}) })
); );
} else if ( } else if (
@ -205,6 +210,8 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
(tempSettingsData.friendsFeed && (tempSettingsData.friendsFeed &&
tempSettingsData.friendsFeed.timestamp < rawDataTimestamp)) tempSettingsData.friendsFeed.timestamp < rawDataTimestamp))
) { ) {
const copyPayload = [...friendsFeed];
localStorage.setItem( localStorage.setItem(
'friends-my-selected-feeds', 'friends-my-selected-feeds',
JSON.stringify(friendsFeed) JSON.stringify(friendsFeed)
@ -213,7 +220,7 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
new CustomEvent('friends-my-selected-feeds-event', { new CustomEvent('friends-my-selected-feeds-event', {
bubbles: true, bubbles: true,
composed: true, composed: true,
detail: friendsFeed, detail: copyPayload,
}) })
); );
} else if ( } else if (
@ -228,24 +235,29 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
}; };
} }
if ( if (
myMenuPlugs && myMenuPlugs &&
(!tempSettingsData.myMenuPlugs || (!tempSettingsData.myMenuPlugs ||
(tempSettingsData.myMenuPlugs && (tempSettingsData.myMenuPlugs &&
tempSettingsData.myMenuPlugs.timestamp < rawDataTimestamp)) tempSettingsData.myMenuPlugs.timestamp < rawDataTimestamp))
) { ) {
localStorage.setItem( if (Array.isArray(myMenuPlugs)) {
'myMenuPlugs', console.log('isArray')
JSON.stringify(myMenuPlugs) const copyPayload = [...myMenuPlugs];
);
this.dispatchEvent( localStorage.setItem(
new CustomEvent('myMenuPlugs-event', { 'myMenuPlugs',
bubbles: true, JSON.stringify(myMenuPlugs)
composed: true, );
detail: myMenuPlugs,
}) this.dispatchEvent(
); new CustomEvent('myMenuPlugs-event', {
bubbles: true,
composed: true,
detail: copyPayload,
})
);
}
} else if ( } else if (
tempSettingsData.myMenuPlugs && tempSettingsData.myMenuPlugs &&
tempSettingsData.myMenuPlugs.timestamp > rawDataTimestamp tempSettingsData.myMenuPlugs.timestamp > rawDataTimestamp
@ -315,7 +327,9 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
stateChanged(state) { stateChanged(state) {
if ( if (
state.app.accountInfo && state.app.accountInfo.names.length && state.app.nodeStatus && state.app.accountInfo &&
state.app.accountInfo.names.length &&
state.app.nodeStatus &&
state.app.nodeStatus.syncPercent !== this.syncPercentage state.app.nodeStatus.syncPercent !== this.syncPercentage
) { ) {
this.syncPercentage = state.app.nodeStatus.syncPercent; this.syncPercentage = state.app.nodeStatus.syncPercent;
@ -365,6 +379,9 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
const friendsFeed = JSON.parse( const friendsFeed = JSON.parse(
localStorage.getItem('friends-my-selected-feeds') || '[]' localStorage.getItem('friends-my-selected-feeds') || '[]'
); );
const myMenuPlugs = JSON.parse(
localStorage.getItem('myMenuPlugs') || '[]'
);
let newObject; let newObject;
@ -373,6 +390,7 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
version: 1, version: 1,
userLists: [friendsList], userLists: [friendsList],
friendsFeed, friendsFeed,
myMenuPlugs,
}; };
} else if (this.settingsRawData) { } else if (this.settingsRawData) {
const tempSettingsData = JSON.parse( const tempSettingsData = JSON.parse(
@ -383,6 +401,21 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
}; };
for (const key in tempSettingsData) { for (const key in tempSettingsData) {
if (tempSettingsData[key].hasOwnProperty('data')) { if (tempSettingsData[key].hasOwnProperty('data')) {
if (
key === 'userLists' &&
!Array.isArray(tempSettingsData[key].data)
)
continue;
if (
key === 'friendsFeed' &&
!Array.isArray(tempSettingsData[key].data)
)
continue;
if (
key === 'myMenuPlugs' &&
!Array.isArray(tempSettingsData[key].data)
)
continue;
newObject[key] = tempSettingsData[key].data; newObject[key] = tempSettingsData[key].data;
} }
} }
@ -506,50 +539,52 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
: get('save.saving2')} : get('save.saving2')}
> >
</vaadin-tooltip> </vaadin-tooltip>
<popover-component <popover-component for="save-icon" message="">
for="save-icon" <div style="margin-bottom:20px">
message="" <p style="margin:10px 0px; font-size:16px">
> ${`${get('walletpage.wchange12')}: ${
<div style="margin-bottom:20px"> this.fee ? this.fee.feeToShow : ''
<p style="margin:10px 0px; font-size:16px">${`${get('walletpage.wchange12')}: ${ }`}
this.fee ? this.fee.feeToShow : '' </p>
}`}</p>
</div>
<div style="display:flex;justify-content:space-between;gap:10px">
<div
class="undo-button"
@click="${() => {
localStorage.setItem('temp-settings-data', JSON.stringify({}));
this.valuesToBeSavedOnQdn = {}
const popover =
this.shadowRoot.querySelector(
'popover-component'
);
if (popover) {
popover.closePopover();
}
this.getGeneralSettingsQdn()
}}"
>
${translate('save.saving4')}
</div> </div>
<div <div
class="accept-button" style="display:flex;justify-content:space-between;gap:10px"
@click="${() => {
this.saveToQdn();
const popover =
this.shadowRoot.querySelector(
'popover-component'
);
if (popover) {
popover.closePopover();
}
}}"
> >
<div
${translate('browserpage.bchange28')} class="undo-button"
</div> @click="${() => {
localStorage.setItem(
'temp-settings-data',
JSON.stringify({})
);
this.valuesToBeSavedOnQdn = {};
const popover =
this.shadowRoot.querySelector(
'popover-component'
);
if (popover) {
popover.closePopover();
}
this.getGeneralSettingsQdn();
}}"
>
${translate('save.saving4')}
</div>
<div
class="accept-button"
@click="${() => {
this.saveToQdn();
const popover =
this.shadowRoot.querySelector(
'popover-component'
);
if (popover) {
popover.closePopover();
}
}}"
>
${translate('browserpage.bchange28')}
</div>
</div> </div>
</popover-component> </popover-component>
`} `}

View File

@ -344,7 +344,6 @@ class ShowPlugin extends connect(store)(LitElement) {
return html` return html`
<div class="tabs"> <div class="tabs">
${this.tabs.map((tab, index) => { ${this.tabs.map((tab, index) => {
console.log({tab})
let title = '' let title = ''
let icon = '' let icon = ''
let count = 0 let count = 0
@ -545,7 +544,6 @@ class ShowPlugin extends connect(store)(LitElement) {
}) })
window.addEventListener('storage', () => { window.addEventListener('storage', () => {
console.log('show plugin')
const checkLanguage = localStorage.getItem('qortalLanguage') const checkLanguage = localStorage.getItem('qortalLanguage')
const checkTheme = localStorage.getItem('qortalTheme') const checkTheme = localStorage.getItem('qortalTheme')
@ -1470,9 +1468,13 @@ class NavBar extends connect(store)(LitElement) {
await this.getMyFollowedNamesList() await this.getMyFollowedNamesList()
} }
_updateMyMenuPlugins(event) { async _updateMyMenuPlugins(event) {
await new Promise((res)=> {
setTimeout(() => {
res()
}, 1000);
})
const detail = event.detail const detail = event.detail
console.log({detailPlugs: detail})
this.myMenuPlugins = detail this.myMenuPlugins = detail
const addressInfo = this.addressInfo const addressInfo = this.addressInfo
const isMinter = addressInfo?.error !== 124 && +addressInfo?.level > 0 const isMinter = addressInfo?.error !== 124 && +addressInfo?.level > 0
@ -1502,7 +1504,6 @@ class NavBar extends connect(store)(LitElement) {
connectedCallback() { connectedCallback() {
super.connectedCallback() super.connectedCallback()
console.log('callback')
window.addEventListener('myMenuPlugs-event', this._updateMyMenuPlugins) } window.addEventListener('myMenuPlugs-event', this._updateMyMenuPlugins) }
disconnectedCallback() { disconnectedCallback() {
@ -1520,8 +1521,9 @@ class NavBar extends connect(store)(LitElement) {
localStorage.removeItem("myMenuPlugs") localStorage.removeItem("myMenuPlugs")
myFile = file myFile = file
const newTabMenu = JSON.parse((myFile) || "[]") const newTabMenu = JSON.parse((myFile) || "[]")
const copyPayload = [...newTabMenu]
localStorage.setItem("myMenuPlugs", JSON.stringify(newTabMenu)) localStorage.setItem("myMenuPlugs", JSON.stringify(newTabMenu))
this.saveSettingToTemp(newTabMenu) this.saveSettingToTemp(copyPayload)
this.shadowRoot.getElementById('importTabMenutDialog').close() this.shadowRoot.getElementById('importTabMenutDialog').close()
this.myMenuPlugins = JSON.parse(localStorage.getItem("myMenuPlugs") || "[]") this.myMenuPlugins = JSON.parse(localStorage.getItem("myMenuPlugs") || "[]")
this.firstUpdated() this.firstUpdated()
@ -2004,9 +2006,10 @@ class NavBar extends connect(store)(LitElement) {
if (myNameRes !== false) { if (myNameRes !== false) {
oldMenuPlugs.push(newMenuPlugsItem) oldMenuPlugs.push(newMenuPlugsItem)
const copyPayload = [...oldMenuPlugs]
localStorage.setItem("myMenuPlugs", JSON.stringify(oldMenuPlugs)) localStorage.setItem("myMenuPlugs", JSON.stringify(oldMenuPlugs))
this.saveSettingToTemp(oldMenuPlugs) this.saveSettingToTemp(copyPayload)
let myplugstring2 = get("walletpage.wchange52") let myplugstring2 = get("walletpage.wchange52")
parentEpml.request('showSnackBar', `${myplugstring2}`) parentEpml.request('showSnackBar', `${myplugstring2}`)
@ -2068,9 +2071,10 @@ class NavBar extends connect(store)(LitElement) {
if (myNameRes !== false) { if (myNameRes !== false) {
oldMenuPlugs.push(newMenuPlugsItem) oldMenuPlugs.push(newMenuPlugsItem)
const copyPayload = [...oldMenuPlugs]
localStorage.setItem("myMenuPlugs", JSON.stringify(oldMenuPlugs)) localStorage.setItem("myMenuPlugs", JSON.stringify(oldMenuPlugs))
this.saveSettingToTemp(oldMenuPlugs) this.saveSettingToTemp(copyPayload)
let myplugstring2 = get("walletpage.wchange52") let myplugstring2 = get("walletpage.wchange52")
parentEpml.request('showSnackBar', `${myplugstring2}`) parentEpml.request('showSnackBar', `${myplugstring2}`)
@ -2138,9 +2142,10 @@ class NavBar extends connect(store)(LitElement) {
} }
oldMenuPlugs.push(newMenuPlugsItem) oldMenuPlugs.push(newMenuPlugsItem)
const copyPayload = [...oldMenuPlugs]
localStorage.setItem("myMenuPlugs", JSON.stringify(oldMenuPlugs)) localStorage.setItem("myMenuPlugs", JSON.stringify(oldMenuPlugs))
this.saveSettingToTemp(oldMenuPlugs) this.saveSettingToTemp(copyPayload)
let myplugstring2 = get("walletpage.wchange52") let myplugstring2 = get("walletpage.wchange52")
parentEpml.request('showSnackBar', `${myplugstring2}`) parentEpml.request('showSnackBar', `${myplugstring2}`)
@ -2202,7 +2207,6 @@ class NavBar extends connect(store)(LitElement) {
} }
renderRemoveIcon(appurl, appicon, appname, appid, appplugin) { renderRemoveIcon(appurl, appicon, appname, appid, appplugin) {
console.log({appurl, appname, appid})
return html` return html`
<div class="menuIconPos" @click="${() => this.changePage(appplugin)}"> <div class="menuIconPos" @click="${() => this.changePage(appplugin)}">
@ -2274,10 +2278,12 @@ class NavBar extends connect(store)(LitElement) {
const pluginToRemove = this.pluginNumberToDelete const pluginToRemove = this.pluginNumberToDelete
this.newMenuFilter = [] this.newMenuFilter = []
this.newMenuFilter = this.myMenuList.filter((item) => item.pluginNumber !== pluginToRemove) this.newMenuFilter = this.myMenuList.filter((item) => item.pluginNumber !== pluginToRemove)
const copyPayload = [...this.newMenuFilter]
const myNewObj = JSON.stringify(this.newMenuFilter) const myNewObj = JSON.stringify(this.newMenuFilter)
localStorage.removeItem("myMenuPlugs") localStorage.removeItem("myMenuPlugs")
localStorage.setItem("myMenuPlugs", myNewObj) localStorage.setItem("myMenuPlugs", myNewObj)
this.saveSettingToTemp(myNewObj) this.saveSettingToTemp(copyPayload)
this.myMenuPlugins = JSON.parse(localStorage.getItem("myMenuPlugs") || "[]") this.myMenuPlugins = JSON.parse(localStorage.getItem("myMenuPlugs") || "[]")
this.firstUpdated() this.firstUpdated()
this.closeRemoveApp() this.closeRemoveApp()