I'm sure, if I really wanted to, I could find a two step process of loading at 0 opacity, finding the dimensions, and then moving it to the center and revealing it. But I don't have the desire. Still. I went ahead and added workspace properties to the central state and read from them when it makes sense.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
import { RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
|
|
|
const initialState: RootState["workspace"] = {
|
|
workspaceId: "",
|
|
animatedBG: true,
|
|
workspaceProperties: {
|
|
name: "undefined",
|
|
overlayIds: [],
|
|
previewWindowDimensions: { width: 0, height: 0 },
|
|
},
|
|
};
|
|
|
|
export type UpdateWorkspaceAction = {
|
|
workspaceId: WorkspaceId,
|
|
workspaceProperties: WorkspaceProperties,
|
|
};
|
|
|
|
export const workspaceSlice = createSlice({
|
|
name: "workspace",
|
|
initialState,
|
|
reducers: {
|
|
setWorkspaceId: (state, action: PayloadAction<WorkspaceId>) => {
|
|
state.workspaceId = action.payload;
|
|
},
|
|
setAnimatedBG: (state, action: PayloadAction<boolean>) => {
|
|
state.animatedBG = action.payload;
|
|
},
|
|
updateWorkspace: (state, action: PayloadAction<UpdateWorkspaceAction>) => {
|
|
state.workspaceId = action.payload.workspaceId;
|
|
state.workspaceProperties = action.payload.workspaceProperties;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
setWorkspaceId,
|
|
setAnimatedBG,
|
|
updateWorkspace,
|
|
} = workspaceSlice.actions;
|
|
export default workspaceSlice.reducer;
|