mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 23:36:20 +00:00
fix(app): read views after queued writes, reload on write failure
- Page and journal views read through the write queue after the previous view's pending saves, so they never load stale text. - A failed write reloads the current view and shows a message instead of leaving blocks on temporary ids; inserts also trigger reconciliation. - Completion replaces the query range, not up to the caret, and closes when the caret moves away. - Renaming a page reloads it so rewritten links are not overwritten. - Dropping below an expanded parent lands as its first child, where the indicator is drawn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fce7526fcf
commit
5e25db3e24
9 files changed
+102
-29
No files matched your search
@@ -41,12 +41,15 @@ class _PageScreenState extends State<PageScreen> {
|
||||
final app = AppScope.read(context);
|
||||
try {
|
||||
final t = widget.target;
|
||||
PageData? v;
|
||||
if (t.id != null) {
|
||||
v = await app.backend.page(t.id!);
|
||||
} else {
|
||||
v = await app.backend.openPage(t.title!);
|
||||
}
|
||||
// Read after the previous view's pending saves (flushed when it is disposed at the
|
||||
// end of this frame) have reached the core.
|
||||
await WidgetsBinding.instance.endOfFrame;
|
||||
final v = await app.queue.run(
|
||||
() => t.id != null
|
||||
? app.backend.page(t.id!)
|
||||
: app.backend.openPage(t.title!).then<PageData?>((p) => p),
|
||||
report: false,
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (v == null) {
|
||||
setState(() => _error = 'This page no longer exists.');
|
||||
@@ -228,6 +231,8 @@ class _TitleFieldState extends State<_TitleField> {
|
||||
await app.queue.run(() => app.backend.renamePage(widget.page.id, title));
|
||||
_committed = title;
|
||||
app.renamed(widget.page.id, title);
|
||||
// The core rewrote links in other blocks, possibly on this page: reload them.
|
||||
app.reload();
|
||||
} catch (e) {
|
||||
_text.text = _committed;
|
||||
messenger.showSnackBar(SnackBar(content: Text('Rename failed: $e')));
|
||||
|
||||
Reference in new issue
Block a user