forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disable screenshots on desktop also (keybase#26986)
- Loading branch information
1 parent
8a112fb
commit 5346b7f
Showing
4 changed files
with
90 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,70 @@ | ||
const Protect = () => null | ||
export default Protect | ||
import * as C from '@/constants' | ||
import * as T from '@/constants/types' | ||
import * as React from 'react' | ||
import * as Kb from '@/common-adapters' | ||
|
||
const Screenprotector = () => { | ||
const [disableScreenshot, setDisableScreenshot] = React.useState<boolean | undefined>(undefined) | ||
const initialDisableScreenshot = React.useRef<boolean | undefined>(undefined) | ||
const loadDisableScreenshot = C.useRPC(T.RPCGen.configGuiGetValueRpcPromise) | ||
|
||
// load it | ||
if (disableScreenshot === undefined) { | ||
setTimeout(() => { | ||
loadDisableScreenshot( | ||
[{path: 'ui.disableScreenshot'}], | ||
result => { | ||
const res = result.b ?? false | ||
initialDisableScreenshot.current = res | ||
setDisableScreenshot(res) | ||
}, | ||
() => { | ||
setDisableScreenshot(false) | ||
} | ||
) | ||
}, 1) | ||
} | ||
const submitDisableSpellcheck = C.useRPC(T.RPCGen.configGuiSetValueRpcPromise) | ||
|
||
const onToggleDisableScreenshot = () => { | ||
const next = !disableScreenshot | ||
setDisableScreenshot(next) | ||
submitDisableSpellcheck( | ||
[ | ||
{ | ||
path: 'ui.disableScreenshot', | ||
value: {b: next, isNull: false}, | ||
}, | ||
], | ||
() => {}, | ||
() => { | ||
console.log('cant save screenshot?') | ||
setDisableScreenshot(!next) | ||
} | ||
) | ||
} | ||
|
||
return ( | ||
<Kb.Box2 direction="vertical" fullWidth={true}> | ||
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.container}> | ||
<Kb.Checkbox | ||
label={ | ||
'Disable screenshots' + | ||
(initialDisableScreenshot.current === disableScreenshot ? '' : ' (restart required)') | ||
} | ||
disabled={disableScreenshot === undefined} | ||
checked={!!disableScreenshot} | ||
onCheck={onToggleDisableScreenshot} | ||
/> | ||
</Kb.Box2> | ||
</Kb.Box2> | ||
) | ||
} | ||
|
||
const styles = Kb.Styles.styleSheetCreate(() => ({ | ||
container: { | ||
...Kb.Styles.padding(Kb.Styles.globalMargins.small), | ||
}, | ||
})) | ||
|
||
export default Screenprotector |
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