0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2024-12-22 13:22:58 -05:00

Improve quality

This commit is contained in:
dragongoose 2023-08-18 13:12:06 -04:00
parent 93ca3a612a
commit fc498f078d
No known key found for this signature in database
GPG key ID: 01397EEC371CDAA5
3 changed files with 40 additions and 24 deletions

View file

@ -4,6 +4,7 @@ import videojs from 'video.js'
import 'videojs-contrib-quality-levels'
import type { QualityLevelList, QualityLevel } from 'videojs-contrib-quality-levels'
import i18n from '@/i18n'
import { getSetting } from '@/mixins'
const getQualityFromSettings = (qualityLevels) => {
const settings = localStorage.getItem("settings")
@ -52,7 +53,7 @@ export const createQualitySelector = (player: any) => {
}
// set quality on startup
const startingQuality = getQualityFromSettings()
const startingQuality = getSetting("defaultQuality")
const id = formatedQualities.find((i) => i.name === startingQuality)?.id
setQuality(id)

View file

@ -41,13 +41,43 @@ export async function getEndpoint(endpoint: string) {
return data
}
export function chatVisible() {
const storage = localStorage.getItem('settings')
if (!storage) return true
const parsed = JSON.parse(storage)
export function getDefaultSettings() {
return {
"audioOnly": {
"name": "Audio Only",
"selected": false,
"type": "checkbox"
},
"defaultQuality": {
"name": "Default Quality",
"options": ["160p", "360p", "480p", "720p", "1080p"],
"selected": "480p",
"type": "option"
},
"chatVisible": {
"name": "Hide Chat",
"selected": false,
"type": "checkbox"
},
}
}
export function getSetting(key: string): boolean | string {
const storage = localStorage.getItem('settings')
let parsed
if (!storage) {
parsed = getDefaultSettings()
} else {
parsed = JSON.parse(storage)
}
return parsed[key].selected
}
export function chatVisible() {
const p = getSetting("chatVisible")
// Flip becuase on the setting page it's
// displayed as "Hide Chat", but the value
// is chatVisible
return !parsed.chatVisible.selected
return !p
}

View file

@ -1,28 +1,13 @@
<script lang="ts">
import { getDefaultSettings } from '@/mixins'
export default {
setup() {
let settings
let storedSettings = localStorage.getItem("settings")
if (storedSettings === null) {
settings = {
"audioOnly": {
"name": "Audio Only",
"selected": false,
"type": "checkbox"
},
"defaultQuality": {
"name": "Default Quality",
"options": ["160p", "360p", "480p", "720p", "1080p"],
"selected": "480p",
"type": "option"
},
"chatVisible": {
"name": "Hide Chat",
"selected": false,
"type": "checkbox"
},
}
settings = getDefaultSettings()
} else {
settings = JSON.parse(storedSettings)
}