Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(modules): adds clean-up after before module deletion #481

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/application/worker/store/modules/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,36 @@ const actions = {
}

return;
},

async removeActiveModule({ commit }, { moduleId, writeToSwap }) {
const writeTo = writeToSwap ? swap : state;

const module = writeTo.active[moduleId];
const { meta } = module;

if (!module) {
throw new Error(`No module with id "${moduleId}" found`);
}

const metaInputIds = [
meta.alphaInputId,
meta.compositeOperationInputId,
meta.enabledInputId
];
const moduleProperties = Object.values(module.$props).map(prop => prop.id);
const inputIds = [...moduleProperties, ...metaInputIds];

for (let i = 0, len = inputIds.length; i < len; i++) {
const inputId = inputIds[i];

await store.dispatch("inputs/removeInputLink", {
inputId,
writeToSwap
});
}

commit("REMOVE_ACTIVE_MODULE", { moduleId, writeToSwap });
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/components/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ export default {
window.dispatchEvent(new Event("resize"));
},

beforeDestroy() {
this.$modV.store.commit("modules/REMOVE_ACTIVE_MODULE", {
async beforeDestroy() {
await this.$modV.store.dispatch("modules/removeActiveModule", {
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
2 changes: 1 addition & 1 deletion src/components/Group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export default {
groupId
});

this.$modV.store.commit("modules/REMOVE_ACTIVE_MODULE", {
this.$modV.store.dispatch("modules/removeActiveModule", {
moduleId
});
},
Expand Down