chore: reduced a bit bundle size by using lighter flags; workflow: improved code modularity; chore: removed unused functions and globals; chore: removed .jsbeautify file

This commit is contained in:
Roberto Tonino
2020-09-26 17:53:25 +02:00
parent 4c81cb0cb9
commit 468142004a
14 changed files with 105 additions and 219 deletions

View File

@@ -69,7 +69,7 @@
</table>
<footer>
<button class="back-button" @click="backTab">{{ $t('globals.back') }}</button>
<button class="back-button" @click="$router.back()">{{ $t('globals.back') }}</button>
</footer>
</div>
</template>
@@ -78,7 +78,7 @@
import { isEmpty, orderBy } from 'lodash-es'
import { socket } from '@/utils/socket'
import Downloads from '@/utils/downloads'
import { showView, backTab } from '@js/tabs'
import { showView } from '@js/tabs'
import EventBus from '@/utils/EventBus'
export default {
@@ -97,7 +97,6 @@ export default {
}
},
methods: {
backTab,
albumView: showView.bind(null, 'album'),
reset() {
this.title = 'Loading...'
@@ -128,9 +127,7 @@ export default {
getCurrentTab() {
return this.currentTab
},
updateSelected() {
window.currentStack.selected = this.currentTab
},
updateSelected() {},
checkNewRelease(date) {
let g1 = new Date()
let g2 = new Date(date)

View File

@@ -181,7 +181,7 @@ export default {
this.currentTab = newTab
},
checkIfShowNewResults(term, mainSelected) {
let needToPerformNewSearch = term !== this.results.query || mainSelected == 'search_tab'
let needToPerformNewSearch = term !== this.results.query /* || mainSelected == 'search_tab' */
if (needToPerformNewSearch) {
this.showNewResults(term)
@@ -192,7 +192,7 @@ export default {
if (needToUpdateSearch) {
let resetObj = { data: [], next: 0, total: 0, loaded: false }
this.results[this.currentTab.searchType+"Tab"] = { ...resetObj }
this.results[this.currentTab.searchType + 'Tab'] = { ...resetObj }
this.search(this.currentTab.searchType)
}
},

View File

@@ -21,9 +21,8 @@
<script>
import { isValidURL } from '@/utils/utils'
import Downloads from '@/utils/downloads'
import EventBus from '@/utils/EventBus.js'
import { sendAddToQueue } from '@/utils/downloads'
import EventBus from '@/utils/EventBus'
import { socket } from '@/utils/socket'
export default {
@@ -32,12 +31,27 @@ export default {
lastTextSearch: ''
}
},
mounted() {
document.addEventListener('keyup', keyEvent => {
created() {
const focusSearchBar = keyEvent => {
if (keyEvent.keyCode === 70 && keyEvent.ctrlKey) {
keyEvent.preventDefault()
this.$refs.searchbar.focus()
}
}
const deleteSearchBarContent = keyEvent => {
if (!(keyEvent.key == 'Backspace' && keyEvent.ctrlKey && keyEvent.shiftKey)) return
this.$refs.searchbar.value = ''
this.$refs.searchbar.focus()
}
document.addEventListener('keydown', focusSearchBar)
document.addEventListener('keyup', deleteSearchBarContent)
this.$on('hook:destroyed', () => {
document.removeEventListener('keydown', focusSearchBar)
document.removeEventListener('keyup', deleteSearchBarContent)
})
},
methods: {
@@ -71,11 +85,11 @@ export default {
socket.emit('analyzeLink', term)
} else {
// ? Open downloads tab ?
Downloads.sendAddToQueue(term)
sendAddToQueue(term)
}
}
} else {
if (isShowingSearch && sameAsLastSearch){
if (isShowingSearch && sameAsLastSearch) {
this.$root.$emit('mainSearch:updateResults', term)
return
}
@@ -91,7 +105,7 @@ export default {
this.lastTextSearch = term
}
this.$root.$emit('mainSearch:showNewResults', term, window.main_selected)
this.$root.$emit('mainSearch:showNewResults', term /* , window.main_selected */)
}
}
}

View File

@@ -644,8 +644,8 @@
}
svg {
width: 40px;
height: 40px;
width: 40px !important;
height: 40px !important;
filter: brightness(0.5);
}
}
@@ -654,19 +654,18 @@
<script>
import { mapActions, mapGetters } from 'vuex'
import { getSettingsData } from '@/data/settings'
import { toast } from '@/utils/toasts'
import { socket } from '@/utils/socket'
import EventBus from '@/utils/EventBus'
import flags from '@/utils/flags'
import { getSettingsData } from '@/data/settings'
import { flags } from '@/utils/flags'
export default {
data() {
return {
flags,
currentLocale: 'en',
locales: [],
currentLocale: this.$i18n.locale,
locales: this.$i18n.availableLocales,
settings: {
tags: {}
},
@@ -708,22 +707,11 @@ export default {
}
},
async mounted() {
this.locales = this.$i18n.availableLocales
const { settingsData, defaultSettingsData, spotifyCredentials } = await getSettingsData()
this.defaultSettings = defaultSettingsData
this.initSettings(settingsData, spotifyCredentials)
// this.revertSettings()
// this.revertCredentials()
let storedLocale = localStorage.getItem('locale')
if (storedLocale) {
this.currentLocale = storedLocale
}
let storedAccountNum = localStorage.getItem('accountNum')
if (storedAccountNum) {

View File

@@ -137,7 +137,7 @@
<button class="with_icon" @click.stop="addToQueue" :data-link="selectedLinks()">
{{ $t('tracklist.downloadSelection') }}<i class="material-icons">file_download</i>
</button>
<button class="back-button" @click="backTab">{{ $t('globals.back') }}</button>
<button class="back-button" @click="$router.back()">{{ $t('globals.back') }}</button>
</footer>
</div>
</template>
@@ -145,7 +145,7 @@
<script>
import { isEmpty } from 'lodash-es'
import { socket } from '@/utils/socket'
import { showView, backTab } from '@js/tabs.js'
import { showView } from '@js/tabs.js'
import Downloads from '@/utils/downloads'
import Utils from '@/utils/utils'
import EventBus from '@/utils/EventBus'
@@ -164,7 +164,6 @@ export default {
body: []
}),
methods: {
backTab,
artistView: showView.bind(null, 'artist'),
albumView: showView.bind(null, 'album'),
playPausePreview(e) {