mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 17:55:51 +00:00
add to followlist
This commit is contained in:
parent
02822c50a3
commit
9d2909aa12
@ -158,6 +158,37 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
|
||||
return decryptedDataToBase64;
|
||||
}
|
||||
|
||||
async getMyFollowedNames() {
|
||||
|
||||
let myFollowedNames = []
|
||||
try {
|
||||
myFollowedNames = await parentEpml.request('apiCall', {
|
||||
url: `/lists/followedNames?apiKey=${this.myNode.apiKey}`
|
||||
})
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
|
||||
return myFollowedNames
|
||||
}
|
||||
|
||||
async followNames(names) {
|
||||
let items = names
|
||||
let namesJsonString = JSON.stringify({ "items": items })
|
||||
|
||||
let ret = await parentEpml.request('apiCall', {
|
||||
url: `/lists/followedNames?apiKey=${this.myNode.apiKey}`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: `${namesJsonString}`
|
||||
})
|
||||
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
async setValues(response, resource) {
|
||||
this.settingsRawData = response;
|
||||
const rawDataTimestamp = resource.updated;
|
||||
@ -179,6 +210,14 @@ class SaveSettingsQdn extends connect(store)(LitElement) {
|
||||
) {
|
||||
const friendList = userLists[0];
|
||||
const copyPayload = [...friendList];
|
||||
const onlyNames = copyPayload.map((item)=> item.name)
|
||||
const followedList = await this.getMyFollowedNames()
|
||||
|
||||
const namesNotInFollowedList = onlyNames.filter(name => !followedList.includes(name));
|
||||
if(namesNotInFollowedList.length > 0){
|
||||
await this.followNames(namesNotInFollowedList)
|
||||
|
||||
}
|
||||
|
||||
localStorage.setItem(
|
||||
'friends-my-friend-list',
|
||||
|
Loading…
x
Reference in New Issue
Block a user