Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/api/offstylesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class OffstylesApi extends Api {
break;
case 'player':
params.append("steamid", filter.scope.steamid);
if (filter.scope.wr !== undefined) params.append("wr", filter.scope.wr.toString());
break;
case 'globals':
if (filter.scope.recent) params.append("recent", "true");
Expand Down
2 changes: 1 addition & 1 deletion src/components/MapDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
};
});

const filterChanged = async (name: 'style' | 'sort' | 'best' | 'has_replay' | 'invalidated', value: string | number | boolean | undefined) => {
const filterChanged = async (name: 'style' | 'sort' | 'best' | 'has_replay' | 'wr' | 'invalidated', value: string | number | boolean | undefined) => {
await router.replace({ query: urlParams.updateMany({ [name]: value }) });
};

Expand Down
5 changes: 4 additions & 1 deletion src/components/PlayerDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
sort: (q.sort as SortOrder) || 'Newest',
best: q.best !== undefined ? q.best === 'true' : true,
hasReplay: q.has_replay === 'true',
wr: q.wr === 'true',
invalidated: q.invalidated !== undefined ? q.invalidated === 'true' : undefined,
};
});
Expand Down Expand Up @@ -212,7 +213,7 @@
}
};

const filterChanged = async (name: 'style' | 'sort' | 'best' | 'has_replay' | 'invalidated', value: string | number | boolean | undefined) => {
const filterChanged = async (name: 'style' | 'sort' | 'best' | 'has_replay' | 'wr' | 'invalidated', value: string | number | boolean | undefined) => {
await router.replace({ query: urlParams.updateMany({ [name]: value }) });
};

Expand Down Expand Up @@ -283,6 +284,8 @@
:sort="currentFilter.sort"
:best="currentFilter.best"
:hasReplay="currentFilter.hasReplay"
:wr="currentFilter.wr"
:showWr="true"
:invalidated="currentFilter.invalidated"
:styleOptions="playerStyleOptions"
@filter-Changed="filterChanged"
Expand Down
14 changes: 13 additions & 1 deletion src/components/TimesFilterBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { useModerationStore } from '@/stores/moderation';

type InvalidatedChoice = 'hide' | 'mix' | 'only';
type FilterKey = 'style' | 'sort' | 'best' | 'has_replay' | 'invalidated';
type FilterKey = 'style' | 'sort' | 'best' | 'has_replay' | 'wr' | 'invalidated';

const SORT_OPTIONS: SortOrder[] = ['Fastest', 'Slowest', 'Newest', 'Oldest'];
const INVALIDATED_OPTIONS: { value: InvalidatedChoice, label: string }[] = [
Expand All @@ -23,6 +23,8 @@
sort: SortOrder,
best: boolean,
hasReplay: boolean,
wr?: boolean,
showWr?: boolean,
invalidated: boolean | undefined,
styleOptions: number[],
}>();
Expand Down Expand Up @@ -62,6 +64,11 @@
emit('filter-Changed', 'has_replay', checked ? true : undefined);
};

const wrChanged = (event: Event) => {
const checked = (event.target as HTMLInputElement).checked;
emit('filter-Changed', 'wr', checked ? true : undefined);
};

const invalidatedChanged = (value: InvalidatedChoice) => {
const mapped = value === 'hide' ? undefined : value === 'only';
emit('filter-Changed', 'invalidated', mapped);
Expand Down Expand Up @@ -116,6 +123,11 @@
<span>Has replay</span>
</label>

<label v-if="props.showWr" class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" :checked="!!props.wr" @change="wrChanged">
<span>Only show WR times</span>
</label>

<Listbox
v-if="moderationStore.canInvalidateTimes.value"
:model-value="invalidatedValue"
Expand Down
2 changes: 1 addition & 1 deletion src/types/TimesFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type SortOrder = 'Fastest' | 'Slowest' | 'Newest' | 'Oldest';

export type TimesScope =
| { kind: 'map'; map: string }
| { kind: 'player'; steamid: string }
| { kind: 'player'; steamid: string; wr?: boolean }
| { kind: 'globals'; wr?: boolean; recent?: boolean };

export interface TimesFilter {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/timesFilterFromQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const forPlayer = function(
defaults: FilterDefaults,
canSeeInvalidated: boolean,
): TimesFilter {
return { ...baseFilter({ query, defaults, canSeeInvalidated }), scope: { kind: 'player', steamid } };
const wr = query.wr === 'true' ? true : undefined;
return { ...baseFilter({ query, defaults, canSeeInvalidated }), scope: { kind: 'player', steamid, wr } };
};

const forGlobals = function(
Expand Down