Fix remove/mark-watched not working on common-list movies
getLists() returned the common list via MAX(id) grouped across both users' rows, so the id handed back could belong to either partner. remove()/markWatched() scope by (id, user_id), so whenever it picked the partner's id, the query silently matched zero rows while still reporting success. Now each user's own is_common=1 rows are returned directly, so the id is always theirs. Also fixes the frontend never recognizing common movies as "already added" (see watchgether-web). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+5
-7
@@ -63,13 +63,11 @@ class Movie {
|
||||
}
|
||||
|
||||
// 3. Commune
|
||||
$stmt = $this->db->prepare("
|
||||
SELECT MAX(id) as id, tmdb_id, title, poster_path, media_type, is_common, MAX(added_at) as added_at
|
||||
FROM movies
|
||||
WHERE is_common = 1 AND (user_id = ? OR user_id = ?)
|
||||
GROUP BY tmdb_id, title, poster_path, media_type, is_common
|
||||
");
|
||||
$stmt->execute([$myId, $partnerId]);
|
||||
// On renvoie MA propre ligne (pas une fusion avec celle du/de la partenaire) :
|
||||
// chacun a sa propre ligne is_common=1 pour le même film, et remove/mark-watched
|
||||
// ont besoin de MON id pour agir sur MA ligne, pas une autre.
|
||||
$stmt = $this->db->prepare("SELECT * FROM movies WHERE user_id = ? AND is_common = 1 ORDER BY added_at DESC");
|
||||
$stmt->execute([$myId]);
|
||||
$common = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return ["perso" => $perso, "partner" => $partner, "common" => $common];
|
||||
|
||||
Reference in New Issue
Block a user