Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROMM-1427] Add option to remove game from continue playing #1461

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions backend/endpoints/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ async def delete_roms(
@protected_route(router.put, "/roms/{id}/props", [Scope.ROMS_USER_WRITE])
async def update_rom_user(request: Request, id: int) -> RomUserSchema:
data = await request.json()
data = data["data"] or {}
gantoine marked this conversation as resolved.
Show resolved Hide resolved

rom = db_rom_handler.get_rom(id)

Expand All @@ -579,6 +580,7 @@ async def update_rom_user(request: Request, id: int) -> RomUserSchema:
"difficulty",
"completion",
"status",
"last_played",
]

cleaned_data = {field: data[field] for field in fields_to_update if field in data}
Expand Down
40 changes: 39 additions & 1 deletion frontend/src/components/common/Game/AdminMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { Emitter } from "mitt";
import { storeToRefs } from "pinia";
import { inject } from "vue";
import { useI18n } from "vue-i18n";
import romApi from "@/services/api/rom";

// Props
const { t } = useI18n();
Expand Down Expand Up @@ -86,6 +87,31 @@ async function switchFromFavourites() {
emitter?.emit("showLoadingDialog", { loading: false, scrim: false });
});
}

async function resetLastPlayed() {
await romApi
.updateUserRomProps({
romId: props.rom.id,
data: { last_played: null },
})
.then(() => {
emitter?.emit("snackbarShow", {
msg: `${props.rom.name} removed from Continue Playing`,
Copy link
Collaborator

@adamantike adamantike Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we currently support i18n here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we already have a ton of these error messages that aren't translated. At some point we'll do a second pass and correct these, but since they're transient IMO they're lower priority.

icon: "mdi-check-bold",
color: "green",
timeout: 2000,
});
})
.catch((error) => {
console.log(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",
color: "red",
});
return;
});
}
</script>

<template>
Expand Down Expand Up @@ -119,14 +145,26 @@ async function switchFromFavourites() {
</v-list-item>
<v-divider />
</template>
<v-list-item
v-if="auth.scopes.includes('roms.user.write') && rom.rom_user.last_played"
class="py-4 pr-5"
@click="resetLastPlayed"
>
<v-list-item-title class="d-flex">
<v-icon icon="mdi-play-protected-content" class="mr-2" />
{{ t("rom.remove-from-playing") }}
</v-list-item-title>
</v-list-item>
<v-list-item
v-if="auth.scopes.includes('collections.write')"
class="py-4 pr-5"
@click="switchFromFavourites"
>
<v-list-item-title class="d-flex">
<v-icon
:icon="collectionsStore.isFav(rom) ? 'mdi-star-outline' : 'mdi-star'"
:icon="
collectionsStore.isFav(rom) ? 'mdi-star-remove-outline' : 'mdi-star'
"
class="mr-2"
/>{{
collectionsStore.isFav(rom)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/de_DE/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "in",
"rename-file-part5": "Tags im Dateinamen werden nicht verändert",
"no-metadata-source": "Keine Quelle für Metadaten aktiv",
"remove-from-playing": "vom Spielen entfernen",
"edit-rom": "Bearbeiten",
"filename": "Dateiname",
"foldername": "Verzeichnisname",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en_GB/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "to",
"rename-file-part5": "File name tags won't be affected",
"no-metadata-source": "No metadata source enabled",
"remove-from-playing": "Remove from playing",
"edit-rom": "Edit",
"filename": "File name",
"foldername": "Folder name",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en_US/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "to",
"rename-file-part5": "File name tags won't be affected",
"no-metadata-source": "No metadata source enabled",
"remove-from-playing": "Remove from playing",
"edit-rom": "Edit",
"filename": "File name",
"foldername": "Folder name",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/es_ES/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "a",
"rename-file-part5": "Las etiquetas del nombre no se verán afectadas",
"no-metadata-source": "No hay fuente de metadatos habilitada",
"remove-from-playing": "Eliminar de jugar",
"edit-rom": "Editar",
"filename": "Nombre del archivo",
"foldername": "Nombre de la carpeta",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/fr_FR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "à",
"rename-file-part5": "Les tags du nom de fichier ne seront pas affectés",
"no-metadata-source": "Aucune source de métadonnées activée",
"remove-from-playing": "Retirer de jouant",
"edit-rom": "Éditer",
"filename": "Nom du fichier",
"foldername": "Nom du dossier",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ko_KR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "에서 다음으로 변경합니다:",
"rename-file-part5": "파일 이름 태그에는 영향을 주지 않습니다",
"no-metadata-source": "메타데이터 DB 연동 안됨",
"remove-from-playing": "플레이 중지",
"edit-rom": "수정",
"filename": "파일 이름",
"foldername": "폴더 이름",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/pt_BR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "para",
"rename-file-part5": "As tags do nome do arquivo não serão afetadas",
"no-metadata-source": "Nenhuma fonte de metadados habilitada",
"remove-from-playing": "Remover de jogando",
"edit-rom": "Editar",
"filename": "Nome do arquivo",
"foldername": "Nome da pasta",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ru_RU/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "в",
"rename-file-part5": "Теги имени файла не будут затронуты",
"no-metadata-source": "Источник метаданных не включен",
"remove-from-playing": "Удалить из играющих",
"edit-rom": "Редактировать",
"filename": "Имя файла",
"foldername": "Имя папки",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zh_CN/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"rename-file-part4": "至",
"rename-file-part5": "文件名标签不会受到影响",
"no-metadata-source": "未启用元数据源",
"remove-from-playing": "从正在游玩中移除",
"edit-rom": "编辑",
"name": "名称",
"filename": "文件名称",
Expand Down
Loading