make quick cycling great again
This commit is contained in:
@@ -1064,12 +1064,22 @@ export default router => {
|
||||
|
||||
const currentRatingId = existingRating.length > 0 ? existingRating[0].tag_id : null;
|
||||
let newRatingId;
|
||||
if (currentRatingId === 1) {
|
||||
newRatingId = 2; // SFW -> NSFW
|
||||
} else if (currentRatingId === 2) {
|
||||
newRatingId = cfg.enable_nsfl ? nsfl_id : 1; // NSFW -> NSFL (if enabled) or SFW
|
||||
const reqRating = req.body?.rating || req.post?.rating || req.url?.qs?.rating;
|
||||
if (reqRating === 'sfw') {
|
||||
newRatingId = 1;
|
||||
} else if (reqRating === 'nsfw') {
|
||||
newRatingId = 2;
|
||||
} else if (reqRating === 'nsfl') {
|
||||
newRatingId = nsfl_id;
|
||||
} else {
|
||||
newRatingId = 1; // NSFL or none -> SFW
|
||||
// fallback to cycling
|
||||
if (currentRatingId === 1) {
|
||||
newRatingId = 2; // SFW -> NSFW
|
||||
} else if (currentRatingId === 2) {
|
||||
newRatingId = cfg.enable_nsfl ? nsfl_id : 1; // NSFW -> NSFL (if enabled) or SFW
|
||||
} else {
|
||||
newRatingId = 1; // NSFL or none -> SFW
|
||||
}
|
||||
}
|
||||
|
||||
await db.begin(async sql => {
|
||||
|
||||
@@ -105,8 +105,19 @@ export default router => {
|
||||
const cycle = [1, 2, nsflId];
|
||||
const currentTags = await lib.getTags(postid);
|
||||
const ratingTagId = currentTags.find(t => [1, 2, nsflId].includes(t.id))?.id ?? 0;
|
||||
const cycleIdx = cycle.indexOf(ratingTagId); // -1 if untagged → (−1+1)%3 = 0 → SFW
|
||||
const nextTagId = cycle[(cycleIdx + 1) % cycle.length];
|
||||
|
||||
let nextTagId;
|
||||
const reqRating = req.body?.rating || req.post?.rating || req.url?.qs?.rating;
|
||||
if (reqRating === 'sfw') {
|
||||
nextTagId = 1;
|
||||
} else if (reqRating === 'nsfw') {
|
||||
nextTagId = 2;
|
||||
} else if (reqRating === 'nsfl') {
|
||||
nextTagId = nsflId;
|
||||
} else {
|
||||
const cycleIdx = cycle.indexOf(ratingTagId); // -1 if untagged → (−1+1)%3 = 0 → SFW
|
||||
nextTagId = cycle[(cycleIdx + 1) % cycle.length];
|
||||
}
|
||||
|
||||
try {
|
||||
// Remove any existing rating tag
|
||||
|
||||
Reference in New Issue
Block a user