Skip to content

Commit

Permalink
chord: This function expects to fail to collect info, maybe don't thr…
Browse files Browse the repository at this point in the history
…ow is a good idea -- Jack-Works
  • Loading branch information
Misaka-0x447f committed Aug 24, 2019
1 parent ef84c99 commit a06055d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export function resolveLastRecognizedIdentityFacebook(this: SocialNetworkUI) {
.startWatch()
.then()
function assign(i: part) {
if (i.identifier.isUnknown) throw new Error('failed to recognize user id')
ref.value = i
if (!i.identifier.isUnknown) ref.value = i
}
}

Expand Down
19 changes: 14 additions & 5 deletions src/social-network-provider/twitter.com/ui/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ import { equal, notEmpty } from '../../../utils/assert'
export const resolveLastRecognizedIdentity = (self: SocialNetworkUI) => {
const selfSelector = selfInfoSelectors.screenName
const assign = () => {
const ref = self.lastRecognizedIdentity
const info = selfInfoSelectors.screenName.evaluateOnce()
const id = new PersonIdentifier(host, notEmpty(info, 'user id not found')[0])
equal(id.isUnknown, false, 'user id not recognized')
ref.value = { identifier: id }
try {
const ref = self.lastRecognizedIdentity
const info = selfInfoSelectors.screenName.evaluateOnce()
const id = new PersonIdentifier(host, notEmpty(info, 'user id not found')[0])
equal(id.isUnknown, false, 'user id not recognized')
ref.value = { identifier: id }
} catch (e) {
/**
* This function expects to fail to collect info,
* maybe don't throw is a good idea
* -- Jack-Works
*/
console.log(e);
}
}
new MutationObserverWatcher(selfSelector)
.enableSingleMode()
Expand Down
6 changes: 6 additions & 0 deletions src/social-network/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ interface SocialNetworkUIInformationCollector {
* ```
*
* If `selectedIdentity` is null, you should try to set it to an identity in the `myIdentitiesRef`
*
*/
/**
* This function expects to fail to collect info,
* maybe don't throw is a good idea
* -- Jack-Works
*/
resolveLastRecognizedIdentity(): void
/**
Expand Down

0 comments on commit a06055d

Please sign in to comment.