Skip to content

Commit

Permalink
fix: renderCompoundMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
guanbinrui committed Aug 24, 2020
1 parent e8ac456 commit 2b0a9a6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/social-network-provider/facebook.com/UI/collectPosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
makeTypedMessageText,
makeTypedMessageImage,
makeTypedMessageFromList,
makeTypedMessageCompound,
} from '../../../protocols/typed-message'

const posts = new LiveSelector().querySelectorAll<HTMLDivElement>(
Expand Down Expand Up @@ -82,7 +83,7 @@ export function collectPostsFacebook(this: SocialNetworkUI) {
info.postMetadataImages.add(url)
nextTypedMessage.push(makeTypedMessageImage(url))
}
info.parsedPostContent.value = makeTypedMessageFromList(...nextTypedMessage)
info.parsedPostContent.value = makeTypedMessageCompound(nextTypedMessage)
}
collectPostInfo()
info.postPayload.value = deconstructPayload(info.postContent.value, this.payloadDecoder)
Expand Down
6 changes: 2 additions & 4 deletions src/social-network-provider/twitter.com/ui/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
makeTypedMessageEmpty,
makeTypedMessageSuspended,
serializeTypedMessage,
makeTypedMessageCompound,
} from '../../../protocols/typed-message'

const resolveLastRecognizedIdentity = (self: SocialNetworkUI) => {
Expand Down Expand Up @@ -131,9 +132,6 @@ const registerPostCollector = (self: SocialNetworkUI) => {
info.postContent.addListener((newValue) => {
info.postPayload.value = deconstructPayload(newValue, self.payloadDecoder)
})
info.parsedPostContent.addListener((newValue) => {
// info.parsedPostContent.value =
})
injectMaskbookIconToPost(info)
self.posts.set(proxy, info)
return {
Expand Down Expand Up @@ -199,5 +197,5 @@ function collectPostInfo(tweetNode: HTMLDivElement | null, info: PostInfo, self:
})
.catch(() => makeTypedMessageEmpty())

info.parsedPostContent.value = makeTypedMessageFromList(...messages, makeTypedMessageSuspended(images))
info.parsedPostContent.value = makeTypedMessageCompound([...messages, makeTypedMessageSuspended(images)])
}
3 changes: 0 additions & 3 deletions src/social-network/PostInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ export abstract class PostInfo {
if (by.isUnknown || id === null) this.postIdentifier.value = null
else this.postIdentifier.value = new PostIdentifier(by, id)
}
if (process.env.NODE_ENV === 'development') {
this.parsedPostContent.addListener((x) => console.log(x))
}
this.postID.addListener(calc)
this.postBy.addListener(calc)

Expand Down
4 changes: 2 additions & 2 deletions src/social-network/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,17 @@ export function activateSocialNetworkUI(): void {
function hookUIPostMap(ui: SocialNetworkUI) {
const unmountFunctions = new WeakMap<object, () => void>()
ui.posts.event.on('set', (key, value) => {
const unmountPostDummy = ui.injectPostDummy(value)
const unmountPostInspector = ui.injectPostInspector(value)
const unmountPostDummy = ui.injectPostDummy(value)
const unmountCommentBox: () => void =
ui.injectCommentBox === 'disabled' ? nopWithUnmount : defaultTo(ui.injectCommentBox, nopWithUnmount)(value)
const unmountPostComments: () => void =
ui.injectPostComments === 'disabled'
? nopWithUnmount
: defaultTo(ui.injectPostComments, nopWithUnmount)(value)
unmountFunctions.set(key, () => {
unmountPostDummy()
unmountPostInspector()
unmountPostDummy()
unmountCommentBox()
unmountPostComments()
})
Expand Down

0 comments on commit 2b0a9a6

Please sign in to comment.