Skip to content

Commit

Permalink
autoselect most recent state on play
Browse files Browse the repository at this point in the history
  • Loading branch information
zurdi15 committed Jul 8, 2024
1 parent 51bc201 commit c448efd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Details/Saves.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const HEADERS = [
key: "emulator",
},
{
title: "Last update",
title: "Updated",
align: "start",
sortable: true,
key: "updated_at",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Details/States.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const HEADERS = [
key: "emulator",
},
{
title: "Last update",
title: "Updated",
align: "start",
sortable: true,
key: "updated_at",
Expand Down
30 changes: 17 additions & 13 deletions frontend/src/views/Play/Base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import Player from "@/views/Play/Player.vue";
import { isNull } from "lodash";
import { onMounted, ref } from "vue";
import { useRoute } from "vue-router";
import { useTheme } from "vuetify";
// Props
const theme = useTheme();
const route = useRoute();
const rom = ref<DetailedRom | null>(null);
const firmwareOptions = ref<FirmwareSchema[]>([]);
Expand Down Expand Up @@ -52,6 +50,12 @@ onMounted(async () => {
platformId: romResponse.data.platform_id,
});
firmwareOptions.value = firmwareResponse.data;
// Auto select most recent state
if (rom.value.user_states && rom.value.user_states?.length > 0) {
stateRef.value = rom.value.user_states.sort((a, b) =>
b.updated_at.localeCompare(a.updated_at)
)[0];
}
});
</script>

Expand Down Expand Up @@ -206,17 +210,17 @@ onMounted(async () => {
"
>
<template #selection="{ item }">
<v-list-item :title="item.value.file_name ?? ''">
<v-list-item class="pa-0" :title="item.value.file_name ?? ''">
<template #append>
<v-chip size="x-small" class="ml-1" color="orange" label>{{
item.value.emulator
}}</v-chip>
<v-chip size="x-small" class="ml-1" label>
{{ formatTimestamp(item.value.updated_at) }}
</v-chip>
<v-chip size="x-small" class="ml-1" label
>{{ formatBytes(item.value.file_size_bytes) }}
</v-chip>
>{{ formatBytes(item.value.file_size_bytes) }}
</v-chip>
<v-chip size="small" class="ml-1" label>
{{ formatTimestamp(item.value.updated_at) }}
</v-chip>
</template>
</v-list-item>
</template>
Expand All @@ -230,12 +234,12 @@ onMounted(async () => {
<v-chip size="x-small" class="ml-1" color="orange" label>{{
item.value.emulator
}}</v-chip>
<v-chip size="x-small" class="ml-1" label>
{{ formatTimestamp(item.value.updated_at) }}
</v-chip>
<v-chip size="x-small" class="ml-1" label
>{{ formatBytes(item.value.file_size_bytes) }}
</v-chip>
>{{ formatBytes(item.value.file_size_bytes) }}
</v-chip>
<v-chip size="small" class="ml-1" label>
{{ formatTimestamp(item.value.updated_at) }}
</v-chip>
</template>
</v-list-item>
</template>
Expand Down

0 comments on commit c448efd

Please sign in to comment.