fix mutes and blocks
This commit is contained in:
parent
bcfe1de1b2
commit
869e7cfe0f
3 changed files with 19 additions and 22 deletions
|
|
@ -98,12 +98,13 @@ const List = {
|
||||||
|
|
||||||
this.fetchFunction(this.page)
|
this.fetchFunction(this.page)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
console.log(result)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.bottomedOut = isEmpty(result.items)
|
this.bottomedOut = isEmpty(result)
|
||||||
if (this.externalItems) return
|
if (this.externalItems) return
|
||||||
this.page += 1
|
this.page += 1
|
||||||
this.total = result.count
|
this.total = result.length
|
||||||
this.items.push(...result.items)
|
this.items.push(...result)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
|
|
||||||
|
|
@ -44,18 +44,18 @@ const MutesAndBlocks = {
|
||||||
return useUsersStore().currentUser
|
return useUsersStore().currentUser
|
||||||
},
|
},
|
||||||
blocks() {
|
blocks() {
|
||||||
return get(useUsersStore().currentUser, 'blockIds', [])
|
return get(this.user, 'blockIds', [])
|
||||||
},
|
},
|
||||||
mutes() {
|
mutes() {
|
||||||
return get(useUsersStore().currentUser, 'muteIds', [])
|
return get(this.user, 'muteIds', [])
|
||||||
},
|
},
|
||||||
domains() {
|
domains() {
|
||||||
return get(useUsersStore().currentUser, 'domainMutes', [])
|
return get(this.user, 'domainMutes', [])
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchItems(group) {
|
fetchItems(group) {
|
||||||
return () => this.$store.dispatch('fetch' + group, this.userId)
|
return () => useUsersStore()['fetch' + group](this.userId)
|
||||||
},
|
},
|
||||||
importFollows(file) {
|
importFollows(file) {
|
||||||
return importFollows({
|
return importFollows({
|
||||||
|
|
@ -111,16 +111,16 @@ const MutesAndBlocks = {
|
||||||
.then((users) => map(users, 'id'))
|
.then((users) => map(users, 'id'))
|
||||||
},
|
},
|
||||||
blockUsers(ids) {
|
blockUsers(ids) {
|
||||||
return this.$store.dispatch('blockUsers', ids)
|
return useUsersStore().blockUsers(ids)
|
||||||
},
|
},
|
||||||
unblockUsers(ids) {
|
unblockUsers(ids) {
|
||||||
return this.$store.dispatch('unblockUsers', ids)
|
return useUsersStore().unblockUsers(ids)
|
||||||
},
|
},
|
||||||
muteUsers(ids) {
|
muteUsers(ids) {
|
||||||
return this.$store.dispatch('muteUsers', ids)
|
return useUsersStore().muteUsers(ids)
|
||||||
},
|
},
|
||||||
unmuteUsers(ids) {
|
unmuteUsers(ids) {
|
||||||
return this.$store.dispatch('unmuteUsers', ids)
|
return useUsersStore().unmuteUsers(ids)
|
||||||
},
|
},
|
||||||
filterUnMutedDomains(urls) {
|
filterUnMutedDomains(urls) {
|
||||||
return urls.filter((url) => !this.user.domainMutes.includes(url))
|
return urls.filter((url) => !this.user.domainMutes.includes(url))
|
||||||
|
|
|
||||||
|
|
@ -241,9 +241,7 @@ export const useUsersStore = defineStore('users', {
|
||||||
this.currentUser.blockIds = blockIds
|
this.currentUser.blockIds = blockIds
|
||||||
},
|
},
|
||||||
addBlockId(blockId) {
|
addBlockId(blockId) {
|
||||||
if (this.currentUser.blockIds.includes(blockId)) {
|
this.currentUser.blockIds.add(blockId)
|
||||||
this.currentUser.blockIds.push(blockId)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
setBlockIdsMaxId(blockIdsMaxId) {
|
setBlockIdsMaxId(blockIdsMaxId) {
|
||||||
this.currentUser.blockIdsMaxId = blockIdsMaxId
|
this.currentUser.blockIdsMaxId = blockIdsMaxId
|
||||||
|
|
@ -255,9 +253,7 @@ export const useUsersStore = defineStore('users', {
|
||||||
this.currentUser.muteIdsMaxId = muteIdsMaxId
|
this.currentUser.muteIdsMaxId = muteIdsMaxId
|
||||||
},
|
},
|
||||||
addMuteId(muteId) {
|
addMuteId(muteId) {
|
||||||
if (this.currentUser.muteIds.includes(muteId)) {
|
this.currentUser.muteIds.add(muteId)
|
||||||
this.currentUser.muteIds.push(muteId)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
saveDomainMutes(domainMutes) {
|
saveDomainMutes(domainMutes) {
|
||||||
this.currentUser.domainMutes = domainMutes
|
this.currentUser.domainMutes = domainMutes
|
||||||
|
|
@ -412,7 +408,7 @@ export const useUsersStore = defineStore('users', {
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
const { data: blocks } = result
|
const { data: blocks } = result
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.saveBlockIds(blocks.map(({ id }) => id))
|
this.saveBlockIds(new Set(blocks.map(({ id }) => id)))
|
||||||
} else {
|
} else {
|
||||||
blocks.forEach(({ id }) => this.addBlockId(id))
|
blocks.forEach(({ id }) => this.addBlockId(id))
|
||||||
}
|
}
|
||||||
|
|
@ -476,7 +472,7 @@ export const useUsersStore = defineStore('users', {
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
const { data: mutes } = result
|
const { data: mutes } = result
|
||||||
if (reset) {
|
if (reset) {
|
||||||
this.saveMuteIds(mutes.map(({ id }) => id))
|
this.saveMuteIds(new Set(mutes.map(({ id }) => id)))
|
||||||
} else {
|
} else {
|
||||||
mutes.forEach(({ id }) => this.addMuteId(id))
|
mutes.forEach(({ id }) => this.addMuteId(id))
|
||||||
}
|
}
|
||||||
|
|
@ -680,9 +676,9 @@ export const useUsersStore = defineStore('users', {
|
||||||
.then(({ data: user, ...rest }) => {
|
.then(({ data: user, ...rest }) => {
|
||||||
// user.credentials = userCredentials
|
// user.credentials = userCredentials
|
||||||
user.credentials = accessToken
|
user.credentials = accessToken
|
||||||
user.blockIds = []
|
user.blockIds = new Set()
|
||||||
user.muteIds = []
|
user.muteIds = new Set()
|
||||||
user.domainMutes = []
|
user.domainMutes = new Set()
|
||||||
this.setCurrentUser(user)
|
this.setCurrentUser(user)
|
||||||
|
|
||||||
useSyncConfigStore()
|
useSyncConfigStore()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue