aboutsummaryrefslogtreecommitdiffstats
path: root/ui/src/state/store.ts
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-05-06 08:11:47 +0100
committerGitHub <noreply@github.com>2024-05-06 08:11:47 +0100
commit754ddeaa8d3e3e4f3efc93d5bb22c68c31bb5c36 (patch)
treef48fb912c2be2d08855e97ff24b6919a115c3c4f /ui/src/state/store.ts
parentchore(deps): bump serde_with from 3.7.0 to 3.8.1 (#2002) (diff)
downloadatuin-754ddeaa8d3e3e4f3efc93d5bb22c68c31bb5c36.zip
feat(ui): scroll history infinitely (#1999)
* wip, history scrolls right! * wip * virtual scroll fucking worksssss * paging works :) * scroll search results now too
Diffstat (limited to 'ui/src/state/store.ts')
-rw-r--r--ui/src/state/store.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/ui/src/state/store.ts b/ui/src/state/store.ts
index 7e237d70..fef1b632 100644
--- a/ui/src/state/store.ts
+++ b/ui/src/state/store.ts
@@ -8,6 +8,7 @@ import {
DefaultHomeInfo,
Alias,
ShellHistory,
+ Var,
} from "./models";
import { invoke } from "@tauri-apps/api/core";
@@ -26,9 +27,10 @@ interface AtuinState {
refreshAliases: () => void;
refreshVars: () => void;
refreshShellHistory: (query?: string) => void;
+ historyNextPage: (query?: string) => void;
}
-export const useStore = create<AtuinState>()((set) => ({
+export const useStore = create<AtuinState>()((set, get) => ({
user: DefaultUser,
homeInfo: DefaultHomeInfo,
aliases: [],
@@ -78,4 +80,23 @@ export const useStore = create<AtuinState>()((set) => ({
console.log(e);
});
},
+
+ historyNextPage: (query?: string) => {
+ let history = get().shellHistory;
+ let offset = history.length - 1;
+
+ if (query) {
+ invoke("search", { query: query, offset: offset })
+ .then((res: any) => {
+ set({ shellHistory: [...history, ...res] });
+ })
+ .catch((e) => {
+ console.log(e);
+ });
+ } else {
+ invoke("list", { offset: offset }).then((res: any) => {
+ set({ shellHistory: [...history, ...res] });
+ });
+ }
+ },
}));