Skip to content

Commit

Permalink
Fix fold comment button position (fix #4890)
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed Sep 4, 2024
1 parent 3bdf835 commit e91b9e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#end .bottombar {
padding-bottom: 8px !important;
}
18 changes: 13 additions & 5 deletions registry/lib/components/feeds/fold-comments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { select } from '@/core/spin-query'
import { childListSubtree } from '@/core/observer'

const entry = async () => {
const { ShadowRootStyles } = await import('@/core/shadow-root')
const { forEachFeedsCard } = await import('@/components/feeds/api')
const { childList } = await import('@/core/observer')
const commentSelector = '.bb-comment, .bili-comment-container'
Expand All @@ -30,20 +31,23 @@ const entry = async () => {
commentBox.insertAdjacentElement('beforeend', button)
}
if (feedsCardsManager.managerType === 'v2') {
const existingComment = dq(card, commentSelector) as HTMLElement
const getExistingComment = () => dq(card, commentSelector) as HTMLElement
const isCommentAreaReady = () => {
const existingComment = getExistingComment()
return existingComment !== null && dq(existingComment, 'bili-comments')
}
const handler = () => {
const button = dq(card, '.bili-dyn-action.comment') as HTMLElement
button?.click()
}
if (!existingComment) {
if (!isCommentAreaReady()) {
childListSubtree(card, () => {
const panel = dq(card, commentSelector)
if (panel) {
if (isCommentAreaReady()) {
injectToComment(card, handler)
}
})
} else {
injectToComment(existingComment, handler)
injectToComment(getExistingComment(), handler)
}
return
}
Expand Down Expand Up @@ -75,6 +79,10 @@ const entry = async () => {
forEachFeedsCard({
added: c => injectButton(c.element),
})

const styles = await import('./fold-comment-shadow.scss').then(m => m.default)
const shadowRootStyles = new ShadowRootStyles()
shadowRootStyles.addStyle(styles)
}

export const component = defineComponentMetadata({
Expand Down

0 comments on commit e91b9e6

Please sign in to comment.