-
Notifications
You must be signed in to change notification settings - Fork 25
fix: Prevent corrupting restored order state on relaunch #589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
5c0f3f6
80398e4
65d326a
96380fb
65fd8ad
31e205b
2913404
d87fd79
38454f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import 'package:mostro_mobile/features/order/providers/order_notifier_provider.d | |
| import 'package:mostro_mobile/features/key_manager/key_manager_provider.dart'; | ||
| import 'package:mostro_mobile/features/mostro/mostro_instance.dart'; | ||
| import 'package:mostro_mobile/shared/utils/nostr_utils.dart'; | ||
| import 'package:mostro_mobile/features/restore/restore_mode_provider.dart'; | ||
|
|
||
| class MostroService { | ||
| final Ref ref; | ||
|
|
@@ -162,6 +163,11 @@ class MostroService { | |
| decryptedEvent.id ?? | ||
| event.id ?? | ||
| 'msg_${DateTime.now().millisecondsSinceEpoch}'; | ||
| if (ref.read(isRestoringProvider)) { | ||
| logger.i('Restore in progress, skipping storage write for ${msg.action}'); | ||
| return; | ||
| } | ||
|
|
||
| await messageStorage.addMessage(messageKey, msg); | ||
|
Comment on lines
+199
to
204
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the relevant service and storage behavior
git ls-files lib/services/mostro_service.dart lib/**/message_storage.dart lib/**/storage*.dart lib/**/message*.dart
echo '--- mostro_service.dart outline ---'
ast-grep outline lib/services/mostro_service.dart --view expanded || true
echo '--- search for addMessage and timestamp fallback ---'
rg -n "addMessage\\(|timestamp .*DateTime\\.now|msg\\.timestamp|innerCreatedAt|kind == 14|createdAt" lib/services lib -g '*.dart' -A 3 -B 3Repository: MostroP2P/mobile Length of output: 50372 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Read the relevant section with line numbers once the file is located.
sed -n '160,240p' lib/services/mostro_service.dartRepository: MostroP2P/mobile Length of output: 2891 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the implementation of messageStorage.addMessage if present.
rg -n "class .*MessageStorage|Future<.*addMessage|void addMessage|DateTime\\.now\\(" lib -g '*.dart' -A 5 -B 5Repository: MostroP2P/mobile Length of output: 50372 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate the MostroMessage model and its timestamp parsing.
rg -n "class MostroMessage|MostroMessage\\.fromJson|timestamp" lib -g '*.dart' -A 6 -B 6 | sed -n '1,220p'Repository: MostroP2P/mobile Length of output: 16989 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the concrete storage implementation used by mostroStorageProvider and its addMessage fallback.
sed -n '1,220p' lib/shared/providers/storage_providers.dart
echo '---'
rg -n "class .*Storage|addMessage\\(|DateTime\\.now\\(" lib -g '*.dart' -A 8 -B 4 | sed -n '1,240p'Repository: MostroP2P/mobile Length of output: 18652 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate the MostroMessage model and its timestamp field handling.
fd -a "mostro_message.dart" lib
fd -a "message.dart" lib | sed -n '1,80p'
rg -n "class MostroMessage|MostroMessage\\.fromJson|timestamp" lib -g '*.dart' -A 8 -B 6 | sed -n '1,220p'Repository: MostroP2P/mobile Length of output: 17321 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find the concrete storage implementation behind mostroStorageProvider and its addMessage behavior.
rg -n "mostroStorageProvider|class .*Storage|addMessage\\(" lib -g '*.dart' -A 8 -B 6 | sed -n '1,260p'Repository: MostroP2P/mobile Length of output: 23071 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the MostroMessage model and the concrete MostroStorage implementation.
sed -n '1,220p' lib/data/models/mostro_message.dart
echo '---'
fd -a "mostro_storage.dart" lib
echo '---'
sed -n '1,260p' lib/data/repositories/mostro_storage.dartRepository: MostroP2P/mobile Length of output: 10636 Use 🤖 Prompt for AI Agents |
||
| logger.i( | ||
| 'Received DM, Event ID: ${decryptedEvent.id ?? event.id} with payload: ${decryptedEvent.content}', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.