diff --git a/commafeed-client/src/app/slices/entries.ts b/commafeed-client/src/app/slices/entries.ts index d0c880b6..5ce49b9b 100644 --- a/commafeed-client/src/app/slices/entries.ts +++ b/commafeed-client/src/app/slices/entries.ts @@ -1,7 +1,8 @@ import { createSlice, type PayloadAction } from "@reduxjs/toolkit" import { client } from "app/client" import { Constants } from "app/constants" -import { createAppAsyncThunk, type RootState } from "app/store" +import { type RootState } from "app/store" +import { createAppAsyncThunk } from "app/thunk" import { type Entry, type MarkRequest, type TagRequest } from "app/types" import { scrollToWithCallback } from "app/utils" import { flushSync } from "react-dom" @@ -11,10 +12,12 @@ import { reloadTree } from "./tree" import { reloadTags } from "./user" export type EntrySourceType = "category" | "feed" | "tag" + export interface EntrySource { type: EntrySourceType id: string } + export type ExpendableEntry = Entry & { expanded?: boolean } interface EntriesState { @@ -188,7 +191,12 @@ export const selectEntry = createAppAsyncThunk( // expand if requested const previouslySelectedEntry = state.entries.entries.find(e => e.id === state.entries.selectedEntryId) if (previouslySelectedEntry) { - thunkApi.dispatch(entriesSlice.actions.setEntryExpanded({ entry: previouslySelectedEntry, expanded: false })) + thunkApi.dispatch( + entriesSlice.actions.setEntryExpanded({ + entry: previouslySelectedEntry, + expanded: false, + }) + ) } thunkApi.dispatch(entriesSlice.actions.setEntryExpanded({ entry, expanded: arg.expand })) }) diff --git a/commafeed-client/src/app/slices/redirect.ts b/commafeed-client/src/app/slices/redirect.ts index 312c59b0..f2b5a1a8 100644 --- a/commafeed-client/src/app/slices/redirect.ts +++ b/commafeed-client/src/app/slices/redirect.ts @@ -1,6 +1,6 @@ import { createSlice, type PayloadAction } from "@reduxjs/toolkit" import { Constants } from "app/constants" -import { createAppAsyncThunk } from "app/store" +import { createAppAsyncThunk } from "app/thunk" interface RedirectState { to?: string diff --git a/commafeed-client/src/app/slices/server.ts b/commafeed-client/src/app/slices/server.ts index f59ffd91..fb38ccf0 100644 --- a/commafeed-client/src/app/slices/server.ts +++ b/commafeed-client/src/app/slices/server.ts @@ -1,6 +1,6 @@ -import { type PayloadAction, createSlice } from "@reduxjs/toolkit" +import { createSlice, type PayloadAction } from "@reduxjs/toolkit" import { client } from "app/client" -import { createAppAsyncThunk } from "app/store" +import { createAppAsyncThunk } from "app/thunk" import { type ServerInfo } from "app/types" interface ServerState { diff --git a/commafeed-client/src/app/slices/tree.ts b/commafeed-client/src/app/slices/tree.ts index 2a1cb14d..6777d360 100644 --- a/commafeed-client/src/app/slices/tree.ts +++ b/commafeed-client/src/app/slices/tree.ts @@ -1,6 +1,6 @@ import { createSlice, type PayloadAction } from "@reduxjs/toolkit" import { client } from "app/client" -import { createAppAsyncThunk } from "app/store" +import { createAppAsyncThunk } from "app/thunk" import { type Category, type CollapseRequest } from "app/types" import { visitCategoryTree } from "app/utils" // eslint-disable-next-line import/no-cycle diff --git a/commafeed-client/src/app/slices/user.ts b/commafeed-client/src/app/slices/user.ts index 0172a3a2..7b21bb13 100644 --- a/commafeed-client/src/app/slices/user.ts +++ b/commafeed-client/src/app/slices/user.ts @@ -2,7 +2,7 @@ import { t } from "@lingui/macro" import { showNotification } from "@mantine/notifications" import { createSlice, isAnyOf } from "@reduxjs/toolkit" import { client } from "app/client" -import { createAppAsyncThunk } from "app/store" +import { createAppAsyncThunk } from "app/thunk" import { type ReadingMode, type ReadingOrder, type Settings, type SharingSettings, type UserModel } from "app/types" // eslint-disable-next-line import/no-cycle import { reloadEntries } from "./entries" diff --git a/commafeed-client/src/app/store.ts b/commafeed-client/src/app/store.ts index 763cf945..4b900c21 100644 --- a/commafeed-client/src/app/store.ts +++ b/commafeed-client/src/app/store.ts @@ -1,4 +1,4 @@ -import { configureStore, createAsyncThunk } from "@reduxjs/toolkit" +import { configureStore } from "@reduxjs/toolkit" import { setupListeners } from "@reduxjs/toolkit/query" import { type TypedUseSelectorHook, useDispatch, useSelector } from "react-redux" import entriesReducer from "./slices/entries" @@ -24,7 +24,3 @@ export type AppDispatch = typeof store.dispatch export const useAppDispatch: () => AppDispatch = useDispatch export const useAppSelector: TypedUseSelectorHook = useSelector -export const createAppAsyncThunk = createAsyncThunk.withTypes<{ - state: RootState - dispatch: AppDispatch -}>() diff --git a/commafeed-client/src/app/thunk.ts b/commafeed-client/src/app/thunk.ts new file mode 100644 index 00000000..e22cf20a --- /dev/null +++ b/commafeed-client/src/app/thunk.ts @@ -0,0 +1,7 @@ +import { createAsyncThunk } from "@reduxjs/toolkit" +import { type AppDispatch, type RootState } from "app/store" + +export const createAppAsyncThunk = createAsyncThunk.withTypes<{ + state: RootState + dispatch: AppDispatch +}>()