@@ -1019,6 +1103,115 @@ class NavBar extends connect(store)(LitElement) {
${translate("general.no")}
+
+
+
+
+
+
this.searchNameResult()}" title="${translate("websitespage.schange35")}">
+
this.closeNameSearch()}" title="${translate("general.close")}">
+
+
+
+
+ {
+ render(html`${this.renderNameAvatar(data.item)}`, root)
+ }}
+ >
+
+ {
+ render(html`${data.item.name}`, root)
+ }}
+ >
+
+ {
+ render(html`${this.renderMyFollowUnfollowButton(data.item)}`, root)
+ }}
+ >
+
+
+ ${this.isEmptyArray(this.searchNameResources) ? html`
+ ${translate("login.entername")}
+ `: ''}
+
+
+
+
+
+
+
+
${translate("tabmenu.tm31")}
+
+
+
+
+ {
+ render(html`${this.renderNameAvatar(data.item)}`, root)
+ }}
+ >
+
+ {
+ render(html`${data.item.name}`, root)
+ }}
+ >
+
+ {
+ render(html`${this.renderMyFollowUnfollowButton(data.item)}`, root)
+ }}
+ >
+
+
+ ${this.isEmptyArray(this.myFollowedNamesList) ? html`
+ ${translate("tabmenu.tm32")}
+ `: ''}
+
+
+
+
+
+
`
}
@@ -1052,6 +1245,165 @@ class NavBar extends connect(store)(LitElement) {
} else {
this.myMenuList = this.newMenuList
}
+
+ await this.getMyFollowedNames()
+ await this.getMyFollowedNamesList()
+ }
+
+ openNameSearch() {
+ this.searchNameResources = []
+ this.shadowRoot.getElementById('searchNameContent').value = ''
+ this.shadowRoot.getElementById('myFollowedNamesDialog').close()
+ this.shadowRoot.getElementById('searchNameDialog').open()
+ }
+
+ closeNameSearch() {
+ this.shadowRoot.getElementById('searchNameDialog').close()
+ }
+
+ openMyFollowedNames() {
+ this.shadowRoot.getElementById('searchNameDialog').close()
+ this.shadowRoot.getElementById('myFollowedNamesDialog').open()
+ this.getMyFollowedNamesList()
+ }
+
+ closeMyFollowedNames() {
+ this.shadowRoot.getElementById('myFollowedNamesDialog').close()
+ }
+
+ async getMyFollowedNames() {
+ let myFollowedNames = await parentEpml.request('apiCall', {
+ url: `/lists/followedNames?apiKey=${this.getApiKey()}`
+ })
+
+ this.myFollowedNames = myFollowedNames
+ }
+
+ searchNameKeyListener(e) {
+ if (e.key === 'Enter') {
+ this.searchNameResult()
+ }
+ }
+
+ async getMyFollowedNamesList() {
+ const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
+ const myNodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port
+ const followedNamesUrl = `${myNodeUrl}/lists/followedNames?apiKey=${this.getApiKey()}`
+
+ var myFollowedNamesNew = []
+
+ this.myFollowedNamesList = []
+
+ await fetch(followedNamesUrl).then(response => {
+ return response.json()
+ }).then(data => {
+ return data.map(item => {
+ const addListName = {
+ name: item
+ }
+ myFollowedNamesNew.push(addListName)
+ })
+ })
+ this.myFollowedNamesList = myFollowedNamesNew
+ if(this.shadowRoot.getElementById('myFollowedNamesDialog').opened) {
+ this.shadowRoot.getElementById('myFollowedNamesDialog').notifyResize()
+ }
+ }
+
+ async searchNameResult() {
+ let searchMyName = this.shadowRoot.getElementById('searchNameContent').value
+ if (searchMyName.length === 0) {
+ let err1string = get("appspage.schange34")
+ parentEpml.request('showSnackBar', `${err1string}`)
+ } else {
+ let searchNameResources = await parentEpml.request('apiCall', {
+ url: `/names/search?query=${searchMyName}&prefix=true&limit=0&reverse=true`
+ })
+ if (this.isEmptyArray(searchNameResources)) {
+ let err2string = get("appspage.schange17")
+ parentEpml.request('showSnackBar', `${err2string}`)
+ } else {
+ this.searchNameResources = searchNameResources
+ if(this.shadowRoot.getElementById('searchNameDialog').opened) {
+ this.shadowRoot.getElementById('searchNameDialog').notifyResize()
+ }
+ }
+ }
+ }
+
+ renderNameAvatar(nameObj) {
+ let myName = nameObj.name
+ const myNameNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]
+ const myNodeUrl = myNameNode.protocol + '://' + myNameNode.domain + ':' + myNameNode.port
+ const nameUrl = `${myNodeUrl}/arbitrary/THUMBNAIL/${myName}/qortal_avatar?async=true`
+ return html`

`
+ }
+
+ renderMyFollowUnfollowButton(nameObj) {
+ let name = nameObj.name
+
+ if (this.myFollowedNames == null || !Array.isArray(this.myFollowedNames)) {
+ return html``
+ }
+
+ if (this.myFollowedNames.indexOf(name) === -1) {
+ return html`
this.myFollowName(nameObj)}>add_to_queue ${translate("appspage.schange29")}`
+ } else {
+ return html`
this.myUnfollowName(nameObj)}>remove_from_queue ${translate("appspage.schange30")}`
+ }
+ }
+
+ async myFollowName(nameObj) {
+ let name = nameObj.name
+ let items = [
+ name
+ ]
+ let namesJsonString = JSON.stringify({ "items": items })
+
+ let ret = await parentEpml.request('apiCall', {
+ url: `/lists/followedNames?apiKey=${this.getApiKey()}`,
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: `${namesJsonString}`
+ })
+
+ if (ret === true) {
+ this.myFollowedNames = this.myFollowedNames.filter(item => item != name)
+ this.myFollowedNames.push(name)
+ } else {
+ let err3string = get("appspage.schange22")
+ parentEpml.request('showSnackBar', `${err3string}`)
+ }
+ this.getMyFollowedNamesList()
+ return ret
+ }
+
+ async myUnfollowName(nameObj) {
+ let name = nameObj.name
+ let items = [
+ name
+ ]
+ let namesJsonString = JSON.stringify({ "items": items })
+
+ let ret = await parentEpml.request('apiCall', {
+ url: `/lists/followedNames?apiKey=${this.getApiKey()}`,
+ method: 'DELETE',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: `${namesJsonString}`
+ })
+
+ if (ret === true) {
+ this.myFollowedNames = this.myFollowedNames.filter(item => item != name)
+ } else {
+ let err4string = get("appspage.schange23")
+ parentEpml.request('showSnackBar', `${err4string}`)
+ }
+ this.getMyFollowedNamesList()
+ return ret
}
async checkMyMenuPlugins() {
@@ -1707,6 +2059,11 @@ class NavBar extends connect(store)(LitElement) {
return apiKey
}
+ isEmptyArray(arr) {
+ if (!arr) { return true }
+ return arr.length === 0
+ }
+
stateChanged(state) {
this.menuList = state.app.registeredUrls
this.addressInfo = state.app.accountInfo.addressInfo