Skip to content

Commit

Permalink
Fix React hooks call order
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Jul 5, 2019
1 parent 071418b commit 1beb457
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/extension/content-script/injections/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ function PostInspector(props: PostInspectorProps) {
const { post, postBy, postId } = props
const whoAmI = (useIdentitiesAtFacebook()[0] || { identifier: PersonIdentifier.unknown }).identifier
const people = usePeople()
const [alreadySelectedPreviously, setAlreadySelectedPreviously] = useState<Person[]>([])

if (postBy.isUnknown) return null
const type = {
encryptedPost: deconstructPayload(post),
provePost: post.match(/🔒(.+)🔒/)!,
}
useAsync(() => {
if (!whoAmI.equals(postBy)) return Promise.resolve([])
if (!type.encryptedPost) return Promise.resolve([])
const { iv } = type.encryptedPost
return Services.Crypto.getSharedListOfPost(iv)
}, [post]).then(p => setAlreadySelectedPreviously(p))
if (type.encryptedPost) {
props.needZip()
const [alreadySelectedPreviously, setAlreadySelectedPreviously] = useState<Person[]>([])
const { iv, ownersAESKeyEncrypted } = type.encryptedPost
if (whoAmI.equals(postBy)) {
useAsync(() => Services.Crypto.getSharedListOfPost(iv), [post]).then(p => setAlreadySelectedPreviously(p))
}
return (
<DecryptPostUI.UI
requestAppendDecryptor={async people => {
Expand Down
1 change: 1 addition & 0 deletions src/social-network/facebook.com/parse-html.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* Parse static result from fb
* ! TODO: This is not work in Firefox Desktop
*/
export async function parseFacebookStaticHTML(url: RequestInfo) {
const request = await fetch(url, { credentials: 'include' })
Expand Down

0 comments on commit 1beb457

Please sign in to comment.