-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting custom auto-lock timer (#3477)
Closes #3471 Adds a dropdown on settings to allow changing the maximum amount of time the wallet can remain idle before locking signing. This new setting is updated through an async thunk which triggers an event to also handle the change on the keyring service. The data is persisted on preferences db and exposed through redux to the UI. ## Testing Env ``` SUPPORT_CUSTOM_AUTOLOCK=true ``` ## To Test - [x] Import an account - [x] Lock and unlock your wallet - [x] Head to settings, change auto-lock time - [x] Change your system's date or change the options [here](https://github.com/tahowallet/extension/blob/be6fae78bd7949cd5e4d8f37c882152d00e8141d/ui/pages/Settings.tsx#L308), test that different time options work correctly - [x] If the wallet has been idle for 10 minutes and the current auto lock setting changes to from 15 minutes to 5, the wallet should lock itself. Latest build: [extension-builds-3477](https://github.com/tahowallet/extension/suites/13795656037/artifacts/764974743) (as of Thu, 22 Jun 2023 16:11:15 GMT).
- Loading branch information
Showing
14 changed files
with
310 additions
and
54 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
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,39 @@ | ||
import { MINUTE } from "../../constants" | ||
|
||
const DEFAULT_AUTOLOCK_INTERVAL = 60 * MINUTE | ||
|
||
type OldState = { | ||
ui: { | ||
settings: { | ||
[settingsKey: string]: unknown | ||
} | ||
[sliceKey: string]: unknown | ||
} | ||
[otherSlice: string]: unknown | ||
} | ||
|
||
type NewState = { | ||
ui: { | ||
settings: { | ||
[settingsKey: string]: unknown | ||
autoLockInterval: number | ||
} | ||
[sliceKey: string]: unknown | ||
} | ||
[otherSlice: string]: unknown | ||
} | ||
|
||
export default (prevState: Record<string, unknown>): NewState => { | ||
const typedPrevState = prevState as OldState | ||
|
||
return { | ||
...prevState, | ||
ui: { | ||
...typedPrevState.ui, | ||
settings: { | ||
...typedPrevState.ui.settings, | ||
autoLockInterval: DEFAULT_AUTOLOCK_INTERVAL, | ||
}, | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.