Add Watch Buddies feature

- Created WatchBuddy model
- M:N junctions to EntrySeen/EpisodeSeen
  and Media relation for profile pictures
- Full CRUD + search + profile picture upload
- WatchBuddySelect multi-select with search and inline create, replaced
  all seen_with text inputs
- WatchBuddiesPage (grid) and WatchBuddyProfilePage (edit form,
  icon-based contacts, poster-grid watch history, monthly timeline)
This commit is contained in:
X4Lo committed 2026-06-25 03:11:14 +01:00
1 parent 4313a794ce
commit e82b905886
28 files changed
+6813 -374

No files matched your search

+28 -19
View File
@@ -1,5 +1,6 @@
const Entry = require('../models/Entry');
const EntrySeen = require('../models/EntrySeen');
const Entry = require("../models/Entry");
const EntrySeen = require("../models/EntrySeen");
const WatchBuddy = require("../models/WatchBuddy");
class EntrySeenController {
constructor() {
@@ -18,34 +19,37 @@ class EntrySeenController {
const entrySeen = await EntrySeen.findByPk(req.params.id);
if (!entrySeen) {
res.status(404).json({ message: 'Entry seen record not found.' });
res.status(404).json({ message: "Entry seen record not found." });
}
res.status(200).json(entrySeen);
}
async createEntrySeen(req, res) {
const { entry_id, date_seen, seen_with } = req.body;
const { entry_id, date_seen, seen_with, buddy_ids } = req.body;
// ? checking the an entry with the given id does exist
const entry = await Entry.findByPk(entry_id);
if (!entry) {
return res.status(404).json({ error: 'Entry not found' });
return res.status(404).json({ error: "Entry not found" });
}
// Create a new EntrySeen record
const newEntrySeen = await EntrySeen.create({
entry_id,
date_seen,
seen_with,
});
// Link watch buddies
if (Array.isArray(buddy_ids) && buddy_ids.length > 0) {
await newEntrySeen.setBuddies(buddy_ids);
}
// Auto-upgrade TV series status when first watched
if (
entry.is_tvseries &&
(!entry.watch_status || entry.watch_status === 'plan_to_watch')
(!entry.watch_status || entry.watch_status === "plan_to_watch")
) {
entry.watch_status = 'watching';
entry.watch_status = "watching";
await entry.save();
}
@@ -56,7 +60,8 @@ class EntrySeenController {
const { entryId } = req.params;
const entrySeens = await EntrySeen.findAll({
where: { entry_id: entryId },
order: [['date_seen', 'DESC']],
order: [["date_seen", "DESC"]],
include: [{ model: WatchBuddy, as: "buddies" }],
});
if (entrySeens.length > 0) {
@@ -64,30 +69,34 @@ class EntrySeenController {
} else {
res
.status(404)
.json({ message: 'No records found for the given entry ID.' });
.json({ message: "No records found for the given entry ID." });
}
}
async updateEntrySeen(req, res) {
const { date_seen, seen_with } = req.body;
const updated = await EntrySeen.update(
const { date_seen, seen_with, buddy_ids } = req.body;
await EntrySeen.update(
{ date_seen, seen_with },
{ where: { id: req.params.id } },
);
if (updated[0] > 0) {
const updatedEntrySeen = await EntrySeen.findByPk(req.params.id);
res.status(200).json(updatedEntrySeen);
} else {
res.status(404).json({ message: 'Entry seen record not found.' });
const record = await EntrySeen.findByPk(req.params.id);
if (!record) {
return res.status(404).json({ message: "Entry seen record not found." });
}
if (Array.isArray(buddy_ids)) {
await record.setBuddies(buddy_ids);
}
res.status(200).json(record);
}
async deleteEntrySeen(req, res) {
const entrySeen = await EntrySeen.findByPk(req.params.id);
if (!entrySeen)
res.status(404).json({ message: 'Entry seen record not found.' });
res.status(404).json({ message: "Entry seen record not found." });
const deleted = await entrySeen.destroy();