Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Sep 27, 2022
1 parent b5ebb47 commit 4cc7179
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/components/Persist/Lock.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fatalErrorActions } from 'app/state/fatalerror'
import { persistActions } from 'app/state/persist'
import { selectIsPersisted } from 'app/state/persist/selectors'
import { Box, Button } from 'grommet'
Expand All @@ -17,6 +18,18 @@ export function Lock() {
<Button label="Lock profile" onClick={() => dispatch(persistActions.lockAsync())}></Button>

<Button label="Erase profile" onClick={() => dispatch(persistActions.eraseAsync())}></Button>
<Button
label="fatal error"
onClick={() =>
dispatch(
fatalErrorActions.setError({
message: 'Error message',
stack: 'Error stack',
sagaStack: 'sagaStack',
}),
)
}
></Button>
</Box>
)
}
1 change: 1 addition & 0 deletions src/app/state/persist/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function* watchPersistAsync() {
}

function* handleAsyncPersistActions(action: AnyAction) {
console.log('handleAsyncPersistActions: action of type', action.type)
if (persistActions.setPasswordAsync.match(action)) {
yield* call(setPasswordAsync, action)
} else if (persistActions.unlockAsync.match(action)) {
Expand Down
2 changes: 2 additions & 0 deletions src/store/configureStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { configureStoreWithSyncTabs } from 'app/state/persist/syncTabs'
export function configureAppStore(state?: Partial<RootState>) {
const sagaMiddleware = createSagaMiddleware({
onError: (error, info) => {
console.error(error)
console.error(info.sagaStack)
store.dispatch(
fatalErrorActions.setError({
message: error.toString(),
Expand Down
5 changes: 5 additions & 0 deletions src/store/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ function createRootReducer() {
return rootReducer
}

window.addEventListener('storage', event => {
console.log('a different tab wrote to localStorage', event)
})

export function createPersistedRootReducer() {
const originalRootReducer = createRootReducer()
return (state: RootState | undefined, action: AnyAction): RootState => {
console.log('PersistedRootReducer: action of type', action.type, action.$isSync ? '$isSync=true' : '')
const newState = originalRootReducer(state, action)
if (persistActions.setUnlockedRootState.match(action)) {
return receivePersistedRootState(
Expand Down

0 comments on commit 4cc7179

Please sign in to comment.