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
|
// 3. Commune
|
||||||
$stmt = $this->db->prepare("
|
// On renvoie MA propre ligne (pas une fusion avec celle du/de la partenaire) :
|
||||||
SELECT MAX(id) as id, tmdb_id, title, poster_path, media_type, is_common, MAX(added_at) as added_at
|
// chacun a sa propre ligne is_common=1 pour le même film, et remove/mark-watched
|
||||||
FROM movies
|
// ont besoin de MON id pour agir sur MA ligne, pas une autre.
|
||||||
WHERE is_common = 1 AND (user_id = ? OR user_id = ?)
|
$stmt = $this->db->prepare("SELECT * FROM movies WHERE user_id = ? AND is_common = 1 ORDER BY added_at DESC");
|
||||||
GROUP BY tmdb_id, title, poster_path, media_type, is_common
|
$stmt->execute([$myId]);
|
||||||
");
|
|
||||||
$stmt->execute([$myId, $partnerId]);
|
|
||||||
$common = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$common = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return ["perso" => $perso, "partner" => $partner, "common" => $common];
|
return ["perso" => $perso, "partner" => $partner, "common" => $common];
|
||||||
|
|||||||
Reference in New Issue
Block a user