From 0383bc46f698d9e9a11c981799564ae51c3a5bb9 Mon Sep 17 00:00:00 2001 From: Ray Lillywhite Date: Sun, 21 May 2023 13:19:29 +0800 Subject: [PATCH] Fix sorting and filtering studies Previously, whenever you would use one of the filter or sort controls on the study page, it would reset the other one. That meant that it was impossible to view your own studies sorted by recently updated for example. This change preserves the filter when you change the sort and vice versa. Here's a video showing that the change works: https://d.rayll.com/i/xhN0OG/XRTuSzRk1a --- src/ui/study/StudyIndexCtrl.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/study/StudyIndexCtrl.ts b/src/ui/study/StudyIndexCtrl.ts index 8568607ddb..7713cfb49e 100644 --- a/src/ui/study/StudyIndexCtrl.ts +++ b/src/ui/study/StudyIndexCtrl.ts @@ -1,12 +1,14 @@ +import * as xhr from './studyXhr' + +import { PagerCategory, PagerData, PagerOrder } from '../../lichess/interfaces/study' + +import { Paginator } from '../../lichess/interfaces' +import { batchRequestAnimationFrame } from '../../utils/batchRAF' import debounce from 'lodash-es/debounce' import { fromNow } from '../../i18n' import { handleXhrError } from '../../utils' -import { batchRequestAnimationFrame } from '../../utils/batchRAF' import redraw from '../../utils/redraw' import router from '../../router' -import { Paginator } from '../../lichess/interfaces' -import { PagerData, PagerCategory, PagerOrder } from '../../lichess/interfaces/study' -import * as xhr from './studyXhr' export interface PagerDataWithDate extends PagerData { date: string @@ -96,12 +98,12 @@ export default class StudyIndexCtrl { public readonly onCatChange = (e: Event): void => { const cat = (e.target as HTMLSelectElement).value - router.setQueryParams({ cat }, true) + router.setQueryParams({cat: cat, order: this.order }, true) } public readonly onOrderChange = (e: Event): void => { const order = (e.target as HTMLSelectElement).value - router.setQueryParams({ order }, true) + router.setQueryParams({ cat: this.cat, order: order }, true) } public readonly onScroll = (e: Event): void => {