mirror of
https://github.com/responsively-org/responsively-app
synced 2024-09-20 22:31:59 +00:00
Zoom level persisted across restarts
This commit is contained in:
parent
9228b2e2c6
commit
aff7428286
2 changed files with 17 additions and 3 deletions
|
@ -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>) => {
|
||||
|
|
|
@ -16,6 +16,16 @@ const schema = {
|
|||
},
|
||||
},
|
||||
},
|
||||
renderer: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
zoomStepIndex: {
|
||||
type: 'number',
|
||||
default: 3,
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
},
|
||||
devtools: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
|
Loading…
Reference in a new issue