improve responsiveness of emoji stealer and remove copypasta
This commit is contained in:
parent
7eabe5ace4
commit
e2b4c712af
4 changed files with 122 additions and 202 deletions
|
|
@ -12,6 +12,7 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
|
|||
import StringSetting from '../helpers/string_setting.vue'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useEmojiStore } from 'src/stores/emoji.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
|
|
@ -174,51 +175,9 @@ const EmojiTab = {
|
|||
this.sortPackFiles(packName)
|
||||
},
|
||||
|
||||
loadPacksPaginated(listFunction) {
|
||||
const pageSize = 25
|
||||
const allPacks = {}
|
||||
|
||||
return listFunction({
|
||||
instance: this.remotePackInstance,
|
||||
page: 1,
|
||||
pageSize: 0,
|
||||
})
|
||||
.then((data) => data.json())
|
||||
.then((data) => {
|
||||
if (data.error !== undefined) {
|
||||
return Promise.reject(data.error)
|
||||
}
|
||||
|
||||
let resultingPromise = Promise.resolve({})
|
||||
for (let i = 0; i < Math.ceil(data.count / pageSize); i++) {
|
||||
resultingPromise = resultingPromise
|
||||
.then(() =>
|
||||
listFunction({
|
||||
instance: this.remotePackInstance,
|
||||
page: i,
|
||||
pageSize,
|
||||
}),
|
||||
)
|
||||
.then((data) => data.json())
|
||||
.then((pageData) => {
|
||||
if (pageData.error !== undefined) {
|
||||
return Promise.reject(pageData.error)
|
||||
}
|
||||
|
||||
assign(allPacks, pageData.packs)
|
||||
})
|
||||
}
|
||||
|
||||
return resultingPromise
|
||||
})
|
||||
.then(() => allPacks)
|
||||
.catch((data) => {
|
||||
this.displayError(data)
|
||||
})
|
||||
},
|
||||
|
||||
refreshPackList() {
|
||||
this.loadPacksPaginated(
|
||||
useEmojiStore().getAdminPacks(
|
||||
this.remotePackInstance,
|
||||
this.$store.state.api.backendInteractor.listEmojiPacks,
|
||||
).then((allPacks) => {
|
||||
this.knownLocalPacks = allPacks
|
||||
|
|
@ -228,7 +187,8 @@ const EmojiTab = {
|
|||
})
|
||||
},
|
||||
listRemotePacks() {
|
||||
this.loadPacksPaginated(
|
||||
useEmojiStore().getAdminPacks(
|
||||
this.remotePackInstance,
|
||||
this.$store.state.api.backendInteractor.listRemoteEmojiPacks,
|
||||
)
|
||||
.then((allPacks) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue