Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/dev/drive/drive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,13 @@ Offset _point(Map<String, dynamic> step, String key, [int at = 0]) {
return Offset(xy[at].toDouble(), xy[at + 1].toDouble());
}

String? _textOf(Widget widget) => switch (widget) {
Text(:final data?) => data,
Text(:final textSpan?) => textSpan.toPlainText(),
RichText(:final text) => text.toPlainText(),
_ => null,
};

bool _isText(Widget widget, String text) =>
(widget is Text &&
(widget.data ?? widget.textSpan?.toPlainText()) == text) ||
Expand Down Expand Up @@ -2273,9 +2280,12 @@ Future<void> _run(Map<String, dynamic> step) async {
}
case 'waitText':
final gone = step['gone'] == true;
final containing = step['containing'] == true;
await _waitFor(() {
try {
_centerOf((w) => _isText(w, value as String));
_centerOf((w) => containing
? _textOf(w)?.contains(value as String) ?? false
: _isText(w, value as String));
return !gone;
} on StateError {
return gone;
Expand Down
67 changes: 65 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7137,7 +7137,7 @@
},
"storeBannerHeld": "{strategyName}: {reason}",
"@storeBannerHeld": {
"description": "Draft for Dara. Library banner button for a strategy whose work the store holds for the player. {reason} is one of the storeHeld\u2026 phrases.",
"description": "Draft for Dara. Library banner button for a strategy whose work the store holds for the player. {reason} is one of the storeHeld… phrases.",
"placeholders": {
"strategyName": {
"type": "String"
Expand Down Expand Up @@ -7193,7 +7193,7 @@
}
}
},
"storeEditUnsentConflict": "This changed before your change was sent. Yours is still on the page and waits in the sync button.",
"storeEditUnsentConflict": "This changed before your change was sent. Yours is still on the page; the sync button asks whether to send it.",
"@storeEditUnsentConflict": {
"description": "Draft for Dara. Toast when a change is held before it was sent because a teammate changed the same thing."
},
Expand Down Expand Up @@ -7222,6 +7222,34 @@
}
}
},
"syncButtonPutMineBack": "Put mine back",
"@syncButtonPutMineBack": {
"description": "Draft for Dara. Sync popover button: send the player's held change over the teammate's version the page shows, and draw it."
},
"syncButtonSendMine": "Send mine",
"@syncButtonSendMine": {
"description": "Draft for Dara. Sync popover button: send the player's unsent change over the teammate's."
},
"syncButtonGoToPage": "Go to that page",
"@syncButtonGoToPage": {
"description": "Draft for Dara. Sync popover button when the held change is on another page: open that page so the player can see what they are choosing between."
},
"storeKeepNotYet": "Waiting for the latest version of this page. You can put yours back once it arrives.",
"@storeKeepNotYet": {
"description": "Draft for Dara. Sync popover sentence when Put mine back has to wait for the page's latest version; the button is disabled until it arrives."
},
"storeKeepNotYetOffline": "Waiting for the connection to come back. You can put yours back once the page's latest version arrives.",
"@storeKeepNotYetOffline": {
"description": "Draft for Dara. Sync popover sentence when Put mine back waits for the page's latest version while offline."
},
"storeKeepChangedAgain": "It changed again while you were choosing. The page shows the newer version; choose again.",
"@storeKeepChangedAgain": {
"description": "Draft for Dara. Sync popover sentence when a teammate changed the item again after the popover showed it; nothing was written."
},
"storeHeldOnOtherPage": "It's on another page. Go to that page to choose with it in front of you.",
"@storeHeldOnOtherPage": {
"description": "Draft for Dara. Sync popover sentence when the held change is on a page the player is not looking at."
},
"syncButtonDontSend": "Don't send",
"@syncButtonDontSend": {
"description": "Draft for Dara. Sync popover button for a change held before it was sent: drop it; the page will show the saved version."
Expand All @@ -7242,5 +7270,40 @@
"type": "int"
}
}
},
"storeHeldChangedAgainAfter": "You changed it again after this. Discard mine gives up both; then make your change again.",
"@storeHeldChangedAgainAfter": {
"description": "Draft for Dara. Sync popover sentence when the player's own later change to the held item is drawn over it, so Put mine back is not offered."
},
"storeHeldSomeKeepable": "Some of these can be put back and some can't. Discard mine gives up all of them, including the ones you could put back.",
"@storeHeldSomeKeepable": {
"description": "Draft for Dara. Sync popover sentence when only some of the held changes can be put back; Discard mine applies to all of them."
},
"storeHeldConflictKeepBody": "{count, plural, =1{A teammate changed the same thing first. The page shows their version; yours is kept here. Put yours back to replace theirs, or discard it.} other{A teammate changed the same things first. The page shows their versions; your {count} changes are kept here. Put yours back to replace theirs, or discard them.}}",
"@storeHeldConflictKeepBody": {
"description": "Draft for Dara. Sync popover body for a change a teammate changed first, when Put mine back is offered for it.",
"placeholders": {
"count": {
"type": "int"
}
}
},
"storeHeldUnsentConflictSendBody": "{count, plural, =1{This changed before yours was sent. The page shows yours; it hasn't been sent. Send yours, or don't send it and the page will show the saved version.} other{This changed before your {count} changes were sent. The page shows yours; they haven't been sent. Send yours, or don't send them and the page will show the saved version.}}",
"@storeHeldUnsentConflictSendBody": {
"description": "Draft for Dara. Sync popover body, when Send mine is offered, for a change held before it was sent because a teammate changed the same thing; the page still shows the player's version.",
"placeholders": {
"count": {
"type": "int"
}
}
},
"storeHeldPageBackSendBody": "{count, plural, =1{A page you changed was deleted and has come back. Your change on it wasn't sent; it stays on this computer until you send it or discard it. Discard it and the page shows the saved version.} other{A page you changed was deleted and has come back. Your {count} changes on it weren't sent; they stay on this computer until you send them or discard them. Discard them and the page shows the saved version.}}",
"@storeHeldPageBackSendBody": {
"description": "Draft for Dara. Sync popover body for changes on a page that was deleted and has come back, when Send mine is offered for them.",
"placeholders": {
"count": {
"type": "int"
}
}
}
}
16 changes: 14 additions & 2 deletions lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@
"storeHeldWaitingBehindBody": "その後にあなたが加えた変更も待機中で、表示されたままです。破棄すると、それらも破棄されます。",
"storeHeldUnsentConflict": "あなたの変更が送信される前にこれが変更されました",
"storeHeldUnsentConflictBody": "{count, plural, other{あなたの{count}件の変更が送信される前にこれが変更されました。ページにはあなたの版が表示されていますが、まだ送信されていません。送信しなければ、ページには保存済みの版が表示されます。}}",
"storeEditUnsentConflict": "あなたの変更が送信される前に、これは変更されました。あなたの変更はページに表示されたまま、同期ボタンで待機しています。",
"storeEditUnsentConflict": "あなたの変更が送信される前にこれが変更されました。あなたの版はページに残っています。送信するかどうかは同期ボタンで選べます。",
"storeHeldBothConflicts": "あなたの変更の一部はページから外れ、一部はまだページに残っています。選択はすべてに適用されます。",
"storeHeldItemGone": "変更したものは削除されたため、あなたの変更は破棄のみ可能です。",
"storeUndoHeld": "この変更は同期ボタンで待機しているため、ここでは元に戻せません。同期ボタンで破棄してください。",
Expand All @@ -1529,5 +1529,17 @@
"syncButtonDontSend": "送信しない",
"deletedPageRestoreQueued": "ページを復元しています。このページの変更は同期ボタンで待機しています。",
"storeHeldPageBack": "このページが戻りました。変更は送信を待っています",
"storeHeldPageBackBody": "{count, plural, other{変更したページが削除され、その後戻りました。このページの{count}件の変更は送信されておらず、破棄するまでこのPCに残ります。破棄すると、ページには保存された版が表示されます。}}"
"storeHeldPageBackBody": "{count, plural, other{変更したページが削除され、その後戻りました。このページの{count}件の変更は送信されておらず、破棄するまでこのPCに残ります。破棄すると、ページには保存された版が表示されます。}}",
"syncButtonPutMineBack": "自分の変更に戻す",
"syncButtonSendMine": "自分の版を送信",
"syncButtonGoToPage": "そのページに移動",
"storeKeepNotYet": "このページの最新版を待っています。届いたら自分の変更に戻せます。",
"storeKeepNotYetOffline": "接続の回復を待っています。ページの最新版が届いたら自分の変更に戻せます。",
"storeKeepChangedAgain": "選択している間に再び変更されました。ページには新しい版が表示されています。もう一度選んでください。",
"storeHeldOnOtherPage": "別のページにあります。そのページに移動して、見ながら選んでください。",
"storeHeldChangedAgainAfter": "この後でもう一度変更しています。破棄すると両方の変更が破棄されます。その後でもう一度変更してください。",
"storeHeldSomeKeepable": "一部の変更は元に戻せますが、戻せないものもあります。破棄すると、元に戻せた変更も含めてすべて破棄されます。",
"storeHeldConflictKeepBody": "チームメイトが先に同じものを変更しました。ページにはチームメイトの版が表示されています。{count, plural, other{あなたの{count}件の変更}}はここに保管されています。自分の変更に戻すか、破棄してください。",
"storeHeldUnsentConflictSendBody": "{count, plural, other{あなたの{count}件の変更が送信される前にこれが変更されました。ページにはあなたの版が表示されていますが、まだ送信されていません。送信するか、送信しなければページには保存済みの版が表示されます。}}",
"storeHeldPageBackSendBody": "{count, plural, other{変更したページが削除され、その後戻りました。このページの{count}件の変更は送信されておらず、送信するか破棄するまでこのPCに残ります。破棄すると、ページには保存された版が表示されます。}}"
}
16 changes: 14 additions & 2 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@
"storeHeldWaitingBehindBody": "你之后对它所做的更改也在等待,并仍然显示。放弃会同时放弃这些更改。",
"storeHeldUnsentConflict": "在你的更改发送之前,这里已被修改",
"storeHeldUnsentConflictBody": "{count, plural, other{在你的 {count} 项更改发送之前,这里已被修改。页面显示的是你的版本,但尚未发送。不发送的话,页面将显示已保存的版本。}}",
"storeEditUnsentConflict": "在你的更改发送之前,这里已被更改。你的更改仍显示在页面上,并在同步按钮中等待。",
"storeEditUnsentConflict": "在你的更改发送之前,这里已被修改。页面上仍是你的版本,同步按钮会询问是否发送。",
"storeHeldBothConflicts": "你的部分更改已不在页面上,部分仍在页面上;你的选择会应用于全部更改。",
"storeHeldItemGone": "你更改的内容已被删除,因此你的更改只能放弃。",
"storeUndoHeld": "此更改正在同步按钮中等待,因此无法在这里撤销。请在同步按钮中放弃它。",
Expand All @@ -1529,5 +1529,17 @@
"syncButtonDontSend": "不发送",
"deletedPageRestoreQueued": "正在恢复页面。你在其中的更改正在同步按钮中等待。",
"storeHeldPageBack": "此页面已恢复,你的更改正在等待发送",
"storeHeldPageBackBody": "{count, plural, other{你更改过的页面曾被删除,现已恢复。你在其中的 {count} 项更改尚未发送,在你丢弃之前会保留在这台电脑上。丢弃后,页面会显示已保存的版本。}}"
"storeHeldPageBackBody": "{count, plural, other{你更改过的页面曾被删除,现已恢复。你在其中的 {count} 项更改尚未发送,在你丢弃之前会保留在这台电脑上。丢弃后,页面会显示已保存的版本。}}",
"syncButtonPutMineBack": "恢复我的更改",
"syncButtonSendMine": "发送我的版本",
"syncButtonGoToPage": "前往该页面",
"storeKeepNotYet": "正在等待此页面的最新版本。收到后即可恢复你的更改。",
"storeKeepNotYetOffline": "正在等待连接恢复。收到页面的最新版本后即可恢复你的更改。",
"storeKeepChangedAgain": "在你选择时它又被修改了。页面显示的是较新的版本,请重新选择。",
"storeHeldOnOtherPage": "它在另一个页面上。前往该页面,对照着内容进行选择。",
"storeHeldChangedAgainAfter": "你在此之后又修改过它。丢弃我的更改会放弃两次更改;之后请重新修改。",
"storeHeldSomeKeepable": "其中一些可以放回,另一些不能。丢弃我的更改会放弃全部更改,包括可以放回的那些。",
"storeHeldConflictKeepBody": "队友先修改了同一内容。页面显示队友的版本,你的{count, plural, other{{count} 项更改}}保存在这里。你可以恢复你的更改来替换队友的版本,或放弃它。",
"storeHeldUnsentConflictSendBody": "{count, plural, other{在你的 {count} 项更改发送之前,这里已被修改。页面显示的是你的版本,但尚未发送。你可以发送,或者不发送,页面将显示已保存的版本。}}",
"storeHeldPageBackSendBody": "{count, plural, other{你更改过的页面曾被删除,现已恢复。你在其中的 {count} 项更改尚未发送,在你发送或丢弃之前会保留在这台电脑上。丢弃后,页面会显示已保存的版本。}}"
}
42 changes: 29 additions & 13 deletions lib/providers/collab/cloud_sync_status_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'package:icarus/providers/collab/cloud_media_upload_queue_provider.dart';
import 'package:icarus/providers/collab/convex_connection_provider.dart';
import 'package:icarus/providers/collab/remote_strategy_snapshot_provider.dart';
import 'package:icarus/providers/collab/strategy_op_queue_provider.dart';
import 'package:icarus/providers/strategy_page_session_provider.dart'
show strategyPageSessionProvider;
import 'package:icarus/providers/strategy_save_state_provider.dart';
import 'package:icarus/providers/strategy_provider.dart';
import 'package:icarus/providers/text_draft_provider.dart';
Expand Down Expand Up @@ -254,20 +256,12 @@ final storeWorkPagesProvider = StreamProvider<Set<String>?>(
),
);

