Skip to content

Commit

Permalink
Merge pull request #1480 from rommapp/hotfix-remove-continue-playing
Browse files Browse the repository at this point in the history
[HOTFIX] Fix remove from continue playing
  • Loading branch information
gantoine authored Jan 13, 2025
2 parents 04c78ab + d0ba1d6 commit bfc0c8a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
21 changes: 11 additions & 10 deletions backend/handler/database/roms_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,19 @@ def update_rom_user(self, id: int, data: dict, session: Session = None) -> RomUs

rom_user = self.get_rom_user_by_id(id)

if data.get("is_main_sibling", False):
rom = self.get_rom(rom_user.rom_id)
if not data.get("is_main_sibling", False):
return rom_user

session.execute(
update(RomUser)
.where(
and_(
RomUser.rom_id.in_(r.id for r in rom.sibling_roms),
RomUser.user_id == rom_user.user_id,
)
rom = self.get_rom(rom_user.rom_id)
session.execute(
update(RomUser)
.where(
and_(
RomUser.rom_id.in_(r.id for r in rom.sibling_roms),
RomUser.user_id == rom_user.user_id,
)
.values(is_main_sibling=False)
)
.values(is_main_sibling=False)
)

return self.get_rom_user_by_id(id)
4 changes: 3 additions & 1 deletion frontend/src/components/common/Game/AdminMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function switchFromFavourites() {
}
await collectionApi
.updateCollection({ collection: favCollection.value as Collection })
.then(({ data }) => {
.then(() => {
emitter?.emit("snackbarShow", {
msg: `${props.rom.name} ${
collectionsStore.isFav(props.rom) ? "added to" : "removed from"
Expand Down Expand Up @@ -101,6 +101,8 @@ async function resetLastPlayed() {
color: "green",
timeout: 2000,
});
romsStore.removeFromContinuePlaying(props.rom);
})
.catch((error) => {
console.log(error);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/services/api/rom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function updateUserRomProps({
romId: number;
data: Partial<RomUserSchema>;
updateLastPlayed?: boolean;
}): Promise<{ data: DetailedRom }> {
}): Promise<{ data: RomUserSchema }> {
return api.put(`/roms/${romId}/props`, {
data: data,
update_last_played: updateLastPlayed,
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/stores/roms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,17 @@ export default defineStore("roms", {
addToRecent(rom: SimpleRom) {
this.recentRoms = [rom, ...this.recentRoms];
},
removeFromRecent(rom: SimpleRom) {
this.recentRoms = this.recentRoms.filter((value) => value.id !== rom.id);
},
addToContinuePlaying(rom: SimpleRom) {
this.continuePlayingRoms = [rom, ...this.continuePlayingRoms];
},
removeFromContinuePlaying(rom: SimpleRom) {
this.continuePlayingRoms = this.continuePlayingRoms.filter(
(value) => value.id !== rom.id,
);
},
update(rom: SimpleRom) {
this.allRoms = this.allRoms.map((value) =>
value.id === rom.id ? rom : value,
Expand Down

0 comments on commit bfc0c8a

Please sign in to comment.