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

View file

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