0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2025-01-03 11:20:07 -05:00

Fix badges

This commit is contained in:
dragongoose 2023-07-03 19:32:06 -04:00
parent 877a567a15
commit af3f74f4b0
No known key found for this signature in database
GPG key ID: 50DB99B921579009

View file

@ -4,6 +4,7 @@ import { ref, inject } from 'vue'
import BadgeVue from './ChatBadge.vue'
import { getBadges } from '@/assets/badges'
import { parseMessage } from '@/assets/messageParser'
import { getEndpoint } from '@/mixins'
import type { Badge, ParsedMessage } from '@/assets/types'
@ -22,9 +23,15 @@ export default {
},
async setup(props) {
let messages = ref<ParsedMessage[]>([])
let badges = ref<Badge[]>([])
let badges: Badge[] = []
let wsLink = inject('wsLink') as string
await getEndpoint(`api/badges?channelName=${props.channelName}`)
.then((data) => {
console.log(data)
badges = data
})
return {
ws: new WebSocket(wsLink),
@ -32,7 +39,7 @@ export default {
badges,
}
},
mounted() {
async mounted() {
const chatList = this.$refs.chatList as Element
const chatStatusMessage = this.$refs.initConnectingStatus as Element
this.ws.onmessage = (message) => {
@ -61,7 +68,7 @@ export default {
this.messages.shift()
}
},
getBadges(message: ParsedMessage) {
getBadgesFromMessage(message: ParsedMessage) {
let badgesString = message.data.tags.badges;
if (!badgesString) return;
let badges = badgesString.split(',');
@ -103,7 +110,7 @@ export default {
<p class="text-sm items-center">
<ul class="inline-flex space-x-1 pr-1">
<li v-for="badge in getBadges(message)" :key="badge.id">
<li v-for="badge in getBadgesFromMessage(message)" :key="badge.id">
<badge-vue :badge-info="badge"></badge-vue>
</li>
</ul>