Files
snort/packages/app/src/State/Cache.ts
2023-02-21 14:36:12 +00:00

39 lines
774 B
TypeScript

import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { TaggedRawEvent } from "@snort/nostr";
export interface TimelineCache {
key: string;
main: TaggedRawEvent[];
related: TaggedRawEvent[];
latest: TaggedRawEvent[];
parent: TaggedRawEvent[];
}
export interface FeedCache {
timeline: TimelineCache;
}
const InitState = {
timeline: {
key: "",
main: [],
related: [],
latest: [],
parent: [],
},
} as FeedCache;
const CacheSlice = createSlice({
name: "Cache",
initialState: InitState,
reducers: {
setTimeline: (state, action: PayloadAction<TimelineCache>) => {
state.timeline = action.payload;
},
},
});
export const { setTimeline } = CacheSlice.actions;
export const reducer = CacheSlice.reducer;