不直接在Ticker修改父组件状态

This commit is contained in:
John Smith 2022-02-22 23:48:01 +08:00
parent 6c92859408
commit b5b9b2601a
2 changed files with 14 additions and 7 deletions

View File

@ -169,18 +169,25 @@ export default {
return constants.getPriceConfig(message.price).pinTime
},
updateProgress() {
//
this.curTime = new Date()
for (let i = 0; i < this.messages.length;) {
let message = this.messages[i]
//
let filteredMessages = []
let messagesChanged = false
for (let message of this.messages) {
let pinTime = this.getPinTime(message)
if ((this.curTime - message.addTime) / (60 * 1000) >= pinTime) {
if (this.pinnedMessage == message) {
messagesChanged = true
if (this.pinnedMessage === message) {
this.pinnedMessage = null
}
this.messages.splice(i, 1)
} else {
i++
continue
}
filteredMessages.push(message)
}
if (messagesChanged) {
this.$emit('update:messages', filteredMessages)
}
},
onItemClick(message) {

View File

@ -2,7 +2,7 @@
<yt-live-chat-renderer class="style-scope yt-live-chat-app" style="--scrollbar-width:11px;" hide-timestamps
@mousemove="refreshCantScrollStartTime"
>
<ticker class="style-scope yt-live-chat-renderer" :messages="paidMessages" :showGiftName="showGiftName"></ticker>
<ticker class="style-scope yt-live-chat-renderer" :messages.sync="paidMessages" :showGiftName="showGiftName"></ticker>
<yt-live-chat-item-list-renderer class="style-scope yt-live-chat-renderer" allow-scroll>
<div ref="scroller" id="item-scroller" class="style-scope yt-live-chat-item-list-renderer animated" @scroll="onScroll">
<div ref="itemOffset" id="item-offset" class="style-scope yt-live-chat-item-list-renderer" style="height: 0px;">