Skip to content

Commit

Permalink
Persist task view state.
Browse files Browse the repository at this point in the history
This does not persist actual task process. This will have to be handled
very, very differently, and I'm not sure how yet.

Closes: MediaWikiAGE#53
  • Loading branch information
AttemptToCallNil committed Jun 14, 2021
1 parent a018ec4 commit 8b4f8aa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const store = createStore({
processedBotPassId: null,

loginFormData: null,
taskViewData: null,
},
mutations: {
saveProcessedWiki(state, processedWikiData) {
Expand All @@ -23,6 +24,9 @@ const store = createStore({
},
saveLoginFormData(state, loginFormData) {
state.loginFormData = loginFormData;
},
saveTaskViewData(state, taskViewData) {
state.taskViewData = taskViewData;
}
},
getters: {
Expand All @@ -36,6 +40,9 @@ const store = createStore({
},
getLoginFormData(state) {
return state.loginFormData;
},
getTaskViewData(state) {
return state.taskViewData;
}
}
});
Expand Down
29 changes: 28 additions & 1 deletion src/views/Tasks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,27 @@ export default {
targetElement.focus();
})();
},
commitChoices() {
const taskData = {
generatorModalChosenGenerator: this.generatorModalChosenGenerator,
addTaskModalChosenTask: this.addTaskModalChosenTask,
expandedTasks: this.expandedTasks,
tasks: this.tasks,
taskPages: this.taskPages
};
this.$store.commit("saveTaskViewData", taskData);
},
restoreFromState() {
const taskData = this.$store.getters.getTaskViewData;
if (taskData === null) {
return;
}
for (const key of Object.keys(taskData)) {
this[key] = taskData[key];
}
},
getGeneratorOptionInputId(optionId) {
return `generator-option-${this.generatorModalChosenGenerator}-${optionId}`;
},
Expand Down Expand Up @@ -346,7 +367,13 @@ export default {
this.addTaskModalOpen = false;
document.removeEventListener("keydown", this.onAddTaskModalKeydown);
}
}
},
created: function() {
this.restoreFromState();
},
beforeUnmount: function() {
this.commitChoices();
},
};
</script>
<style>
Expand Down

0 comments on commit 8b4f8aa

Please sign in to comment.