fix: support offline manual bookkeeping

This commit is contained in:
2026-08-21 15:43:01 +08:00
parent 9bb45aac83
commit 979684a06e
5 changed files with 167 additions and 30 deletions
+1
View File
@@ -188,6 +188,7 @@ class _AddPageState extends State<AddPage> {
note: _noteCtrl.text.trim().isEmpty ? null : _noteCtrl.text.trim(),
paymentMethod: _paymentMethod,
occurredAt: _occurredAt,
localFirst: true,
);
TransactionEvents.notifyChanged();
if (mounted) context.pop(amount);
@@ -65,7 +65,13 @@ class _CategoryManagePageState extends State<CategoryManagePage> {
final result = await _showEditor();
if (result == null) return;
try {
await CategoryApi.create(result.name, result.icon, result.color, _type);
await CategoryApi.create(
result.name,
result.icon,
result.color,
_type,
localFirst: true,
);
await _load();
} catch (error) {
if (mounted) _showError(error);
@@ -82,6 +88,7 @@ class _CategoryManagePageState extends State<CategoryManagePage> {
iconKey: result.icon,
colorKey: result.color,
sortOrder: category.sortOrder,
localFirst: true,
);
await _load();
} catch (error) {
@@ -375,7 +382,7 @@ class _CategoryManagePageState extends State<CategoryManagePage> {
);
if (!confirmed) return;
try {
await CategoryApi.delete(category.id);
await CategoryApi.delete(category.id, localFirst: true);
await _load();
} catch (error) {
if (mounted) _showError(error);
@@ -410,7 +417,7 @@ class _CategoryManagePageState extends State<CategoryManagePage> {
final ids = _custom.map((category) => category.id).toList();
setState(() => _savingOrder = true);
try {
await CategoryApi.reorder(_type, ids);
await CategoryApi.reorder(_type, ids, localFirst: true);
if (!mounted) return;
setState(() {
_reordering = false;