mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2024-12-22 13:22:58 -05:00
Add option to hide chat
This commit is contained in:
parent
90f9947493
commit
93ca3a612a
4 changed files with 25 additions and 6 deletions
|
@ -40,3 +40,14 @@ export async function getEndpoint(endpoint: string) {
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function chatVisible() {
|
||||||
|
const storage = localStorage.getItem('settings')
|
||||||
|
if (!storage) return true
|
||||||
|
const parsed = JSON.parse(storage)
|
||||||
|
|
||||||
|
// Flip becuase on the setting page it's
|
||||||
|
// displayed as "Hide Chat", but the value
|
||||||
|
// is chatVisible
|
||||||
|
return !parsed.chatVisible.selected
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@ export default {
|
||||||
"selected": "480p",
|
"selected": "480p",
|
||||||
"type": "option"
|
"type": "option"
|
||||||
},
|
},
|
||||||
|
"chatVisible": {
|
||||||
|
"name": "Hide Chat",
|
||||||
|
"selected": false,
|
||||||
|
"type": "checkbox"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings = JSON.parse(storedSettings)
|
settings = JSON.parse(storedSettings)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import LoadingScreen from '@/components/LoadingScreen.vue'
|
||||||
import VideoTab from '@/components/user/VideoTab.vue'
|
import VideoTab from '@/components/user/VideoTab.vue'
|
||||||
|
|
||||||
import type { StreamerData } from '@/types'
|
import type { StreamerData } from '@/types'
|
||||||
import { truncate, abbreviate, getEndpoint } from '@/mixins'
|
import { truncate, abbreviate, getEndpoint, chatVisible } from '@/mixins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['rootBackendUrl'],
|
inject: ['rootBackendUrl'],
|
||||||
|
@ -59,7 +59,8 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
truncate,
|
truncate,
|
||||||
abbreviate
|
abbreviate,
|
||||||
|
chatVisible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -167,6 +168,6 @@ export default {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<twitch-chat :isLive="true" :channelName="data.login" class="h-2/3"></twitch-chat>
|
<twitch-chat v-if="chatVisible()" :isLive="true" :channelName="data.login" class="h-2/3"></twitch-chat>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import FollowButton from '@/components/FollowButton.vue'
|
||||||
import LoadingScreen from '@/components/LoadingScreen.vue'
|
import LoadingScreen from '@/components/LoadingScreen.vue'
|
||||||
|
|
||||||
import type { Video } from '@/types'
|
import type { Video } from '@/types'
|
||||||
import { truncate, abbreviate, getEndpoint } from '@/mixins'
|
import { truncate, abbreviate, getEndpoint, chatVisible } from '@/mixins'
|
||||||
|
|
||||||
interface ChatComponent {
|
interface ChatComponent {
|
||||||
updateVodComments: (time: number) => void
|
updateVodComments: (time: number) => void
|
||||||
|
@ -63,9 +63,11 @@ export default {
|
||||||
truncate,
|
truncate,
|
||||||
abbreviate,
|
abbreviate,
|
||||||
handlePlayerTimeUpdate(time: number) {
|
handlePlayerTimeUpdate(time: number) {
|
||||||
|
if (!chatVisible()) return
|
||||||
const chat = this.$refs.chat as ChatComponent
|
const chat = this.$refs.chat as ChatComponent
|
||||||
chat.updateVodComments(time)
|
chat.updateVodComments(time)
|
||||||
}
|
},
|
||||||
|
chatVisible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -135,6 +137,6 @@ export default {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<twitch-chat :isVod="true" :channelName="data.streamer.login" ref="chat"></twitch-chat>
|
<twitch-chat v-if="chatVisible()" :isVod="true" :channelName="data.streamer.login" ref="chat"></twitch-chat>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in a new issue