Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalife committed Dec 9, 2024
1 parent 8efaaac commit d76b4af
Showing 2 changed files with 22 additions and 7 deletions.
23 changes: 17 additions & 6 deletions packages/desktop-client/src/hooks/useSplitsExpanded.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { SplitMode, SplitState } from 'loot-core/client/state-types/app';
import React, {
createContext,
useMemo,
useEffect,
useContext,
useReducer,
Dispatch,
ReactNode,
type Dispatch,
type ReactNode,
} from 'react';
import { useSelector, useDispatch } from 'react-redux';

import {
type SplitMode,
type SplitState,
} from 'loot-core/client/state-types/app';

type ToggleSplitAction = {
type: 'toggle-split';
id: string;
@@ -60,7 +64,7 @@ const SplitsExpandedContext = createContext<SplitsStateContext>({
},
dispatch: () => {
throw new Error('Unitialised context method called: dispatch');
}
},
});

export function useSplitsExpanded() {
@@ -83,7 +87,10 @@ type SplitsExpandedProviderProps = {
initialMode: SplitMode;
};

export function SplitsExpandedProvider({ children, initialMode = 'expand' }: SplitsExpandedProviderProps) {
export function SplitsExpandedProvider({
children,
initialMode = 'expand',
}: SplitsExpandedProviderProps) {
const cachedState = useSelector(state => state.app.lastSplitState);
const reduxDispatch = useDispatch();

@@ -145,7 +152,11 @@ export function SplitsExpandedProvider({ children, initialMode = 'expand' }: Spl
return { ...state, transitionId: null };
}
},
cachedState.current || { ids: new Set<string>(), mode: initialMode, transitionId: null },
cachedState.current || {
ids: new Set<string>(),
mode: initialMode,
transitionId: null,
},
);

useEffect(() => {
6 changes: 5 additions & 1 deletion packages/loot-core/src/client/state-types/app.d.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,11 @@ import type { UndoState } from '../../server/undo';
import type * as constants from '../constants';

export type SplitMode = 'collapse' | 'expand';
export type SplitState = { ids: Set<string>; mode: SplitMode; transitionId: string | null };
export type SplitState = {
ids: Set<string>;
mode: SplitMode;
transitionId: string | null;
};

export type AppState = {
loadingText: string | null;

0 comments on commit d76b4af

Please sign in to comment.