Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/IconComboContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const groups = computed(() => {
option.action();
close();
"
@keydown.enter="
option.action();
close();
"
tabindex="0"
role="button"
>
<slot
v-if="$slots.item"
Expand Down
3 changes: 3 additions & 0 deletions src/components/IconContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ onBeforeUnmount(() => {
>
<div
class="activator"
role="button"
tabindex="0"
@click.stop="toggle"
@keydown.enter="toggle"
>
<slot
name="activator"
Expand Down
3 changes: 3 additions & 0 deletions src/components/MatchCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@
@update:modelValue="emit('update:modelValue', $event)"
@statusChanged="emitStatusChanged"
/>
<div
class="match card"
role="button"
tabindex="0"
:class="{ readonly }"
@click="openMatchEditor"
@keydown.enter="openMatchEditor"
>

Check warning on line 107 in src/components/MatchCard.vue

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use <button> or <input> instead of the button role to ensure accessibility across all devices.

See more on https://sonarcloud.io/project/issues?id=davidohnee_bracketeer&issues=AaECV5gaufcJQJmNrMAO&open=AaECV5gaufcJQJmNrMAO&pullRequest=158
<div
class="team"
:class="{
Expand Down
3 changes: 3 additions & 0 deletions src/components/MatchRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@
@update:modelValue="emit('update:modelValue', $event)"
@statusChanged="emitStatusChanged"
/>
<div
class="match row"
role="button"
tabindex="0"
:class="{ readonly }"
@click="openMatchEditor"
@keydown.enter="openMatchEditor"
>

Check warning on line 101 in src/components/MatchRow.vue

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use <button> or <input> instead of the button role to ensure accessibility across all devices.

See more on https://sonarcloud.io/project/issues?id=davidohnee_bracketeer&issues=AaECV5YeufcJQJmNrMAN&open=AaECV5YeufcJQJmNrMAN&pullRequest=158
<div class="time-progress">
<span
v-if="match.status === 'in-progress'"
Expand Down
3 changes: 3 additions & 0 deletions src/components/StepProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const jumpTo = (index: number) => {
<div class="step">
<div
class="circle"
role="button"
tabindex="0"
:class="{
done: index < modelValue,
active: index === modelValue,
Expand All @@ -37,6 +39,7 @@ const jumpTo = (index: number) => {
(canGoBack && index < modelValue),
}"
@click="jumpTo(index)"
@keydown.enter="jumpTo(index)"
></div>
<span>{{ name }}</span>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/components/TournamentMatches.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ onMounted(() => {
:key="option"
:value="option"
class="chip-option"
role="button"
tabindex="0"
:class="{ selected: selectedGroupOption === option }"
@click="selectedGroupOption = option"
@keydown.enter="selectedGroupOption = option"
>
by {{ getFriendlyOptionName(option) }}
</div>
Expand All @@ -239,8 +242,11 @@ onMounted(() => {
</div>
<div
class="filter"
role="button"
tabindex="0"
:class="{ open: matchFilter?.contextMenu?.isOpen }"
@click.stop.prevent="matchFilter?.contextMenu?.toggle()"
@keydown.enter.prevent="matchFilter?.contextMenu?.toggle()"
>
<MatchFilter
ref="matchFilter"
Expand Down
3 changes: 3 additions & 0 deletions src/components/modals/ShareFull/FoldableShareOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const expanded = ref(false);
<div class="option">
<div
class="header"
role="button"
tabindex="0"
@click="expanded = !expanded"
@keydown.enter="expanded = !expanded"
>
<ion-icon :name="expanded ? 'chevron-down' : 'chevron-forward'"></ion-icon>
<h3>{{ title }}</h3>
Expand Down
3 changes: 3 additions & 0 deletions src/components/notifications/ClosableNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ const click = () => {
'cursor-pointer':
(notification.type !== 'redirect' && notification.redirect) || notification.onClick,
}"
role="button"
tabindex="0"
class="notification"
@click.stop.prevent="click"
@keydown.enter="click"
>
<div class="message">
<h4>
Expand Down
9 changes: 9 additions & 0 deletions src/components/notifications/YesNoNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const click = () => {
<template>
<div
class="notification"
role="button"
tabindex="0"
@keydown.enter="click"
@click.stop.prevent="click"
>
<div class="message">
Expand All @@ -62,13 +65,19 @@ const click = () => {
<div class="yes-no">
<div
class="yes option"
role="button"
tabindex="0"
@click.stop.prevent="yes"
@keydown.enter.stop.prevent="yes"
>
<ion-icon name="checkmark-outline"></ion-icon>
</div>
<div
class="no option"
role="button"
tabindex="0"
@click.stop.prevent="no"
@keydown.enter.stop.prevent="no"
>
<ion-icon name="close-outline"></ion-icon>
</div>
Expand Down
6 changes: 2 additions & 4 deletions src/components/share/GistConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ watch(
async () => {
if (!gistRemote.value) return false;
const identifier = gistRemote.value.identifier;
canPush.value = await accounts.findShareAccount(identifier);
canPush.value = accounts.findShareAccount(identifier);
},
{ immediate: true },
);
Expand Down Expand Up @@ -101,9 +101,7 @@ const share = () => {
onMounted(() => {
const identifier = gistRemote.value?.identifier;
if (!identifier) return false;
accounts.findShareAccount(identifier).then((account) => {
canPush.value = account;
});
canPush.value = accounts.findShareAccount(identifier);
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const formatCurrentMatchTime = (match: Match, tournament: Tournament): st
};

export const copyToClipboard = (text: string) => {
navigator.clipboard.writeText(text);
void navigator.clipboard.writeText(text);
};

export const nextPowerOfTwo = (n: number): number => {
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/share/gist/gist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const accessTokenToAccount = async (accessToken: string) => {
}
};

const isMine = async (identifier: string, accounts: Account[]) => {
const isMine = (identifier: string, accounts: Account[]) => {
try {
const { author } = GistClient.fromShare(identifier);
return accounts.find((x) => x.displayName === author) ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/share/gist/pullSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const createPullSync: PullSyncFactory<IGistPullSync> = (tournament) => {
date: new Date(),
};
},
async stop() {
stop() {
console.log("[Gist] Stopping pull sync");
if (this._timer) {
clearInterval(this._timer);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface IdentifierComponents {
mode: ShareMode;
}

export type AccountResolver = (remote: IRemote) => Promise<Account | null>;
export type AccountResolver = (remote: IRemote) => Account | null;

export interface ISimpleShareClient {
pull: (remote: IRemote) => Promise<Import | null>;
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/share/p2p/pullSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const connectPullPeer = (context: PullContext) => {
interface IP2PPullSync extends IPullSync {
_peer: Peer;
_connection: DataConnection | null;
_onDiff: (diff: Change[]) => Promise<void>;
_onDiff: (diff: Change[]) => void;
}

export const createPullSync: PullSyncFactory<IP2PPullSync> = (tournament) => {
Expand All @@ -112,7 +112,7 @@ export const createPullSync: PullSyncFactory<IP2PPullSync> = (tournament) => {
type: "live",
lastUpdate: new Date(),
}),
async _onDiff(diff: Change[]) {
_onDiff(diff: Change[]) {
if (!tournament.value) {
return;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ export const createPullSync: PullSyncFactory<IP2PPullSync> = (tournament) => {
}
});
},
async stop() {
stop() {
console.log("[P2P] Stopping pull sync");
this._connection?.close();
this._connection = null;
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/share/p2p/pushSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ const attachHostConnection =
(connection: DataConnection) => {
connections.push(connection);

connection.on("open", () => {
connection.on("open", async () => {
if (!tournament.value) {
return;
}

connection.send({
await connection.send({
type: "full",
data: deepCopy(toRaw(tournament.value)),
});
Expand Down Expand Up @@ -209,9 +209,9 @@ export const createPushSync = (tournament: Ref<Tournament | null>): IPushSync =>
return;
}

connections.forEach((connection) => {
connections.forEach(async (connection) => {
if (connection.open) {
connection.send({
await connection.send({
type: "diff",
data: changes,
});
Expand Down
3 changes: 3 additions & 0 deletions src/pages/settings/general/appearance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ const theme = useThemeStore();
>
<div
class="theme-preview"
role="button"
tabindex="0"
:class="availableTheme"
@click="theme.set(availableTheme)"
@keydown.enter="theme.set(availableTheme)"
></div>
<span class="theme-name">
{{ availableTheme }}
Expand Down
28 changes: 15 additions & 13 deletions src/stores/persistence/indexedDb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import localforage from "localforage";
import type { ITournamentPersistor } from "./tournamentWatcher";
import { tournamentFromJson } from "@/helpers";
import type { AnyTournament, Tournament } from "@/types/tournament";
import type { AnyTournament } from "@/types/tournament";
import { toRaw } from "vue";

const KEY_PREFIX = "tournament";
Expand All @@ -12,25 +12,27 @@ const store = localforage.createInstance({

export const createIndexedDbStorage = (): ITournamentPersistor => {
const key = (tournamentId: string) => `${KEY_PREFIX}.${tournamentId}`;
const getValue = async (key: string) => {
if (!key.startsWith(KEY_PREFIX)) return null;

const item = await store.getItem(key);
if (item) {
return tournamentFromJson(item as AnyTournament);
}
return null;
};

return {
load: async () => {
const storedTournaments: Tournament[] = [];
for (const key of await store.keys()) {
if (!key.startsWith(KEY_PREFIX)) continue;

const tournament = await store.getItem(key);
if (tournament) {
storedTournaments.push(tournamentFromJson(tournament as AnyTournament));
}
}
return storedTournaments;
const keys = await store.keys();
const storedValues = await Promise.all(keys.map((k) => getValue(k)));
return storedValues.filter((v) => v != null);
},
onTournamentChange: (tournament) => {
store.setItem(key(tournament.id), toRaw(tournament));
void store.setItem(key(tournament.id), toRaw(tournament));
},
onTournamentDeleted: (tournament) => {
store.removeItem(key(tournament.id));
void store.removeItem(key(tournament.id));
},
};
};
3 changes: 3 additions & 0 deletions src/views/create/BasicsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ const setSport = (sportKey: string) => {
v-for="(v, k) in DEFAULTS"
:key="k"
class="chip-option"
role="button"
tabindex="0"
:class="{ selected: tournament.config.sport === k }"
@click="setSport(k)"
@keydown.enter="setSport(k)"
:title="v.description"
>
<ion-icon
Expand Down
6 changes: 6 additions & 0 deletions src/views/create/TemplateView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ const useTemplate = (template: TournamentTemplate | null) => {
<div class="template-list">
<div
class="template"
role="button"
tabindex="0"
@click="useTemplate(null)"
@keydown.enter="useTemplate(null)"
>
<ion-icon
name="document-text-outline"
Expand All @@ -58,9 +61,12 @@ const useTemplate = (template: TournamentTemplate | null) => {
</div>
<div
class="template"
role="button"
tabindex="0"
v-for="template in templates"
:key="template.name"
@click="useTemplate(template)"
@keydown.enter="useTemplate(template)"
>
<img
:src="logoHref(template)"
Expand Down
Loading