diff --git a/src/App.vue b/src/App.vue index 9227a2f..6ce4c87 100644 --- a/src/App.vue +++ b/src/App.vue @@ -134,6 +134,7 @@ export default { }, created () { this.$store.dispatch('prefs/loadState') + this.$store.dispatch('auth/initializeAuth') } } diff --git a/src/main.js b/src/main.js index cd89fe3..895a194 100644 --- a/src/main.js +++ b/src/main.js @@ -1,7 +1,6 @@ import Vue from 'vue' import App from './App.vue' -import '@fontsource/hind-siliguri/latin.css' import '@/styles/main.scss' import { i18n } from '@/plugins/i18n' diff --git a/src/plugins/i18n.js b/src/plugins/i18n.js index bb0384e..0bef06c 100644 --- a/src/plugins/i18n.js +++ b/src/plugins/i18n.js @@ -65,10 +65,12 @@ export async function changeLocale (lang) { } function initializeLocalLocale () { - const lang = window.localStorage.getItem('LOCALE') - if (lang != null) { - changeLocale(lang).catch(e => console.error(e)) + let lang = window.localStorage.getItem('LOCALE') + if (lang == null) { + // Default language + lang = 'en' } + changeLocale(lang).catch(e => console.error(e)) } initializeLocalLocale() diff --git a/src/routes/WatchVideo.vue b/src/routes/WatchVideo.vue index 8518a61..27044c2 100644 --- a/src/routes/WatchVideo.vue +++ b/src/routes/WatchVideo.vue @@ -238,7 +238,7 @@ export default { this.fetchComments().then(data => (this.comments = data)) }, async fetchSubscribedStatus () { - if (!this.channelId) return + if (!this.channelId || !this.$store.state['auth/isAuthenticated']) return this.$store.dispatch('auth/makeRequest', { path: '/subscribed', diff --git a/src/store/authentication-store.js b/src/store/authentication-store.js index 118bff1..33c6415 100644 --- a/src/store/authentication-store.js +++ b/src/store/authentication-store.js @@ -5,11 +5,25 @@ const AuthenticationStore = { namespaced: true, state: () => ({ - isAuthenticated: true, + isAuthenticated: false, authToken: null }), + mutations: { + replaceAuth (state, data) { + state.isAuthenticated = data.isAuthenticated ?? state.isAuthenticated + state.authToken = data.authToken ?? state.authToken + } + }, + actions: { + initializeAuth ({ commit }) { + const data = window.localStorage.getItem('AUTH') + if (data != null) { + commit('replaceAuth', data) + } + }, + async makeRequest ({ commit, state, diff --git a/src/styles/main.scss b/src/styles/main.scss index eb90fc2..dc5fd48 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -12,4 +12,10 @@ } } -@include addFonts('Hind Siliguri'); +.latin { + @include addFonts('Helvetica Neue'); +} + +.bengali { + @include addFonts('Hind Silliguri') +}