Files
Tom MoorandClaude Fable 5.1 6a34835260 refactor: DRY up app stores with a shared page fetch helper and IndexedStore (#13633)
* refactor: DRY up app stores with fetchPaginated helper and IndexedStore

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* refactor: Resolve related models by store responseKey instead of a key map

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 05:10:15 -04:00

23 lines
584 B
TypeScript

import { override } from "mobx";
import type Model from "~/models/base/Model";
import Store from "./Store";
/**
* A store for models that carry a fractional index, ordered by that index and
* then by the most recently updated.
*/
export default abstract class IndexedStore<
T extends Model & { index: string },
> extends Store<T> {
@override
get orderedData(): T[] {
return Array.from(this.data.values()).sort((a, b) => {
if (a.index === b.index) {
return a.updatedAt > b.updatedAt ? -1 : 1;
}
return a.index < b.index ? -1 : 1;
});
}
}