More porting

This commit is contained in:
root
2021-10-22 08:19:51 +05:30
parent 005a8ed444
commit 83239c3282
10 changed files with 40 additions and 48 deletions
+8 -9
View File
@@ -142,7 +142,7 @@ export default {
localPlayer.configure(
'streaming.bufferingGoal',
Math.max(this.$store.getters.getPreferenceNumber('bufferGoal', 10), 10)
Math.max(this.$store.getters['prefs/getPreferenceNumber']('bufferGoal', 10), 10)
)
this.setPlayerAttrs(localPlayer, videoEl, uri, mime, shaka)
@@ -166,14 +166,14 @@ export default {
})
videoEl.addEventListener('volumechange', () => {
this.$store.commit('setPrefs', {
this.$store.commit('prefs/setPrefs', {
id: 'volume',
value: videoEl.volume
})
})
videoEl.addEventListener('ratechange', () => {
this.$store.commit('setPrefs', {
this.$store.commit('prefs/setPrefs', {
id: 'rate',
value: videoEl.playbackRate
})
@@ -206,7 +206,7 @@ export default {
this.player = player
const disableVideo = this.$store.getters.getPreferenceBoolean('listen', false) && !this.video.livestream
const disableVideo = this.$store.getters['prefs/getPreferenceBoolean']('listen', false) && !this.video.livestream
this.player.configure({
preferredVideoCodecs: this.preferredVideoCodecs,
@@ -216,9 +216,8 @@ export default {
}
})
const quality = this.$store.getters.getPreferenceNumber('quality', 0)
const qualityConds =
quality > 0 && (this.video.audioStreams.length > 0 || this.video.livestream) && !disableVideo
const quality = this.$store.getters['prefs/getPreferenceNumber']('quality', 0)
const qualityConds = quality > 0 && (this.video.audioStreams.length > 0 || this.video.livestream) && !disableVideo
if (qualityConds) this.player.configure('abr.enabled', false)
player.load(uri, 0, mime).then(() => {
@@ -248,8 +247,8 @@ export default {
subtitle.name
)
})
videoEl.volume = this.$store.getters.getPreferenceNumber('volume', 1)
videoEl.playbackRate = this.$store.getters.getPreferenceNumber('rate', 1)
videoEl.volume = this.$store.getters['prefs/getPreferenceNumber']('volume', 1)
videoEl.playbackRate = this.$store.getters['prefs/getPreferenceNumber']('rate', 1)
})
}
},
+2 -2
View File
@@ -55,7 +55,7 @@ export default {
},
methods: {
async fetchChannel () {
return this.$store.dispatch('fetchJson', {
return this.$store.dispatch('auth/makeRequest', {
path: '/' + this.$route.params.path + '/' + this.$route.params.channelId
})
},
@@ -71,7 +71,7 @@ export default {
},
fetchMoreVideos () {
this.$store.dispatch('fetchJson', {
this.$store.dispatch('auth/makeRequest', {
path: '/nextpage/channel/' + this.channel.id,
params: {
nextpage: this.channel.nextpage
+2 -2
View File
@@ -61,7 +61,7 @@ export default {
},
computed: {
getRssUrl () {
return this.$store.getters.apiUrl + '/rss/playlists/' + this.$route.query.list
return this.$store.getters['prefs/apiUrl'] + '/rss/playlists/' + this.$route.query.list
},
chunkedByFour () {
@@ -70,7 +70,7 @@ export default {
},
methods: {
async fetchPlaylist () {
return this.$store.dispatch('fetchJson', {
return this.$store.dispatch('auth/makeRequest', {
path: '/playlists/' + this.$route.query.list
})
},
+3 -3
View File
@@ -3,8 +3,8 @@
<h1 class="text-h4 text-center">{{ $t('titles.preferences') }}</h1>
<v-divider class="ma-4" />
<div style="display: flex;" v-for="(opt, optId) in options" :key="optId">
<v-simple-checkbox v-if="opt.type === 'bool'" :value="$store.getters.getPreferenceBoolean(opt.id, opt.default)" @input="setValue(opt.id, $event)" />
<v-select v-else-if="opt.type === 'select'" :label="$t('preferences.' + opt.id)" :value="$store.getters.getPreference(opt.id, opt.default)" @input="setValue(opt.id, $event)" :items="opt.options" />
<v-simple-checkbox v-if="opt.type === 'bool'" :value="$store.getters['prefs/getPreferenceBoolean'](opt.id, opt.default)" @input="setValue(opt.id, $event)" />
<v-select v-else-if="opt.type === 'select'" :label="$t('preferences.' + opt.id)" :value="$store.getters['prefs/getPreference'](opt.id, opt.default)" @input="setValue(opt.id, $event)" :items="opt.options" />
<p v-if="opt.type === 'bool'">{{ $t('preferences.' + opt.id) }}</p><br />
</div>
<h5 class="text-h5">{{ $t('actions.instances_list') }}</h5>
@@ -139,7 +139,7 @@ export default {
},
methods: {
setValue (k, v) {
this.$store.commit('setPrefs', {
this.$store.commit('prefs/setPrefs', {
id: k,
value: v
})
+1 -1
View File
@@ -54,7 +54,7 @@ export default {
methods: {
async refreshSuggestions () {
this.requestInProgress = true
this.searchSuggestions = await this.$store.dispatch('fetchJson', {
this.searchSuggestions = await this.$store.dispatch('auth/makeRequest', {
path: '/suggestions',
params: {
query: this.searchText
+2 -2
View File
@@ -98,7 +98,7 @@ export default {
},
async fetchResults () {
return this.$store.dispatch('fetchJson', {
return this.$store.dispatch('auth/makeRequest', {
path: 'search',
params: {
q: this.$route.query.search_query,
@@ -127,7 +127,7 @@ export default {
},
fetchMoreResults () {
this.$store.dispatch('fetchJson', {
this.$store.dispatch('auth/makeRequest', {
path: '/nextpage/search',
params: {
nextpage: this.results.nextpage,
+3 -3
View File
@@ -31,16 +31,16 @@ export default {
},
mounted () {
const region = this.$store.getters.getPreference('region', 'US')
const region = this.$store.getters['prefs/getPreference']('region', 'US')
this.fetchTrending(region).then(videos => (this.videos = videos))
},
methods: {
async fetchTrending (region) {
return this.$store.dispatch('fetchJson', {
return this.$store.dispatch('auth/makeRequest', {
path: '/trending',
params: {
region: region || 'US'
region: region
}
})
}
+12 -24
View File
@@ -52,7 +52,7 @@
</div>
<div class="ml-4">
<v-btn
v-if="$store.state.isAuthenticated"
v-if="$store.state['auth/isAuthenticated']"
@click="subscribeHandler"
color="primary"
>
@@ -170,7 +170,7 @@ export default {
params: {
category:
'["' +
this.$store.getters.getPreference('selectedSkip', 'sponsor,interaction,selfpromo,music_offtopic').replaceAll(
this.$store.getters['prefs/getPreference']('selectedSkip', 'sponsor,interaction,selfpromo,music_offtopic').replaceAll(
',',
'","'
) +
@@ -179,7 +179,7 @@ export default {
})
},
fetchComments () {
return this.$store.dispatch('fetchJson', {
return this.$store.dispatch('auth/makeRequest', {
path: '/comments/' + this.getVideoId()
})
},
@@ -191,7 +191,7 @@ export default {
},
fetchMoreComments () {
this.$store.dispatch('fetchJson', {
this.$store.dispatch('auth/makeRequest', {
path: '/nextpage/comments/' + this.getVideoId(),
params: {
nextpage: this.comments.nextpage
@@ -203,7 +203,7 @@ export default {
},
onAutoplayChg (ev) {
this.$store.commit('setPrefs', {
this.$store.commit('prefs/setPrefs', {
id: 'autoplay',
value: ev
})
@@ -232,7 +232,7 @@ export default {
})
},
async getSponsors () {
if (this.$store.getters.getPreference('sponsorblock', true)) { this.fetchSponsors().then(data => (this.sponsors = data)) }
if (this.$store.getters['prefs/getPreference']('sponsorblock', true)) { this.fetchSponsors().then(data => (this.sponsors = data)) }
},
async getComments () {
this.fetchComments().then(data => (this.comments = data))
@@ -240,33 +240,21 @@ export default {
async fetchSubscribedStatus () {
if (!this.channelId) return
this.$store.dispatch('fetchJson', {
this.$store.dispatch('auth/makeRequest', {
path: '/subscribed',
params: {
channelId: this.channelId
},
options: {
headers: {
Authorization: this.$store.getters.getAuthToken
}
}
}).then(json => {
this.subscribed = json.subscribed
})
},
subscribeHandler () {
this.$store.dispatch('fetchJson', {
this.$store.dispatch('auth/makeRequest', {
method: 'POST',
path: (this.subscribed ? '/unsubscribe' : '/subscribe'),
params: null,
options: {
method: 'POST',
body: JSON.stringify({
channelId: this.channelId
}),
headers: {
Authorization: this.$store.getters.getAuthToken,
'Content-Type': 'application/json'
}
data: {
channelId: this.channelId
}
})
this.subscribed = !this.subscribed
@@ -278,7 +266,7 @@ export default {
},
computed: {
isAutoplayEnabled () {
return this.$store.getters.getPreferenceBoolean('autoplay')
return this.$store.getters['prefs/getPreferenceBoolean']('autoplay')
}
},
components: {
+6 -1
View File
@@ -34,7 +34,12 @@ const AuthenticationStore = {
baseURL: rootGetters['prefs/apiUrl'],
method,
url: path,
params
params,
headers: state.isAuthenticated
? {
Authorization: state.authToken
}
: undefined
})
return resp
+1 -1
View File
@@ -14,7 +14,7 @@ const store = new Vuex.Store({
}
})
store.watch(state => state.prefs.prefs, (nextPrefs) => {
store.watch(state => state['prefs/prefs'], (nextPrefs) => {
if (isPlainObject(nextPrefs)) {
window.localStorage.setItem('PREFERENCES', JSON.stringify(nextPrefs))
}