4
1
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-02-11 17:55:51 +00:00

added notification q-app list

This commit is contained in:
Phillip 2023-08-25 23:26:56 -05:00
parent 922db68e53
commit 93658b2ba4
5 changed files with 78 additions and 8 deletions

View File

@ -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",

View File

@ -140,7 +140,9 @@ class NotificationBell extends connect(store)(LitElement) {
${this.notificationCount ? html`
<paper-icon-button style="color: green;" icon="icons:mail" @click=${() => this._toggleNotifications()} title="Q-Mail"></paper-icon-button>
` : html`
<paper-icon-button icon="icons:mail" @click=${() => this._toggleNotifications()} title="Q-Mail"></paper-icon-button>
<paper-icon-button icon="icons:mail" @click=${() => {
this._openTabQmail()
}} title="Q-Mail"></paper-icon-button>
`}
${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 {

View File

@ -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) {
<label for="blockShowNotification">${translate("settings.shownotifications")}</label>
</div>
</div>
<div class="content-box">
<h4>${translate("settings.qappNotification1")}</h4>
${this.appNotificationList.map((app)=> html`
<div style="display: flex; justify-content: space-between; margin-top: 10px;">
${app}
<button class="remove-button" @click=${() => this.removeApp(app)}>Remove</button>
</div>
`)}
</div>
</div>
${this.renderSetCoreButton()}
</div>
`
}
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``

View File

@ -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({

View File

@ -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;