Perf: Remove redundant dialog code, use Modal Mixin

This commit is contained in:
m4ximuel 2021-04-20 00:17:02 +09:00 committed by Daan
parent 04971dcf87
commit 33cf62ff9b
13 changed files with 24 additions and 129 deletions

View file

@ -25,7 +25,6 @@
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vue": "^2.6.12", "vue": "^2.6.12",
"vue-apexcharts": "^1.6.0", "vue-apexcharts": "^1.6.0",
"vue-context": "^6.0.0",
"vue-router": "^3.5.1", "vue-router": "^3.5.1",
"vue-toastification": "^1.7.11", "vue-toastification": "^1.7.11",
"vuedraggable": "^2.24.3", "vuedraggable": "^2.24.3",

View file

@ -204,7 +204,6 @@ export default {
props: ['initialMagnet'], props: ['initialMagnet'],
data() { data() {
return { return {
hndlDialog: true,
showWrapDrag: false, showWrapDrag: false,
files: [], files: [],
category: null, category: null,
@ -247,16 +246,6 @@ export default {
}, },
availableCategories() { availableCategories() {
return this.getCategories() return this.getCategories()
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -64,7 +64,6 @@ export default {
}, },
data() { data() {
return { return {
hndlDialog: true,
newPath: '', newPath: '',
mdiFile, mdiFolder, mdiClose mdiFile, mdiFolder, mdiClose
} }
@ -79,16 +78,6 @@ export default {
}, },
isPhone() { isPhone() {
return this.$vuetify.breakpoint.xsOnly return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -63,7 +63,6 @@ export default {
mixins: [Modal], mixins: [Modal],
data() { data() {
return { return {
hndlDialog: true,
withFiles: false withFiles: false
} }
}, },
@ -72,16 +71,6 @@ export default {
...mapGetters(['getTorrents']), ...mapGetters(['getTorrents']),
torrents() { torrents() {
return this.getTorrents().filter(t => this.selected_torrents.includes(t.hash)) return this.getTorrents().filter(t => this.selected_torrents.includes(t.hash))
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
beforeDestroy() { beforeDestroy() {

View file

@ -61,7 +61,6 @@ export default {
}, },
data() { data() {
return { return {
hndlDialog: true,
name: '', name: '',
mdiFile mdiFile
} }
@ -73,16 +72,6 @@ export default {
}, },
isPhone() { isPhone() {
return this.$vuetify.breakpoint.xsOnly return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -97,7 +97,6 @@ export default {
mixins: [Modal, FullScreenModal, General], mixins: [Modal, FullScreenModal, General],
data() { data() {
return { return {
hndlDialog: true,
search: { search: {
id: null, id: null,
status: null, status: null,
@ -129,16 +128,6 @@ export default {
}, },
enabledSearchPlugins() { enabledSearchPlugins() {
return this.getSearchPlugins().filter(p => p.enabled) return this.getSearchPlugins().filter(p => p.enabled)
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -95,7 +95,6 @@ export default {
mixins: [Modal, FullScreenModal, SettingsTab], mixins: [Modal, FullScreenModal, SettingsTab],
data() { data() {
return { return {
hndlDialog: true,
tab: null, tab: null,
items: [], items: [],
peers: [], peers: [],
@ -105,16 +104,6 @@ export default {
computed: { computed: {
isPhone() { isPhone() {
return this.$vuetify.breakpoint.xsOnly return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -50,7 +50,6 @@ export default {
mixins: [Modal], mixins: [Modal],
data() { data() {
return { return {
hndlDialog: true,
sortProperty: { value: 'added_on', name: 'Added On' }, sortProperty: { value: 'added_on', name: 'Added On' },
reverse: true, reverse: true,
options: [ options: [
@ -75,17 +74,7 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['sort_options']), ...mapState(['sort_options'])
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
}, },
methods: { methods: {
close() { close() {

View file

@ -63,7 +63,6 @@ export default {
}, },
data() { data() {
return { return {
hndlDialog: true,
limit: '', limit: '',
mdiSpeedometer, mdiClose mdiSpeedometer, mdiClose
} }
@ -75,16 +74,6 @@ export default {
}, },
isPhone() { isPhone() {
return this.$vuetify.breakpoint.xsOnly return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -68,7 +68,6 @@ export default {
initialCategory: Object initialCategory: Object
}, },
data: () => ({ data: () => ({
hndlDialog: true,
nameRules: [ nameRules: [
v => !!v || 'Category name is required', v => !!v || 'Category name is required',
v => v =>
@ -87,16 +86,6 @@ export default {
hasInitialCategory() { hasInitialCategory() {
return !!(this.initialCategory && return !!(this.initialCategory &&
this.initialCategory.name) this.initialCategory.name)
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
created() { created() {

View file

@ -45,25 +45,12 @@ export default {
name: 'CreateTagDialog', name: 'CreateTagDialog',
mixins: [Modal], mixins: [Modal],
data: () => ({ data: () => ({
hndlDialog: true,
tagname: '', tagname: '',
rules: [ rules: [
v => !!v || 'Tag is required', v => !!v || 'Tag is required',
v => v.length <= 10 || 'Tag must be less than 10 characters' v => v.length <= 10 || 'Tag must be less than 10 characters'
] ]
}), }),
computed: {
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
methods: { methods: {
create() { create() {
qbit.createTag(this.tagname) qbit.createTag(this.tagname)

View file

@ -93,7 +93,6 @@ export default {
}, },
data() { data() {
return { return {
hndlDialog: true,
hndlFullscreen: false, hndlFullscreen: false,
tab: null, tab: null,
items: [{ tab: 'Info' }, { tab: 'Content' }], items: [{ tab: 'Info' }, { tab: 'Content' }],
@ -116,16 +115,6 @@ export default {
return true return true
return false return false
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
} }
}, },
methods: { methods: {

View file

@ -1,15 +1,34 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
props: ['guid'], props: ['guid'],
computed: { data() {
...mapGetters(['getModalState']) return {
hndlDialog: true
}
}, },
computed: {
...mapGetters(['getModalState']),
dialog: {
get() {
return this.hndlDialog
},
set(val) {
this.hndlDialog = val
if (!val)
this.deleteModal()
}
}
},
methods: { methods: {
deleteModal() { deleteModal() {
setTimeout(() => this.$store.commit('DELETE_MODAL', this.guid), 100) //this.hndlDialog = false
setTimeout(function () {
this.$store.commit('DELETE_MODAL', this.guid)
}.bind(this), 300)
} }
}, },
beforeDestroy() { beforeDestroy() {
this.deleteModal() this.deleteModal()
} }
} }