feat: reset inline wiki entry on route change

This commit is contained in:
Lukas Obermann
2023-06-21 21:59:59 +02:00
parent 66b8256743
commit 8d11ad7aeb
+10 -3
View File
@@ -1,6 +1,7 @@
import { PayloadAction, createSlice } from "@reduxjs/toolkit"
import * as ID from "optolith-database-schema/types/_Identifier"
import { RootState } from "../store.ts"
import { goToTab, goToTabGroup } from "./routeSlice.ts"
export type DisplayableMainIdentifier =
| ID.AdvancedCombatSpecialAbilityIdentifier
@@ -106,9 +107,7 @@ type InlineWikiState = {
id?: DisplayableMainIdentifier
}
const initialState: InlineWikiState = {
id: { tag: "Skill", skill: 33 },
}
const initialState: InlineWikiState = {}
const inlineLibrarySlice = createSlice({
name: "inlineLibrary",
@@ -118,6 +117,14 @@ const inlineLibrarySlice = createSlice({
state.id = action.payload
},
},
extraReducers: builder =>
builder
.addCase(goToTab, (state, _action) => {
state.id = undefined
})
.addCase(goToTabGroup, (state, _action) => {
state.id = undefined
}),
})
export const { changeInlineLibraryEntry } = inlineLibrarySlice.actions