mirror of
https://github.com/YouHaveTrouble/GuildMaster.git
synced 2026-05-11 22:16:59 +00:00
cancel update and save tasks on main component unload
This commit is contained in:
+8
-2
@@ -45,6 +45,8 @@ export default defineComponent({
|
|||||||
name: "GuildView",
|
name: "GuildView",
|
||||||
data: () => ({
|
data: () => ({
|
||||||
guild: new Guild(1, 500),
|
guild: new Guild(1, 500),
|
||||||
|
gameTickTask: null as null | number,
|
||||||
|
gameSaveTask: null as null | number,
|
||||||
lastQuestGot: {
|
lastQuestGot: {
|
||||||
S: null as null | number,
|
S: null as null | number,
|
||||||
A: null as null | number,
|
A: null as null | number,
|
||||||
@@ -225,7 +227,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
this.adventurersDatabase = removeAlreadyHiredAdventurers(this.adventurersDatabase, this.adventurers);
|
this.adventurersDatabase = removeAlreadyHiredAdventurers(this.adventurersDatabase, this.adventurers);
|
||||||
|
|
||||||
setInterval(() => {
|
this.gameSaveTask = setInterval(() => {
|
||||||
saveGame(new GameData({
|
saveGame(new GameData({
|
||||||
adventurers: this.adventurers,
|
adventurers: this.adventurers,
|
||||||
guild: this.guild,
|
guild: this.guild,
|
||||||
@@ -236,7 +238,7 @@ export default defineComponent({
|
|||||||
}));
|
}));
|
||||||
}, 10 * 1000)
|
}, 10 * 1000)
|
||||||
|
|
||||||
setInterval(() => {
|
this.gameTickTask = setInterval(() => {
|
||||||
this.updateMissives();
|
this.updateMissives();
|
||||||
|
|
||||||
const now = Number(new Date());
|
const now = Number(new Date());
|
||||||
@@ -326,6 +328,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if (this.gameSaveTask) clearInterval(this.gameSaveTask);
|
||||||
|
if (this.gameTickTask) clearInterval(this.gameTickTask);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user