Fix replicant reactivity for scoreboard

This commit is contained in:
Pandipipas
2026-02-08 17:19:06 +01:00
parent aa6c9acf1c
commit 62ce10df55
3 changed files with 10 additions and 18 deletions
+4 -6
View File
@@ -1,6 +1,5 @@
import { defineStore } from 'pinia';
import { computed, ref, watch } from 'vue';
import type { Ref } from 'vue';
import { playersReplicant } from '../../../browser_shared/replicants';
import type { Schemas } from '../../../types';
@@ -67,7 +66,6 @@ const writeStorage = (value: PlayersMap) => {
export const usePlayersStore = defineStore('players', () => {
const players = ref<PlayersMap>({});
const replicant = playersReplicant;
const replicantRef = replicant?.data as unknown as Ref<PlayersMap | undefined> | undefined;
const storageSnapshot = readStorage();
if (storageSnapshot) {
players.value = storageSnapshot;
@@ -76,7 +74,7 @@ export const usePlayersStore = defineStore('players', () => {
const isApplyingReplicant = ref(false);
watch(
() => replicantRef?.value,
() => replicant?.data,
(value) => {
if (!value) {
return;
@@ -93,11 +91,11 @@ export const usePlayersStore = defineStore('players', () => {
players,
(value) => {
writeStorage(value);
if (isApplyingReplicant.value || !replicantRef) {
if (isApplyingReplicant.value || !replicant) {
return;
}
replicantRef.value = normalizePlayers(value);
replicant?.save();
replicant.data = normalizePlayers(value);
replicant.save();
},
{ deep: true }
);