Skip to content
Snippets Groups Projects
Commit 271427ba authored by ForkBench's avatar ForkBench
Browse files

Removing event for new competitions, replacing it with subscriptions

parent 61044971
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
import Registrations from "./components/Seedings/Registrations.svelte";
import * as Session from "../bindings/changeme/astro/services/session";
import { Competition } from "../bindings/changeme/astro/services/models";
import { Competitions } from "./store";
let competitions: Competition[] = [];
let loading = true;
......@@ -14,7 +15,7 @@
});
// Listen for the "need-to-update" event
window.addEventListener("need-to-update", async () => {
Competitions.subscribe(async () => {
competitions = await Session.GetCompetitions();
});
</script>
......
......@@ -7,7 +7,7 @@
RemoveCompetition,
} from "../../bindings/changeme/astro/services/session";
import { onMount } from "svelte";
import { SelectedCompetition } from "../store";
import { SelectedCompetition, Competitions } from "../store";
let competitions: Competition[] = [];
......@@ -15,7 +15,7 @@
competitions = await GetCompetitions();
// Emit a signal to the parent component
dispatchEvent(new CustomEvent("need-to-update", {}));
Competitions.set(competitions);
}
onMount(loadCompetitions);
......@@ -37,9 +37,9 @@
<button
on:click={async () => {
await RemoveCompetition(competition.CompetitionID);
loadCompetitions();
SelectedCompetition.set(undefined);
loadCompetitions();
}}>X</button
>
</div>
......
......@@ -9,7 +9,6 @@
let players: (Models.Player | null)[] = [];
let filteredPlayers: (Models.Player | null)[] = [];
let competition: Models.Competition | undefined;
var playerNumber = 0;
SelectedCompetition.subscribe((value) => {
competition = value;
......@@ -265,7 +264,8 @@
on:click={async () => {
var player = await GenerateRandomPlayer();
if (player != null) {
player.PlayerInitialRank = ++playerNumber;
player.PlayerInitialRank =
players.length + 1;
}
if (competition != undefined)
......
import { writable } from 'svelte/store';
import type { Competition } from '../bindings/changeme/astro/services/models';
export const SelectedCompetition = writable<Competition | undefined>(undefined);
\ No newline at end of file
export const SelectedCompetition = writable<Competition | undefined>(undefined);
export const Competitions = writable<(Competition | undefined)[]>([]);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment