Skip to content

Commit

Permalink
Merge pull request #3820 from nextcloud/fix/list-sorting/next
Browse files Browse the repository at this point in the history
fix sorting of poll list
  • Loading branch information
dartcafe authored Dec 26, 2024
2 parents 251903e + cbfc456 commit d2ed262
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/stores/polls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ export const usePollsStore = defineStore('polls', {
},

/*
* polls list, filtered by category
* polls list, filtered by category
*/
pollsByCategory: (state: PollList) => (filterId: FilterType) => {
const useCategory = state.categories.find((category) => category.id === filterId)
return state.list.filter((poll) => useCategory.filterCondition(poll))
},

pollsCount(state: PollList): Array<{ id: string, count: number }> {
const count = []
for (const category of state.categories) {
Expand All @@ -212,7 +212,7 @@ export const usePollsStore = defineStore('polls', {
pollsFilteredSorted(state: PollList): Poll[] {
return orderBy(
this.pollsByCategory(this.currentCategory.id),
[state.sort.by],
[sortColumnsMapping[state.sort.by]],
[state.sort.reverse ? 'desc' : 'asc'],
)
},
Expand Down Expand Up @@ -280,15 +280,15 @@ export const usePollsStore = defineStore('polls', {
this.list = response.data.list
this.meta.status = StatusResults.Loaded
} catch (e) {
if (e?.code === 'ERR_CANCELED') return
if (e?.code === 'ERR_CANCELED') return
this.meta.status = StatusResults.Error
Logger.error('Error loading polls', { error: e.response })
throw e
}
},

async setSort(payload: { sortBy: SortType }): Promise<void> {
if (this.sort.by === sortColumnsMapping[payload.sortBy]) {
if (this.sort.by === payload.sortBy) {
this.sort.reverse = !this.sort.reverse
} else {
this.sort.reverse = true
Expand Down

0 comments on commit d2ed262

Please sign in to comment.