From 93658b2ba43591e94f2ec1a8b18bdfd1d84e843c Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 25 Aug 2023 23:26:56 -0500 Subject: [PATCH] added notification q-app list --- core/language/us.json | 3 +- .../notification-view/notification-bell.js | 21 ++++++- .../settings-view/notifications-view.js | 57 ++++++++++++++++++- .../plugins/core/components/ChatRightPanel.js | 4 -- .../plugins/core/qdn/browser/browser.src.js | 1 + 5 files changed, 78 insertions(+), 8 deletions(-) diff --git a/core/language/us.json b/core/language/us.json index 7fcfc8a1..206eb418 100644 --- a/core/language/us.json +++ b/core/language/us.json @@ -203,7 +203,8 @@ "exp2": "Export Master Key", "exp3": "Export", "exp4": "Please choose a wallet to backup the private master key.", - "core": "Start Core Settings" + "core": "Start Core Settings", + "qappNotification1": "Q-App notifications" }, "appinfo": { "blockheight": "Block Height", diff --git a/core/src/components/notification-view/notification-bell.js b/core/src/components/notification-view/notification-bell.js index 4ac64130..bb3913c5 100644 --- a/core/src/components/notification-view/notification-bell.js +++ b/core/src/components/notification-view/notification-bell.js @@ -140,7 +140,9 @@ class NotificationBell extends connect(store)(LitElement) { ${this.notificationCount ? html` this._toggleNotifications()} title="Q-Mail"> ` : html` - this._toggleNotifications()} title="Q-Mail"> + { + this._openTabQmail() + }} title="Q-Mail"> `} ${this.notificationCount ? html` @@ -188,6 +190,23 @@ class NotificationBell extends connect(store)(LitElement) { if (this.notifications.length === 0) return this.showNotifications = !this.showNotifications } + _openTabQmail() { + const query = `?service=APP&name=Q-Mail` + store.dispatch(setNewTab({ + url: `qdn/browser/index.html${query}`, + id: 'q-mail-notification', + myPlugObj: { + "url": "qapps", + "domain": "core", + "page": `qdn/browser/index.html${query}`, + "title": "Q-Mail", + "icon": "vaadin:mailbox", + "mwcicon": "mail_outline", + "menus": [], + "parent": false + } + })) + } static styles = css` .layout { diff --git a/core/src/components/settings-view/notifications-view.js b/core/src/components/settings-view/notifications-view.js index ca209c24..1d8fb279 100644 --- a/core/src/components/settings-view/notifications-view.js +++ b/core/src/components/settings-view/notifications-view.js @@ -14,7 +14,8 @@ class NotificationsView extends connect(store)(LitElement) { notificationConfig: { type: Object }, q_chatConfig: { type: Object }, blockConfig: { type: Object }, - theme: { type: String, reflect: true } + theme: { type: String, reflect: true }, + appNotificationList: {type: Array} } } @@ -24,6 +25,11 @@ class NotificationsView extends connect(store)(LitElement) { this.q_chatConfig = {} this.blockConfig = {} this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light' + this.appNotificationList = [] // Fetch the list of apps from local storage + } + + firstUpdated(){ + this.appNotificationList = this.getAppsFromStorage(); } static get styles() { @@ -42,7 +48,7 @@ class NotificationsView extends connect(store)(LitElement) { text-align: center; } - @media(min-width: 1150px) { + @media(min-width: 1400px) { .notification-box { display: grid; grid-template-columns: 1fr 1fr; @@ -106,6 +112,18 @@ class NotificationsView extends connect(store)(LitElement) { transition: all .2s; position: relative; } + + .remove-button { + font-family: Roboto, sans-serif; + font-size: 16px; + color: var(--mdc-theme-primary); + background-color: transparent; + padding: 8px 10px; + border-radius: 5px; + border: none; + transition: all 0.3s ease-in-out; + cursor: pointer; + } ` } @@ -145,12 +163,47 @@ class NotificationsView extends connect(store)(LitElement) { +
+

${translate("settings.qappNotification1")}

+ ${this.appNotificationList.map((app)=> html` +
+ ${app} + +
+ `)} + +
${this.renderSetCoreButton()} ` } + getAppsFromStorage() { + // Your method to fetch the list of apps from local storage + // Example: + const address= store.getState().app.selectedAddress.address + const id = `appNotificationList-${address}`; + const data = localStorage.getItem(id); + return data ? Object.keys(JSON.parse(data)) : []; + } + + removeApp(appName) { + // Remove the app from local storage + this.removeAppFromStorage(appName); + // Update the apps list in the component + this.appNotificationList = this.appNotificationList.filter(app => app !== appName); + } + + removeAppFromStorage(appName) { + // Your method to remove the app from local storage + const address= store.getState().app.selectedAddress.address + const id = `appNotificationList-${address}`; + const data = JSON.parse(localStorage.getItem(id) || '{}'); + delete data[appName]; + localStorage.setItem(id, JSON.stringify(data)); + } + renderSetCoreButton() { if (!isElectron()) { return html`` diff --git a/plugins/plugins/core/components/ChatRightPanel.js b/plugins/plugins/core/components/ChatRightPanel.js index fac86ebf..24a90f59 100644 --- a/plugins/plugins/core/components/ChatRightPanel.js +++ b/plugins/plugins/core/components/ChatRightPanel.js @@ -225,7 +225,6 @@ class ChatRightPanel extends LitElement { if(this.groupMembers.length < 20){ return } - console.log('this.leaveGroupObjp', this.leaveGroupObj) this.getMoreMembers(this.leaveGroupObj.groupId) } } @@ -252,7 +251,6 @@ class ChatRightPanel extends LitElement { activeChatHeadUrl="" .setActiveChatHeadUrl=${(val) => { if (val.address === this.myAddress) return; - console.log({ val }); this.selectedHead = val; this.setOpenUserInfo(true); this.setUserName({ @@ -269,7 +267,6 @@ class ChatRightPanel extends LitElement { activeChatHeadUrl="" .setActiveChatHeadUrl=${(val) => { if (val.address === this.myAddress) return; - console.log({ val }); this.selectedHead = val; this.setOpenUserInfo(true); this.setUserName({ @@ -286,7 +283,6 @@ class ChatRightPanel extends LitElement { activeChatHeadUrl="" .setActiveChatHeadUrl=${(val) => { if (val.address === this.myAddress) return; - console.log({ val }); this.selectedHead = val; this.setOpenUserInfo(true); this.setUserName({ diff --git a/plugins/plugins/core/qdn/browser/browser.src.js b/plugins/plugins/core/qdn/browser/browser.src.js index fd3d30de..94834fd8 100644 --- a/plugins/plugins/core/qdn/browser/browser.src.js +++ b/plugins/plugins/core/qdn/browser/browser.src.js @@ -2831,6 +2831,7 @@ class WebBrowser extends LitElement { } } addAppToNotificationList(appName) { + if(!appName) throw new Error('unknown app name') const id = `appNotificationList-${this.selectedAddress.address}`; const checkData = localStorage.getItem(id) ? JSON.parse(localStorage.getItem(id)) : null;