30 lines
3.4 KiB
C#
30 lines
3.4 KiB
C#
using PlotLine.Models;
|
|
using PlotLine.ViewModels;
|
|
namespace PlotLine.Services.Writer;
|
|
public interface IWriterSuggestionProvider { IReadOnlyList<WriterSuggestion> Suggest(WriterDashboardViewModel model); }
|
|
// Data-only rules. Advanced providers can implement the same interface without changing the UI.
|
|
public sealed class WriterSuggestionProvider:IWriterSuggestionProvider
|
|
{
|
|
public IReadOnlyList<WriterSuggestion> Suggest(WriterDashboardViewModel model)
|
|
{
|
|
var result=new List<WriterSuggestion>();
|
|
if(model.Objective is {} objective)result.Add(new("focus",$"Your saved activity is {objective.Activity.ToLowerInvariant()}.","Return to your current focus",objective.SceneID.HasValue?"Scenes":"Writer",objective.SceneID.HasValue?"Edit":objective.ChapterID.HasValue?"Chapter":"Write",objective.SceneID??objective.ChapterID));
|
|
if(model.PlannedActivities.FirstOrDefault() is {} reviewed)result.Add(new("reviewed",$"Your reviewed plan includes {reviewed.Title} on {reviewed.ScheduledDate:d MMM}.","Open your next planned activity",reviewed.SceneID.HasValue?"Scenes":"Writer",reviewed.SceneID.HasValue?"Edit":"Chapter",reviewed.SceneID??reviewed.ChapterID));
|
|
var planned=model.WritingSchedule.TodayTasks.Concat(model.WritingSchedule.UpcomingTasks).FirstOrDefault();
|
|
if(planned!=null)result.Add(new("planned",$"Your plan includes {planned.SceneTitle} on {planned.ScheduledDate:d MMM}.","Open this planned scene","Scenes","Edit",planned.SceneID));
|
|
var reminder=model.StoryHealthReminders.FirstOrDefault(x=>x.EntityType=="Chapter"&&x.Category=="Chapter Goal");
|
|
if(reminder!=null)result.Add(new("intent",reminder.Detail??"This chapter has no saved goal summary.","Set this chapter's Intent","Writer","Chapter",reminder.EntityID));
|
|
var revision=model.RevisionQueue.FirstOrDefault();
|
|
if(revision!=null)result.Add(new("revision",$"{revision.SceneTitle} is marked Needs Work.","Review this scene","Scenes","Edit",revision.SceneID,Interpretation:"This is a workflow label, not a new diagnosis."));
|
|
var next=model.WriteNext.FirstOrDefault();
|
|
if(next!=null)result.Add(new("draft",$"{next.SceneTitle} is marked Outlined.","Work on the next outlined scene","Scenes","Edit",next.SceneID));
|
|
if(model.Activity?.Totals is {Removed:>0} totals)result.Add(new("changes",$"Accepted changes record {totals.Added:N0} additions and {totals.Removed:N0} removals in 30 days.","Review the change evidence","WritingActivity","Index",Interpretation:"Revision may be substantial even when net growth is small."));
|
|
var chapter=model.ObjectiveChoices.FirstOrDefault(x=>x.ChapterID==model.Objective?.ChapterID)??model.ObjectiveChoices.FirstOrDefault();
|
|
if(chapter!=null)result.Add(new("listen",$"{chapter.ChapterTitle} is available in this book.","Read or start Audio Review","ManuscriptReader","Index",ChapterID:chapter.ChapterID,Interpretation:"Listening is an alternative review activity; media controls require updated Windows Companion."));
|
|
var note=model.StoryHealthReminders.FirstOrDefault(x=>x.SceneID.HasValue&&x.Category=="Writer Note");
|
|
if(note!=null)result.Add(new("note",note.Detail??"A note is available for this scene.","Review this captured note","Scenes","Edit",note.SceneID));
|
|
if(model.BookID.HasValue&&result.Count<3)result.Add(new("explore",$"This book contains {model.Book?.ChapterCount??0} chapters.","Explore or add chapters","Books","Details",model.BookID));
|
|
return result.DistinctBy(x=>(x.Controller,x.RouteAction,x.EntityID,x.ChapterID)).Take(4).ToArray();
|
|
}
|
|
}
|