Auto-upgrade TV status on watch, full-width layout, settings tabs
Marking episode/entry as watched now auto-upgrades TV series from plan_to_watch/null to watching. Settings page uses tabs (General/Maintenance) with 2-column grid. AppLayout container removed for full-width pages.
This commit is contained in:
1 parent
cdbaedd7d0
commit
b001ee2240
4 files changed
+267
-215
No files matched your search
@@ -1,5 +1,5 @@
|
||||
const Entry = require("../models/Entry");
|
||||
const EntrySeen = require("../models/EntrySeen");
|
||||
const Entry = require('../models/Entry');
|
||||
const EntrySeen = require('../models/EntrySeen');
|
||||
|
||||
class EntrySeenController {
|
||||
constructor() {
|
||||
@@ -18,7 +18,7 @@ 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);
|
||||
@@ -30,7 +30,7 @@ class EntrySeenController {
|
||||
// ? 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
|
||||
@@ -39,6 +39,16 @@ class EntrySeenController {
|
||||
date_seen,
|
||||
seen_with,
|
||||
});
|
||||
|
||||
// Auto-upgrade TV series status when first watched
|
||||
if (
|
||||
entry.is_tvseries &&
|
||||
(!entry.watch_status || entry.watch_status === 'plan_to_watch')
|
||||
) {
|
||||
entry.watch_status = 'watching';
|
||||
await entry.save();
|
||||
}
|
||||
|
||||
res.status(201).json(newEntrySeen);
|
||||
}
|
||||
|
||||
@@ -46,7 +56,7 @@ class EntrySeenController {
|
||||
const { entryId } = req.params;
|
||||
const entrySeens = await EntrySeen.findAll({
|
||||
where: { entry_id: entryId },
|
||||
order: [["date_seen", "DESC"]],
|
||||
order: [['date_seen', 'DESC']],
|
||||
});
|
||||
|
||||
if (entrySeens.length > 0) {
|
||||
@@ -54,7 +64,7 @@ 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.' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +79,7 @@ class EntrySeenController {
|
||||
const updatedEntrySeen = await EntrySeen.findByPk(req.params.id);
|
||||
res.status(200).json(updatedEntrySeen);
|
||||
} else {
|
||||
res.status(404).json({ message: "Entry seen record not found." });
|
||||
res.status(404).json({ message: 'Entry seen record not found.' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +87,7 @@ 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.' });
|
||||
|
||||
const deleted = await entrySeen.destroy();
|
||||
|
||||
|
||||
Reference in new issue
Block a user