chore: added pageTitle to renderState

This commit is contained in:
peterkwesiansah 2023-06-15 18:10:29 +01:00
parent c6d31e1f54
commit acf2c32253

View file

@ -5,6 +5,7 @@ import type { RootState } from '../..';
export interface RendererState {
address: string;
pageTitle: string;
zoomFactor: number;
rotate: boolean;
isInspecting: boolean | undefined;
@ -27,6 +28,7 @@ const urlFromQueryParam = () => {
const initialState: RendererState = {
address: urlFromQueryParam() ?? window.electron.store.get('homepage'),
pageTitle: '',
zoomFactor: zoomSteps[window.electron.store.get('renderer.zoomStepIndex')],
rotate: false,
isInspecting: undefined,
@ -43,6 +45,11 @@ export const rendererSlice = createSlice({
state.address = action.payload;
}
},
setPageTitle: (state, action: PayloadAction<string>) => {
if (action.payload !== state.pageTitle) {
state.pageTitle = action.payload;
}
},
zoomIn: (state) => {
const index = zoomSteps.indexOf(state.zoomFactor);
if (index < zoomSteps.length - 1) {
@ -84,10 +91,12 @@ export const {
setIsInspecting,
setLayout,
setIsCapturingScreenshot,
setPageTitle,
} = rendererSlice.actions;
export const selectZoomFactor = (state: RootState) => state.renderer.zoomFactor;
export const selectAddress = (state: RootState) => state.renderer.address;
export const selectPageTitle = (state: RootState) => state.renderer.pageTitle;
export const selectRotate = (state: RootState) => state.renderer.rotate;
export const selectIsInspecting = (state: RootState) =>
state.renderer.isInspecting;