-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const SAVE_LAYOUT_PRESET = 'SAVE_LAYOUT_PRESET'; | ||
export const RECEIVE_LAYOUT_PRESET = 'RECEIVE_LAYOUT_PRESET'; | ||
export const GET_LAYOUT_PRESET = 'GET_LAYOUT_PRESET'; | ||
|
||
export const saveLayoutPreset = (preset) => ({ | ||
type: SAVE_LAYOUT_PRESET, | ||
preset | ||
}); | ||
|
||
export const receiveLayoutPreset = (preset) => ({ | ||
type: RECEIVE_LAYOUT_PRESET, | ||
preset | ||
}); | ||
|
||
export const getLayoutPreset = () => ({ | ||
type: GET_LAYOUT_PRESET | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import LayoutPreset from '../enums/LayoutPreset'; | ||
import { RECEIVE_LAYOUT_PRESET } from '../actions/settings'; | ||
|
||
const initialState = { | ||
layoutPreset: LayoutPreset.DEFAULT | ||
}; | ||
|
||
const telemetry = (state = initialState, action) => { | ||
switch (action.type) { | ||
case RECEIVE_LAYOUT_PRESET: | ||
return { | ||
...state, | ||
layoutPreset: action.preset | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default telemetry; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
GET_LAYOUT_PRESET, | ||
SAVE_LAYOUT_PRESET, | ||
receiveLayoutPreset | ||
} from './actions/settings'; | ||
import LayoutPreset from './enums/LayoutPreset'; | ||
|
||
const LAYOUT_PRESET_KEY = 'layoutPreset'; | ||
|
||
const storageMiddleware = store => next => action => { | ||
switch (action.type) { | ||
case GET_LAYOUT_PRESET: { | ||
const preset = localStorage.getItem(LAYOUT_PRESET_KEY) || LayoutPreset.DEFAULT; | ||
|
||
store.dispatch(receiveLayoutPreset(preset)); | ||
|
||
break; | ||
} | ||
case SAVE_LAYOUT_PRESET: { | ||
localStorage.setItem(LAYOUT_PRESET_KEY, action.preset); | ||
|
||
store.dispatch(receiveLayoutPreset(action.preset)); | ||
|
||
break; | ||
} | ||
default: | ||
next(action); | ||
|
||
break; | ||
} | ||
}; | ||
|
||
export default storageMiddleware; |