Navigation Menu

Skip to content

Commit

Permalink
Perf: Remove redundant dialog code, use Modal Mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
m4ximuel authored and WDaan committed Apr 20, 2021
1 parent 04971dc commit 33cf62f
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 128 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -25,7 +25,6 @@
"uuid": "^8.3.2",
"vue": "^2.6.12",
"vue-apexcharts": "^1.6.0",
"vue-context": "^6.0.0",

This comment has been minimized.

Copy link
@jef

jef Apr 20, 2021

Contributor

No longer builds without vue-context.

This comment has been minimized.

Copy link
@m4ximuel

m4ximuel Apr 20, 2021

Author Contributor

@jef Well caught, I forgot to remove it out before. no more need. I should have created a new PR, but it went into the my merge process.

This comment has been minimized.

Copy link
@WDaan

WDaan Apr 20, 2021

Collaborator

I've removed the import

This comment has been minimized.

Copy link
@jef

jef Apr 20, 2021

Contributor

☺️

"vue-router": "^3.5.1",
"vue-toastification": "^1.7.11",
"vuedraggable": "^2.24.3",
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/AddModal.vue
Expand Up @@ -204,7 +204,6 @@ export default {
props: ['initialMagnet'],
data() {
return {
hndlDialog: true,
showWrapDrag: false,
files: [],
category: null,
Expand Down Expand Up @@ -247,16 +246,6 @@ export default {
},
availableCategories() {
return this.getCategories()
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
created() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/ChangeLocationModal.vue
Expand Up @@ -64,7 +64,6 @@ export default {
},
data() {
return {
hndlDialog: true,
newPath: '',
mdiFile, mdiFolder, mdiClose
}
Expand All @@ -79,16 +78,6 @@ export default {
},
isPhone() {
return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
created() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/ConfirmDeleteModal.vue
Expand Up @@ -63,7 +63,6 @@ export default {
mixins: [Modal],
data() {
return {
hndlDialog: true,
withFiles: false
}
},
Expand All @@ -72,16 +71,6 @@ export default {
...mapGetters(['getTorrents']),
torrents() {
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() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/RenameModal.vue
Expand Up @@ -61,7 +61,6 @@ export default {
},
data() {
return {
hndlDialog: true,
name: '',
mdiFile
}
Expand All @@ -73,16 +72,6 @@ export default {
},
isPhone() {
return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
created() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/SearchModal/SearchModal.vue
Expand Up @@ -97,7 +97,6 @@ export default {
mixins: [Modal, FullScreenModal, General],
data() {
return {
hndlDialog: true,
search: {
id: null,
status: null,
Expand Down Expand Up @@ -129,16 +128,6 @@ export default {
},
enabledSearchPlugins() {
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() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/SettingsModal/SettingsModal.vue
Expand Up @@ -95,7 +95,6 @@ export default {
mixins: [Modal, FullScreenModal, SettingsTab],
data() {
return {
hndlDialog: true,
tab: null,
items: [],
peers: [],
Expand All @@ -105,16 +104,6 @@ export default {
computed: {
isPhone() {
return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
created() {
Expand Down
13 changes: 1 addition & 12 deletions src/components/Modals/SortModal.vue
Expand Up @@ -50,7 +50,6 @@ export default {
mixins: [Modal],
data() {
return {
hndlDialog: true,
sortProperty: { value: 'added_on', name: 'Added On' },
reverse: true,
options: [
Expand All @@ -75,17 +74,7 @@ export default {
}
},
computed: {
...mapState(['sort_options']),
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
...mapState(['sort_options'])
},
methods: {
close() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/SpeedLimitModal.vue
Expand Up @@ -63,7 +63,6 @@ export default {
},
data() {
return {
hndlDialog: true,
limit: '',
mdiSpeedometer, mdiClose
}
Expand All @@ -75,16 +74,6 @@ export default {
},
isPhone() {
return this.$vuetify.breakpoint.xsOnly
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
created() {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/TagsAndCategories/CreateCategoryDialog.vue
Expand Up @@ -68,7 +68,6 @@ export default {
initialCategory: Object
},
data: () => ({
hndlDialog: true,
nameRules: [
v => !!v || 'Category name is required',
v =>
Expand All @@ -87,16 +86,6 @@ export default {
hasInitialCategory() {
return !!(this.initialCategory &&
this.initialCategory.name)
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
created() {
Expand Down
13 changes: 0 additions & 13 deletions src/components/Modals/TagsAndCategories/CreateTagDialog.vue
Expand Up @@ -45,25 +45,12 @@ export default {
name: 'CreateTagDialog',
mixins: [Modal],
data: () => ({
hndlDialog: true,
tagname: '',
rules: [
v => !!v || 'Tag is required',
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: {
create() {
qbit.createTag(this.tagname)
Expand Down
11 changes: 0 additions & 11 deletions src/components/Modals/TorrentDetailModal/TorrentDetailModal.vue
Expand Up @@ -93,7 +93,6 @@ export default {
},
data() {
return {
hndlDialog: true,
hndlFullscreen: false,
tab: null,
items: [{ tab: 'Info' }, { tab: 'Content' }],
Expand All @@ -116,16 +115,6 @@ export default {
return true
return false
},
dialog: {
get: function () {
return this.hndlDialog
},
set: function (e) {
this.hndlDialog = e
if (e === false)
this.deleteModal()
}
}
},
methods: {
Expand Down
25 changes: 22 additions & 3 deletions src/mixins/Modal.js
@@ -1,15 +1,34 @@
import { mapGetters } from 'vuex'
export default {
props: ['guid'],
data() {
return {
hndlDialog: true
}
},
computed: {
...mapGetters(['getModalState'])
...mapGetters(['getModalState']),
dialog: {
get() {
return this.hndlDialog
},
set(val) {
this.hndlDialog = val
if (!val)
this.deleteModal()
}
}
},

methods: {
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() {
this.deleteModal()
}
}
}

0 comments on commit 33cf62f

Please sign in to comment.