Dashboard: show 10 chapters titled Chapters; bump chapter mtime on beat changes
Beat create/update/delete/reorder/assign/move now touch the parent chapter's UpdatedAt so the dashboard's recency sort reflects beat edits, not just chapter-level prose/tag changes.
This commit is contained in:
@@ -116,6 +116,8 @@ public class BeatService(
|
||||
beat.Tags = await tags.ResolveAsync(chapter.ProjectId, names, ct);
|
||||
}
|
||||
|
||||
chapter.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
|
||||
db.Beats.Add(beat);
|
||||
await db.SaveChangesAsync(ct);
|
||||
|
||||
@@ -150,6 +152,7 @@ public class BeatService(
|
||||
beat.WhatHappened = Patch.Apply(beat.WhatHappened, request.WhatHappened);
|
||||
beat.WhatsNext = Patch.Apply(beat.WhatsNext, request.WhatsNext);
|
||||
beat.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
chapter.UpdatedAt = beat.UpdatedAt;
|
||||
|
||||
if (request.CharacterIds is { } characterIds)
|
||||
{
|
||||
@@ -179,6 +182,12 @@ public class BeatService(
|
||||
|
||||
await RequireBeatAccessAsync(beat, ProjectPermission.DeleteContent, ct);
|
||||
|
||||
var chapter = await db.Chapters.FirstOrDefaultAsync(c => c.Id == beat.ChapterId, ct);
|
||||
if (chapter is not null)
|
||||
{
|
||||
chapter.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
db.Beats.Remove(beat);
|
||||
await db.SaveChangesAsync(ct);
|
||||
return true;
|
||||
@@ -215,6 +224,12 @@ public class BeatService(
|
||||
beat.SortOrder = order++;
|
||||
}
|
||||
|
||||
var chapter = await db.Chapters.FirstOrDefaultAsync(c => c.Id == chapterId, ct);
|
||||
if (chapter is not null)
|
||||
{
|
||||
chapter.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync(ct);
|
||||
return await ListAsync(chapterId, ct);
|
||||
}
|
||||
@@ -262,6 +277,7 @@ public class BeatService(
|
||||
{
|
||||
beat.Characters.Add(character);
|
||||
beat.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
chapter.UpdatedAt = beat.UpdatedAt;
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync(ct);
|
||||
@@ -312,14 +328,18 @@ public class BeatService(
|
||||
}
|
||||
|
||||
var nextSortOrder = await NextSortOrderAsync(request.TargetChapterId, ct);
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
foreach (var beatId in request.BeatIds)
|
||||
{
|
||||
var beat = beats.Single(b => b.Id == beatId);
|
||||
beat.ChapterId = request.TargetChapterId;
|
||||
beat.SortOrder = nextSortOrder++;
|
||||
beat.UpdatedAt = DateTimeOffset.UtcNow;
|
||||
beat.UpdatedAt = now;
|
||||
}
|
||||
|
||||
chapter.UpdatedAt = now;
|
||||
targetChapter.UpdatedAt = now;
|
||||
|
||||
await db.SaveChangesAsync(ct);
|
||||
return beats;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user