/// <summary> /// refreshes cache with the current version of the box; call this after saving changes to a box /// </summary> public void UpdateCacheAfterSave(Box box, BoxEditingPool.Item changes, bool propagateToUI) { //determine what was changed bool newIsHighlighted = box.Visibility == Constants.VISIBILITY_HIGHLIGHT; //update cache (bool _, bool oldWasHighlighted) = ForgetAbout(box.RowId); if (box.BoxTime != null && box.DoneDate == null) { var cb = FullBoxToCachedBox(box); ScheduledBoxes.Add(cb); var projector = new RepeatProjector(); Agenda.AddRange(projector.Project(cb, true, true)); SortAgenda(); } else if (box.BoxTime == null && box.ParentId == null && box.IsUnclass == 0 && box.DoneDate == null) { var cb = FullBoxToCachedBox(box); TopNotes.Add(cb); SortTopNotes(); } //propagate changes to UI if (oldWasHighlighted || newIsHighlighted) { AssignHighlights(); } if (propagateToUI) { Globals.UIAction.BoxCacheChanged(changes); } }
public IEnumerable <long> GetCachedBoxIds() { return(ScheduledBoxes.Select(r => r.RowId).Union(TopNotes.Select(r => r.RowId))); }
void SortTopNotes() { TopNotes.Sort((i, j) => i.Title.CompareTo(j.Title)); }