Zoom level persisted across restarts

This commit is contained in:
Manoj Vivek 2023-02-24 15:27:47 +05:30
parent 9228b2e2c6
commit aff7428286
2 changed files with 17 additions and 3 deletions

View file

@ -17,7 +17,7 @@ const zoomSteps = [
const initialState: RendererState = {
address: window.electron.store.get('homepage'),
zoomFactor: zoomSteps[3],
zoomFactor: zoomSteps[window.electron.store.get('renderer.zoomStepIndex')],
rotate: false,
isInspecting: undefined,
layout: window.electron.store.get('ui.previewLayout'),
@ -35,13 +35,17 @@ export const rendererSlice = createSlice({
zoomIn: (state) => {
const index = zoomSteps.indexOf(state.zoomFactor);
if (index < zoomSteps.length - 1) {
state.zoomFactor = zoomSteps[index + 1];
const newIndex = index + 1;
state.zoomFactor = zoomSteps[newIndex];
window.electron.store.set('renderer.zoomStepIndex', newIndex);
}
},
zoomOut: (state) => {
const index = zoomSteps.indexOf(state.zoomFactor);
if (index > 0) {
state.zoomFactor = zoomSteps[index - 1];
const newIndex = index - 1;
state.zoomFactor = zoomSteps[newIndex];
window.electron.store.set('renderer.zoomStepIndex', newIndex);
}
},
setRotate: (state, action: PayloadAction<boolean>) => {

View file

@ -16,6 +16,16 @@ const schema = {
},
},
},
renderer: {
type: 'object',
properties: {
zoomStepIndex: {
type: 'number',
default: 3,
},
},
default: {},
},
devtools: {
type: 'object',
properties: {