Fix some development code not getting optimised out (#2605)

This commit is contained in:
absidue 2022-09-26 22:15:13 +02:00 committed by GitHub
parent 8e72e7fe5f
commit fa8d423bc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 12 additions and 28 deletions

View File

@ -18,15 +18,16 @@
<body>
<div id="app"></div>
<% if (process.env.NODE_ENV !== 'development') { %>
<!-- Set `__static` path to static files in production -->
<script>
try {
if ('<%= process.env.NODE_ENV %>' !== 'development')
window.__static = require('path')
.join(__dirname, '/static')
.replace(/\\/g, '\\\\')
} catch {}
</script>
<% } %>
<script>
// This is the service worker with the Advanced caching

View File

@ -50,9 +50,6 @@ export default Vue.extend({
}
},
computed: {
isDev: function () {
return process.env.NODE_ENV === 'development'
},
isOpen: function () {
return this.$store.getters.getIsSideNavOpen
},
@ -148,7 +145,7 @@ export default Vue.extend({
this.grabUserSettings().then(async () => {
this.checkThemeSettings()
await this.fetchInvidiousInstances({ isDev: this.isDev })
await this.fetchInvidiousInstances()
if (this.defaultInvidiousInstance === '') {
await this.setRandomCurrentInvidiousInstance()
}
@ -257,7 +254,6 @@ export default Vue.extend({
checkExternalPlayer: async function () {
const payload = {
isDev: this.isDev,
externalPlayer: this.externalPlayer
}
this.getExternalPlayerCmdArgumentsData(payload)

View File

@ -21,10 +21,6 @@ export default Vue.extend({
return {}
},
computed: {
isDev: function () {
return process.env.NODE_ENV === 'development'
},
externalPlayerNames: function () {
const fallbackNames = this.$store.getters.getExternalPlayerNames
const nameTranslationKeys = this.$store.getters.getExternalPlayerNameTranslationKeys

View File

@ -61,9 +61,6 @@ export default Vue.extend({
}
},
computed: {
isDev: function () {
return process.env.NODE_ENV === 'development'
},
currentInvidiousInstance: function () {
return this.$store.getters.getCurrentInvidiousInstance
},

View File

@ -42,10 +42,6 @@ export default Vue.extend({
}
},
computed: {
isDev: function () {
return process.env.NODE_ENV === 'development'
},
backendPreference: function () {
return this.$store.getters.getBackendPreference
},

View File

@ -21,7 +21,7 @@ const getters = {
}
const actions = {
async fetchInvidiousInstances({ commit }, payload) {
async fetchInvidiousInstances({ commit }) {
const requestUrl = 'https://api.invidious.io/instances.json'
let instances = []
@ -43,7 +43,7 @@ const actions = {
// And fallback to hardcoded entry(s) if static file absent
const fileName = 'invidious-instances.json'
/* eslint-disable-next-line */
const fileLocation = payload.isDev ? './static/' : `${__dirname}/static/`
const fileLocation = process.env.NODE_ENV === 'development' ? './static/' : `${__dirname}/static/`
if (fs.existsSync(`${fileLocation}${fileName}`)) {
console.warn('reading static file for invidious instances')
const fileData = fs.readFileSync(`${fileLocation}${fileName}`)

View File

@ -323,7 +323,6 @@ const stateWithSideEffects = {
i18n.locale = targetLocale
dispatch('getRegionData', {
isDev: process.env.NODE_ENV === 'development',
locale: targetLocale
})
}

View File

@ -547,7 +547,7 @@ const actions = {
getRegionData ({ commit }, payload) {
let fileData
/* eslint-disable-next-line */
const fileLocation = payload.isDev ? './static/geolocations/' : `${__dirname}/static/geolocations/`
const fileLocation = process.env.NODE_ENV === 'development' ? './static/geolocations/' : `${__dirname}/static/geolocations/`
if (fs.existsSync(`${fileLocation}${payload.locale}`)) {
fileData = fs.readFileSync(`${fileLocation}${payload.locale}/countries.json`)
} else {
@ -1028,7 +1028,7 @@ const actions = {
const fileName = 'external-player-map.json'
let fileData
/* eslint-disable-next-line */
const fileLocation = payload.isDev ? './static/' : `${__dirname}/static/`
const fileLocation = process.env.NODE_ENV === 'development' ? './static/' : `${__dirname}/static/`
if (fs.existsSync(`${fileLocation}${fileName}`)) {
fileData = fs.readFileSync(`${fileLocation}${fileName}`)

View File

@ -16,6 +16,8 @@ import WatchVideoRecommendations from '../../components/watch-video-recommendati
import FtAgeRestricted from '../../components/ft-age-restricted/ft-age-restricted.vue'
import i18n from '../../i18n/index'
const isDev = process.env.NODE_ENV === 'development'
export default Vue.extend({
name: 'Watch',
components: {
@ -86,9 +88,6 @@ export default Vue.extend({
}
},
computed: {
isDev: function () {
return process.env.NODE_ENV === 'development'
},
historyCache: function () {
return this.$store.getters.getHistoryCache
},
@ -1127,7 +1126,7 @@ export default Vue.extend({
if (this.removeVideoMetaFiles) {
const userData = await this.getUserDataPath()
if (this.isDev) {
if (isDev) {
const dashFileLocation = `static/dashFiles/${videoId}.xml`
const vttFileLocation = `static/storyboards/${videoId}.vtt`
// only delete the file it actually exists
@ -1174,7 +1173,7 @@ export default Vue.extend({
const userData = await this.getUserDataPath()
let fileLocation
let uriSchema
if (this.isDev) {
if (isDev) {
fileLocation = `static/dashFiles/${this.videoId}.xml`
uriSchema = `dashFiles/${this.videoId}.xml`
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually
@ -1255,7 +1254,7 @@ export default Vue.extend({
// Dev mode doesn't have access to the file:// schema, so we access
// storyboards differently when run in dev
if (this.isDev) {
if (isDev) {
fileLocation = `static/storyboards/${this.videoId}.vtt`
uriSchema = `storyboards/${this.videoId}.vtt`
// if the location does not exist, writeFileSync will not create the directory, so we have to do that manually