{t("share.not-found")}
{t("share.not-found-description")}
- + )} diff --git a/app/src/store/chat.ts b/app/src/store/chat.ts index d4267363..8e34e53b 100644 --- a/app/src/store/chat.ts +++ b/app/src/store/chat.ts @@ -1,5 +1,5 @@ import { createSlice } from "@reduxjs/toolkit"; -import {ConversationInstance, Model} from "../conversation/types.ts"; +import { ConversationInstance, Model } from "../conversation/types.ts"; import { Message } from "../conversation/types.ts"; import { insertStart } from "../utils.ts"; import { RootState } from "./index.ts"; @@ -14,8 +14,10 @@ type initialStateType = { }; function GetModel(model: string | undefined | null): string { - return model && supportModels.filter((item: Model) => item.id === model).length - ? model : supportModels[0].id; + return model && + supportModels.filter((item: Model) => item.id === model).length + ? model + : supportModels[0].id; } const chatSlice = createSlice({ diff --git a/app/src/store/index.ts b/app/src/store/index.ts index 297e8d00..d558532f 100644 --- a/app/src/store/index.ts +++ b/app/src/store/index.ts @@ -6,6 +6,7 @@ import quotaReducer from "./quota"; import packageReducer from "./package"; import subscriptionReducer from "./subscription"; import apiReducer from "./api"; +import sharingReducer from "./sharing"; const store = configureStore({ reducer: { @@ -16,6 +17,7 @@ const store = configureStore({ package: packageReducer, subscription: subscriptionReducer, api: apiReducer, + sharing: sharingReducer, }, }); diff --git a/app/src/store/sharing.ts b/app/src/store/sharing.ts new file mode 100644 index 00000000..4810e903 --- /dev/null +++ b/app/src/store/sharing.ts @@ -0,0 +1,69 @@ +import { createSlice } from "@reduxjs/toolkit"; +import { AppDispatch, RootState } from "./index.ts"; +import { + deleteSharing, + listSharing, + SharingPreviewForm, +} from "../conversation/sharing.ts"; + +export const sharingSlice = createSlice({ + name: "sharing", + initialState: { + dialog: false, + data: [] as SharingPreviewForm[], + }, + reducers: { + toggleDialog: (state) => { + state.dialog = !state.dialog; + }, + setDialog: (state, action) => { + state.dialog = action.payload as boolean; + }, + openDialog: (state) => { + state.dialog = true; + }, + closeDialog: (state) => { + state.dialog = false; + }, + setData: (state, action) => { + state.data = action.payload as SharingPreviewForm[]; + }, + removeData: (state, action) => { + const hash = action.payload as string; + state.data = state.data.filter((item) => item.hash !== hash); + }, + }, +}); + +export const { + toggleDialog, + setDialog, + openDialog, + closeDialog, + setData, + removeData, +} = sharingSlice.actions; +export default sharingSlice.reducer; + +export const dialogSelector = (state: RootState): boolean => + state.sharing.dialog; +export const dataSelector = (state: RootState): SharingPreviewForm[] => + state.sharing.data; + +export const syncData = async (dispatch: AppDispatch): Promise