mirror of
https://github.com/docmost/docmost.git
synced 2026-08-24 06:32:12 +10:00
refactor(client): type comparePairAtom initializer so setters infer as writable
This commit is contained in:
@@ -11,4 +11,6 @@ export const diffCountsAtom = atom<DiffCounts | null>(null);
|
|||||||
export type ComparePair = { newerId: string; olderId: string };
|
export type ComparePair = { newerId: string; olderId: string };
|
||||||
export const compareModeAtom = atom<boolean>(false);
|
export const compareModeAtom = atom<boolean>(false);
|
||||||
export const compareSelectionAtom = atom<string[]>([]);
|
export const compareSelectionAtom = atom<string[]>([]);
|
||||||
export const comparePairAtom = atom<ComparePair | null>(null);
|
export const comparePairAtom = atom<ComparePair | null>(
|
||||||
|
null as ComparePair | null,
|
||||||
|
);
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ function HistoryList({ pageId }: Props) {
|
|||||||
const setHistoryModalOpen = useSetAtom(historyAtoms);
|
const setHistoryModalOpen = useSetAtom(historyAtoms);
|
||||||
const [compareMode, setCompareMode] = useAtom(compareModeAtom);
|
const [compareMode, setCompareMode] = useAtom(compareModeAtom);
|
||||||
const [compareSelection, setCompareSelection] = useAtom(compareSelectionAtom);
|
const [compareSelection, setCompareSelection] = useAtom(compareSelectionAtom);
|
||||||
// @ts-ignore
|
|
||||||
const setComparePair = useSetAtom(comparePairAtom);
|
const setComparePair = useSetAtom(comparePairAtom);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -87,7 +86,6 @@ function HistoryList({ pageId }: Props) {
|
|||||||
|
|
||||||
const handleSelect = useCallback(
|
const handleSelect = useCallback(
|
||||||
(id: string, index: number) => {
|
(id: string, index: number) => {
|
||||||
// @ts-ignore
|
|
||||||
setComparePair(null);
|
setComparePair(null);
|
||||||
setActiveHistoryId(id);
|
setActiveHistoryId(id);
|
||||||
setActiveHistoryPrevId(historyItems[index + 1]?.id ?? "");
|
setActiveHistoryPrevId(historyItems[index + 1]?.id ?? "");
|
||||||
@@ -108,7 +106,6 @@ function HistoryList({ pageId }: Props) {
|
|||||||
|
|
||||||
const handleStartCompare = useCallback(
|
const handleStartCompare = useCallback(
|
||||||
(id: string) => {
|
(id: string) => {
|
||||||
// @ts-ignore
|
|
||||||
setComparePair(null);
|
setComparePair(null);
|
||||||
setCompareMode(true);
|
setCompareMode(true);
|
||||||
setCompareSelection([id]);
|
setCompareSelection([id]);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export function useHistoryReset(pageId: string) {
|
|||||||
const resetCompare = () => {
|
const resetCompare = () => {
|
||||||
setCompareMode(false);
|
setCompareMode(false);
|
||||||
setCompareSelection([]);
|
setCompareSelection([]);
|
||||||
// @ts-ignore
|
|
||||||
setComparePair(null);
|
setComparePair(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user