forked from Archives/Athou_commafeed
createAppAsyncThunk needs to be in its own file (https://stackoverflow.com/a/77136003/1885506)
This commit is contained in:
@@ -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 }))
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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<RootState> = useSelector
|
||||
export const createAppAsyncThunk = createAsyncThunk.withTypes<{
|
||||
state: RootState
|
||||
dispatch: AppDispatch
|
||||
}>()
|
||||
|
||||
7
commafeed-client/src/app/thunk.ts
Normal file
7
commafeed-client/src/app/thunk.ts
Normal file
@@ -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
|
||||
}>()
|
||||
Reference in New Issue
Block a user