perf: persist searchfilter + page #462

This commit is contained in:
WDaan 2022-11-15 13:56:15 +01:00
parent 3b989499b8
commit 67b1551b36
2 changed files with 23 additions and 5 deletions

View file

@ -109,7 +109,11 @@ export default new Vuex.Store({
filteredTorrentsCount: 0, filteredTorrentsCount: 0,
latestSelectedTorrent: null, latestSelectedTorrent: null,
selectMode: false, selectMode: false,
searchPlugins: [] searchPlugins: [],
dashboard: {
currentPage: 1,
searchFilter: ''
}
}, },
actions: { actions: {
...actions ...actions

View file

@ -155,11 +155,8 @@ export default {
LastFinger: 0, LastFinger: 0,
LastHash: '' LastHash: ''
}, },
trcMoveTick: 0, trcMoveTick: 0,
input: '',
searchFilterEnabled: false, searchFilterEnabled: false,
pageNumber: 1,
mdiTextBoxSearch, mdiTextBoxSearch,
mdiChevronLeftCircle, mdiChevronLeftCircle,
mdiMagnify, mdiMagnify,
@ -169,7 +166,7 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['mainData', 'selected_torrents']), ...mapState(['mainData', 'selected_torrents', 'dashboard']),
...mapGetters(['getTorrents', 'getTorrentCountString', 'getWebuiSettings']), ...mapGetters(['getTorrents', 'getTorrentCountString', 'getWebuiSettings']),
torrents() { torrents() {
if (!this.hasSearchFilter) return this.getTorrents() if (!this.hasSearchFilter) return this.getTorrents()
@ -183,6 +180,22 @@ export default {
return fuse.search(this.input).map(el => el.item) return fuse.search(this.input).map(el => el.item)
}, },
pageNumber: {
get() {
return this.dashboard.currentPage
},
set(val) {
this.dashboard.currentPage = val
}
},
input: {
get() {
return this.dashboard.searchFilter
},
set(val) {
this.dashboard.searchFilter = val
}
},
topPagination() { topPagination() {
return this.getWebuiSettings().topPagination return this.getWebuiSettings().topPagination
}, },
@ -240,6 +253,7 @@ export default {
created() { created() {
this.$store.dispatch('INIT_INTERVALS') this.$store.dispatch('INIT_INTERVALS')
this.$store.commit('FETCH_CATEGORIES') this.$store.commit('FETCH_CATEGORIES')
if(this.input) this.searchFilterEnabled = true
}, },
beforeDestroy() { beforeDestroy() {
this.$store.commit('REMOVE_INTERVALS') this.$store.commit('REMOVE_INTERVALS')