final storeHeldGoneProvider = StreamProvider.autoDispose<bool>((ref) {
final owned = ref.watch(storeOwnedProvider);
if (owned == null) return Stream.value(false);
return storeFactOf(
final storeHeldGoneProvider = StreamProvider.autoDispose<Set<String>?>(
(ref) => _storeRows(
ref,
owned,
() async =>
(await heldConflicts(owned.store, owned.strategyId))
?.any((conflict) => conflict.itemGone) ??
false,
same: (before, now) => before == now,
).values;
});

(owned) => heldGone(owned.store, owned.strategyId),
),
);
final storePageBackProvider = StreamProvider<int?>((ref) {
final owned = ref.watch(storeOwnedProvider);
if (owned == null) return Stream.value(0);
Expand Down Expand Up @@ -413,3 +407,25 @@ final openStrategyUnsentChangesProvider = Provider<int>((ref) {
String offlineSyncLabel(AppLocalizations l10n, int waiting) => waiting == 0
? l10n.syncStatusOfflineNothingWaiting
: l10n.syncStatusOfflineChangesSaved(waiting);

final storeConflictRowsProvider = Provider<List<ConflictRow>>((ref) {
final drawn = ref.watch(remoteEditorSnapshotProvider).valueOrNull;
if (drawn == null) return const [];
return conflictRowsAsDrawn(
ref.read(remoteEditorSnapshotProvider.notifier).storeReadOf(drawn),
ref.watch(
strategyPageSessionProvider.select((state) => state.activePageId),
),
);
});

final storeKeepProvider =
Provider<Future<KeepOutcome> Function(List<ConflictRow> rows)>(
(ref) => (rows) async {
final owned = ref.read(storeOwnedProvider);
if (owned == null) return const KeepNotSaved('the store owns no strategy');
return ref.read(storeOwnedProvider.notifier).inTurn(
() => putMineBack(owned.store, owned.reader, owned.strategyId, rows),
);
},
);
Loading
Loading