Add OpenMemory (#2676)
Co-authored-by: Saket Aryan <94069182+whysosaket@users.noreply.github.com> Co-authored-by: Saket Aryan <saketaryan2002@gmail.com>
This commit is contained in:
47
openmemory/ui/store/uiSlice.ts
Normal file
47
openmemory/ui/store/uiSlice.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
|
||||
interface DialogState {
|
||||
updateMemory: {
|
||||
isOpen: boolean;
|
||||
memoryId: string | null;
|
||||
memoryContent: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
interface UIState {
|
||||
dialogs: DialogState;
|
||||
}
|
||||
|
||||
const initialState: UIState = {
|
||||
dialogs: {
|
||||
updateMemory: {
|
||||
isOpen: false,
|
||||
memoryId: null,
|
||||
memoryContent: null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const uiSlice = createSlice({
|
||||
name: 'ui',
|
||||
initialState,
|
||||
reducers: {
|
||||
openUpdateMemoryDialog: (state, action: PayloadAction<{ memoryId: string; memoryContent: string }>) => {
|
||||
state.dialogs.updateMemory.isOpen = true;
|
||||
state.dialogs.updateMemory.memoryId = action.payload.memoryId;
|
||||
state.dialogs.updateMemory.memoryContent = action.payload.memoryContent;
|
||||
},
|
||||
closeUpdateMemoryDialog: (state) => {
|
||||
state.dialogs.updateMemory.isOpen = false;
|
||||
state.dialogs.updateMemory.memoryId = null;
|
||||
state.dialogs.updateMemory.memoryContent = null;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
openUpdateMemoryDialog,
|
||||
closeUpdateMemoryDialog,
|
||||
} = uiSlice.actions;
|
||||
|
||||
export default uiSlice.reducer;
|
||||
Reference in New Issue
Block a user