diff --git a/src/components/GamePage.vue b/src/components/GamePage.vue index d53c2cb..29b4a85 100644 --- a/src/components/GamePage.vue +++ b/src/components/GamePage.vue @@ -113,6 +113,9 @@ const screenPlanDraft = ref([]) const screenPlanDirty = ref(false) const screenPlanSaving = ref(false) const screenPlanMode = ref<'use' | 'edit'>('use') +let screenPlanRequestVersion = 0 +const screenPlanStepKeys = new WeakMap() +let nextScreenPlanStepKey = 0 const previewQuestions = ref([]) const previewTeams = ref([]) const mapItems = ref([]) @@ -189,8 +192,15 @@ function isScreenPlanEditing() { async function getScreenPlan() { if (isScreenPlanEditing() || screenPlanDirty.value) return + const requestVersion = ++screenPlanRequestVersion const res = await client.GetScreenPlan({ gameID: Number(gameId) }) - if (isScreenPlanEditing() || screenPlanDirty.value) return + if ( + requestVersion !== screenPlanRequestVersion || + isScreenPlanEditing() || + screenPlanDirty.value + ) { + return + } screenPlan.value = res.plan screenPlanDraft.value = res.plan?.steps?.map((step) => ({ ...step })) || [] } @@ -237,8 +247,18 @@ function markScreenPlanDirty() { screenPlanDirty.value = true } +function getScreenPlanStepKey(step: ScreenPlanStep) { + let key = screenPlanStepKeys.get(step) + if (key === undefined) { + key = nextScreenPlanStepKey++ + screenPlanStepKeys.set(step, key) + } + return key +} + async function saveScreenPlan() { if (screenPlanSaving.value) return + screenPlanRequestVersion += 1 screenPlanSaving.value = true try { const currentStep = Math.min( @@ -942,8 +962,16 @@ useSimplePolling(() => { Редактировать @@ -951,11 +979,12 @@ useSimplePolling(() => {

План экранов ещё не создан.