@@ -228,17 +228,37 @@ function moveOrder(container: string, id: string, delta: number) {
228228 applyOrder (container , array )
229229}
230230
231+ function customOrderIdsForContainer(container : string ): string [] {
232+ const items = itemsOfContainer (container )
233+ const ids = items .map (item => item .id )
234+ if (container .startsWith (' cat:' )) {
235+ for (const item of items ) {
236+ if (item .type === ' group' )
237+ ids .push (... membersOf (item .id ).map (member => member .id ))
238+ }
239+ }
240+ return ids
241+ }
242+
231243function doesContainerHaveCustomOrder(container : string ): boolean {
232244 const current = itemsOfContainer (container ).map (i => i .id )
233245 const def = defaultItemsOfContainer (container ).map (i => i .id )
234- return current .length !== def .length || current .some ((id , i ) => id !== def [i ])
246+ if (current .length !== def .length || current .some ((id , i ) => id !== def [i ]))
247+ return true
248+ // Also account for custom ordering inside groups of a category
249+ if (container .startsWith (' cat:' )) {
250+ return itemsOfContainer (container ).some (item =>
251+ item .type === ' group' && doesContainerHaveCustomOrder (GROUP_CONTAINER (item .id )),
252+ )
253+ }
254+ return false
235255}
236256
237257function resetCustomOrderForContainer(container : string ) {
238- const items = itemsOfContainer (container )
258+ const ids = customOrderIdsForContainer (container )
239259 props .settingsStore .mutate ((state ) => {
240- items .forEach ((item ) => {
241- delete state .docksCustomOrder [item . id ]
260+ ids .forEach ((id ) => {
261+ delete state .docksCustomOrder [id ]
242262 })
243263 })
244264}
0 commit comments