-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add manually decrypt post in devtools; remove retry button
- Loading branch information
1 parent
2ec353b
commit 1eb450f
Showing
8 changed files
with
121 additions
and
49 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
const F = (props: { hint: string; content: string | number }) => ( | ||
<li> | ||
<span style={{ userSelect: 'none', opacity: 0.6 }}>{props.hint}: </span> | ||
<span>{props.content}</span> | ||
</li> | ||
) | ||
export function DebugList(props: { items: readonly (readonly [string, string | number | undefined] | JSX.Element)[] }) { | ||
return ( | ||
<ul style={{ wordBreak: 'break-all', padding: '0 1em', margin: 0 }}> | ||
{props.items.map(x => | ||
Array.isArray(x) ? <F hint={x[0]} content={x[1] === undefined ? 'undefined' : x[1]} /> : x, | ||
)} | ||
</ul> | ||
) | ||
} |
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
58 changes: 58 additions & 0 deletions
58
src/extension/options-page/DeveloperComponents/DecryptPost.tsx
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,58 @@ | ||
import React, { useState, useMemo } from 'react' | ||
import { makeStyles } from '@material-ui/core/styles' | ||
import Card from '@material-ui/core/Card' | ||
import CardContent from '@material-ui/core/CardContent' | ||
import Typography from '@material-ui/core/Typography' | ||
import { PersonIdentifier } from '../../../database/type' | ||
import { useTextField } from '../../../utils/components/useForms' | ||
import { DecryptPostUI } from '../../../components/InjectedComponents/DecryptedPost' | ||
import { Person } from '../../../database' | ||
import { useMyIdentities } from '../../../components/DataSource/useActivatedUI' | ||
import { ChooseIdentity } from '../../../components/shared/ChooseIdentity' | ||
|
||
const useStyles = makeStyles(theme => ({})) | ||
|
||
export function DecryptPostDeveloperMode() { | ||
const classes = useStyles() | ||
const myIdentities = useMyIdentities() | ||
const [whoAmISelected, setWhoAmI] = useState<Person | undefined>() | ||
// const [network, networkInput] = useTextField('Network', { defaultValue: 'facebook.com', required: true }) | ||
const [author, authorInput] = useTextField('Author ID of this post', { required: true }) | ||
const [encryptedText, encryptedTextInput] = useTextField('Encrypted post', { | ||
placeholder: '🎼3/4|ownersAESKeyEncrypted|iv|encryptedText|signature:||', | ||
required: true, | ||
}) | ||
const whoAmI = whoAmISelected | ||
? whoAmISelected.identifier | ||
: myIdentities[0] | ||
? myIdentities[0].identifier | ||
: PersonIdentifier.unknown | ||
const network = whoAmI.network | ||
const authorIdentifier = useMemo(() => new PersonIdentifier(network, author), [network, author]) | ||
return ( | ||
<Card> | ||
<CardContent> | ||
<Typography color="textSecondary" gutterBottom> | ||
Decrypt post manually | ||
</Typography> | ||
<Typography variant="caption" gutterBottom> | ||
Your identity? | ||
</Typography> | ||
<ChooseIdentity onChangeIdentity={who => setWhoAmI(who)} /> | ||
{/* {networkInput} */} | ||
{authorInput} | ||
{encryptedTextInput} | ||
<DecryptPostUI.UI | ||
disableSuccessDecryptionCache | ||
alreadySelectedPreviously={[]} | ||
requestAppendRecipients={async () => alert('Not available in this mode')} | ||
encryptedText={encryptedText} | ||
onDecrypted={post => {}} | ||
people={[]} | ||
postBy={authorIdentifier} | ||
whoAmI={whoAmI} | ||
/> | ||
</CardContent> | ||
</Card> | ||
) | ||
} |
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