Prevent onComplete events triggering while loading saves

This commit is contained in:
thepaperpilot 2022-07-07 23:45:54 -05:00
parent a701168ab1
commit 9b89552f1c
2 changed files with 5 additions and 0 deletions

View file

@ -13,6 +13,8 @@ import {
import "game/notifications"; import "game/notifications";
import type { Persistent } from "game/persistence"; import type { Persistent } from "game/persistence";
import { persistent } from "game/persistence"; import { persistent } from "game/persistence";
import player from "game/player";
import settings from "game/settings";
import type { import type {
Computable, Computable,
GetComputableType, GetComputableType,
@ -99,6 +101,7 @@ export function createAchievement<T extends AchievementOptions>(
if (achievement.shouldEarn) { if (achievement.shouldEarn) {
const genericAchievement = achievement as GenericAchievement; const genericAchievement = achievement as GenericAchievement;
watchEffect(() => { watchEffect(() => {
if (settings.active !== player.id) return;
if ( if (
!genericAchievement.earned.value && !genericAchievement.earned.value &&
unref(genericAchievement.visibility) === Visibility.Visible && unref(genericAchievement.visibility) === Visibility.Visible &&

View file

@ -6,6 +6,7 @@ import { globalBus } from "game/events";
import "game/notifications"; import "game/notifications";
import type { Persistent } from "game/persistence"; import type { Persistent } from "game/persistence";
import { persistent } from "game/persistence"; import { persistent } from "game/persistence";
import player from "game/player";
import settings, { registerSettingField } from "game/settings"; import settings, { registerSettingField } from "game/settings";
import { camelToTitle } from "util/common"; import { camelToTitle } from "util/common";
import type { import type {
@ -132,6 +133,7 @@ export function createMilestone<T extends MilestoneOptions>(
if (milestone.shouldEarn) { if (milestone.shouldEarn) {
const genericMilestone = milestone as GenericMilestone; const genericMilestone = milestone as GenericMilestone;
watchEffect(() => { watchEffect(() => {
if (settings.active !== player.id) return;
if ( if (
!genericMilestone.earned.value && !genericMilestone.earned.value &&
unref(genericMilestone.visibility) === Visibility.Visible && unref(genericMilestone.visibility) === Visibility.Visible &&