Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Commit

Permalink
fix(lifecycle): fixes lifecycle bug in modV & galleryitem compont (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA authored May 17, 2020
1 parent 898596a commit e8cf0ab
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ export default {
},
async mounted() {
await this.$modV.setup();
if (!this.$modV.ready) {
await this.$modV.setup();
}
// this.$modV.$worker.addEventListener("message", e => {
// if (e.data.type === "outputs/SET_MAIN_OUTPUT") {
// this.resize();
Expand Down
9 changes: 9 additions & 0 deletions src/application/worker/store/modules/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ const sharedPropertyRestrictions = {
const actions = {
async createGroup({ commit }, args = {}) {
const name = args.name || "New Group";
const writeTo = args.writeToSwap ? swap : state;

const existingGroupIndex = writeTo.groups.findIndex(
group => group.name === args.name
);

if (existingGroupIndex > -1) {
return writeTo.groups[existingGroupIndex];
}

const group = {
...args,
Expand Down
29 changes: 27 additions & 2 deletions src/application/worker/store/modules/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const actions = {
const { renderers } = rootState;

if (!module) {
console.error("No module to register");
console.error("No module to register.");
return;
}

Expand All @@ -94,12 +94,21 @@ const actions = {

const { name, type } = module.meta;

const existingModuleWithDuplicateName = Object.values(
state.registered
).findIndex(registeredModule => registeredModule.meta.name === name);

if (existingModuleWithDuplicateName > -1) {
console.error(`Module registered with name "${name}" already exists.`);
return;
}

if (renderers[type].setupModule) {
try {
module = await renderers[type].setupModule(module);
} catch (e) {
console.error(
`Error in ${type} renderer setup whilst registering ${name}. This module was ommited from registration.`
`Error in ${type} renderer setup whilst registering "${name}". This module was ommited from registration.`
);

return false;
Expand All @@ -125,6 +134,22 @@ const actions = {
...existingModule
};

if (moduleMeta.isGallery) {
const existingModuleWithDuplicateNameInGallery = Object.values(
writeTo.active
).find(
activeModule =>
activeModule.meta.isGallery && activeModule.meta.name === moduleName
);

if (existingModuleWithDuplicateNameInGallery) {
console.warn(
`Module active in gallery with name "${moduleName}" already exists.`
);
return existingModuleWithDuplicateNameInGallery;
}
}

if (!existingModule) {
module.$id = uuidv4();
module.$moduleName = moduleName;
Expand Down
4 changes: 3 additions & 1 deletion src/components/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export default {
},
beforeDestroy() {
this.$modV.store.commit("modules/REMOVE_ACTIVE_MODULE", this.id);
this.$modV.store.commit("modules/REMOVE_ACTIVE_MODULE", {
moduleId: this.id
});
this.$modV.store.commit("outputs/REMOVE_AUXILLARY", this.outputId);
this.$modV.store.commit("groups/REMOVE_MODULE_FROM_GROUP", {
groupId: this.groupId,
Expand Down

0 comments on commit e8cf0ab

Please sign in to comment.