Skip to content

Commit

Permalink
switching from append to unshift
Browse files Browse the repository at this point in the history
  • Loading branch information
vwh committed Jul 28, 2024
1 parent 49ac1bc commit e76cbfc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useQueryData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useQueryData(
setQueryError,
setIsCustomQuery,
query,
appendToQueryHestory,
unShiftToQueryHestory,
customQuery,
setCustomQuery
} = useSQLiteStore();
Expand All @@ -41,7 +41,7 @@ export function useQueryData(
if (error instanceof Error) setQueryError(error.message);
} finally {
setIsQueryLoading(false);
appendToQueryHestory(queryString);
unShiftToQueryHestory(queryString);
}
})();
}
Expand Down
6 changes: 3 additions & 3 deletions src/store/useSQLiteStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface SQLiteState {
setIsCustomQuery: (value: boolean) => void;
queryHestory: string[];
setQueryHestory: (value: string[]) => void;
appendToQueryHestory: (value: string) => void;
unShiftToQueryHestory: (value: string) => void;
expandPage: boolean;
setExpandPage: (value: boolean) => void;
}
Expand Down Expand Up @@ -97,8 +97,8 @@ const initializeStore = create<SQLiteState>((set, get) => ({

queryHestory: [],
setQueryHestory: (value: string[]) => set({ queryHestory: value }),
appendToQueryHestory: (value: string) =>
set((state) => ({ queryHestory: [...state.queryHestory, value] })),
unShiftToQueryHestory: (value: string) =>
set((state) => ({ queryHestory: [value, ...state.queryHestory] })),

expandPage: false,
setExpandPage: (value: boolean) => set({ expandPage: value })
Expand Down

0 comments on commit e76cbfc

Please sign in to comment.