-
Notifications
You must be signed in to change notification settings - Fork 17
Implementation of Background Services & Notification System #74
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
Merged
Merged
Changes from all commits
Commits
Show all changes
153 commits
Select commit
Hold shift + click to select a range
6dd56f2
added KeyManager class
chebizarro 5d7bca8
Add key manager and related providers
chebizarro 7ce5263
added full privacy mode setting to app settings
chebizarro dace285
Changed SecureStorageManager to SessionManager
chebizarro 8cd3ac8
Moved session storage/retrieval to SessionManager
chebizarro 90b0c06
Added separate wrap, seal and rumor functions
chebizarro d60899d
master key and trade key integration
chebizarro 2d53182
minor edits
chebizarro 0144d0e
Minor fixes to session expiration
chebizarro a27c70b
implementation of key manager features
chebizarro c731b63
verified sending new orders with full privacy
chebizarro 7d299cb
message and session serialization and retrieval
chebizarro 3290c1f
updated mostro message to handle cant-do
chebizarro b3615e0
Implementation of order persistence between restarts
chebizarro a055be9
change order > content to order > payload
chebizarro e993b95
Initialize and load sessions at startup
chebizarro 76d5971
Change rumor content to array
chebizarro 0bb91c6
Debugging signing
chebizarro 4240723
Added support for cant-do
chebizarro da5b982
add buy/sell order now working
chebizarro 3d17946
Update lib/data/models/cant_do.dart
chebizarro f295e4a
should fix https://github.com/MostroP2P/mobile/pull/34#pullrequestrev…
chebizarro d81f1cb
Update lib/features/take_order/screens/add_lightning_invoice_screen.dart
chebizarro be21a2d
added localization extension for retrieving localized strings based o…
chebizarro ab1b7c3
Consolidate all OrderNotifiers as subclasses of AbstractOrderNotifier
chebizarro b9888a3
minor changes to order notifier and notification notifiers
chebizarro 54f3b6a
Filter user orders and updated Add Order screen to match web client
chebizarro 64efd54
Added OrderBook feature
chebizarro 60703fc
Added Drawer to Home Screen
chebizarro ff3e6d1
Unifed order provider fixed
chebizarro 3749491
added Chat and Database support
chebizarro 4da43b6
Rationalised TakeOrderNotifier
chebizarro 330a05f
removed bloc dependancy
chebizarro bdb6edc
Added integration and mocked unit tests
chebizarro af60aa0
Integration tests for Create Sell Order
chebizarro 7d30f8b
Added Key Management and Relay screens
chebizarro 23a856b
Added extra key manager methods for importing existing key
chebizarro ef838ab
Added rating feature
chebizarro b4287c8
renamed order book and chat to trades and messages respectively
chebizarro ba68084
switch persistence to sembat and updated dart_nostr to latest version
chebizarro 64d4a27
updated mostro storage to use sembast
chebizarro 8f94142
Clear caches
chebizarro 64b5293
update tests
chebizarro 86d2d39
Added Mostro Instance Screen and updated OrderNotifier strings
chebizarro 90436bb
Add QR Code Reader to Lightning Invoice screen
chebizarro af2c715
Separate our Lightning invoice components to widgets
chebizarro 39e2c27
Consolidated Drawer Screens
chebizarro bb371f0
Order Screens complete
chebizarro e30068b
Updated launch icons
chebizarro 33c41b7
Major revisions
chebizarro 9ed07e4
Changes to startup and added web support
chebizarro 83ff94b
Added public test nostr relay and daemon as default
chebizarro c8bc4f1
set permissions for secure storage
chebizarro f0f1ef9
UX clean up
chebizarro 7585026
Add mostro pubkey filter getting events
grunch 91dfaf4
fixed privacy mode
chebizarro 0da6684
added default relay
chebizarro 710797b
Updated Settings Screen
chebizarro d561602
update build workflow
chebizarro ae1dd1f
More buildflow fixes
chebizarro f37eb89
Updated Take Order Screen and Home Screen Order List
chebizarro 58d0bcb
improve Lightning Invoice Screen
chebizarro 12ffd00
Improve images
grunch 2ab2654
Add currency flag to my trades widget
grunch a722f54
Fix alignment on currency flag
grunch c85d198
Fix take order bug
chebizarro 32a07aa
Merge remote-tracking branch 'refs/remotes/upstream/wip' into wip
chebizarro db82cd2
fix for build action
chebizarro 753c9fc
works in full privacy mode
chebizarro 6f7c62c
refactored app settings to be more reactive
chebizarro 66c28ce
More settings refactoring
chebizarro 6d4862c
Modified signing function
chebizarro cfa160b
start of mostro service refactor
chebizarro 781242f
Refactored Mostro Service
chebizarro 54c3480
Fixes error creating new order with ln address #38
chebizarro 95ea019
Addresses When creating a new identity, the orders from the previous …
chebizarro 2ede4a5
Started ChatRoom refactor
chebizarro 983f3b0
Updated i10n strings to latest suggestions
chebizarro 7b6800a
Implementation of Rate Counterpart
chebizarro 8483549
Partial implementation of Increment trade index only on success #35
chebizarro f55bc91
Changed AddLightingForm to back to the Home Screen on back/close
chebizarro 4baa690
Revert Increment trade index only on success #35 fix
chebizarro 9dcfca7
Major refactor of MostroService including deprecation of MostroReposi…
chebizarro 686d853
Added BaseStorage abstract class
chebizarro 2d90530
Pay Invoice button added as per Add a Show Invoice button to the sell…
chebizarro 61a4ac0
Cancel button should appear for relevant order states Button cancel i…
chebizarro 146c549
First cut of Mostro Chat
chebizarro 7a09bcb
Updated Drawer
chebizarro 2453ef4
Refdactored Data Storage and Notifiers
chebizarro 917de9f
Updated Settings and Account Screens
chebizarro 082250e
add IT locale
bitcoininvenice 998ff24
added background services
chebizarro 1a067c1
Added changes to background interface and upgraded MacOS settings
chebizarro d550173
synchronize background services
chebizarro 414af2b
Now uses two separate databases
chebizarro 8768fcb
ensure NostrService init
chebizarro fe47e24
Rebuild of out of date annotated classes
chebizarro 8b3d5d0
add isRunning property to BackgroundService
chebizarro f2c8bea
Remove extra event call
chebizarro 6b2faf2
Add lifecycle manager and refactor background service database paths
chebizarro 1280eef
Revert MostrService and ChatRoomNotifier to subscribing directly in t…
chebizarro bd6a5d6
Set background services to only run on app suspend
chebizarro b3fbba8
Startup modifications
chebizarro 4f4f63e
Refactored background service
chebizarro d8b56db
Replace route builders with pageBuilder to add fade transitions betwe…
chebizarro d2e574d
Added isRunning callback
chebizarro c4c8210
renamed notification icon
chebizarro 0cca048
Add background service capabilities and persistent notifications for …
chebizarro 27193bf
Mo background changes
chebizarro 66a1f5c
Avoid race conditions when app is backgrounded
chebizarro 471d615
Add logging and improve app state transitions between foreground/back…
chebizarro df567e4
Add NostrResponsiveButton widget and refactor order repository reload…
chebizarro d9bc94b
Add async state handling and refresh functionality to trades screen
chebizarro 8a1d69e
Refactor buttons using NostrResponsiveButton and improve state manage…
chebizarro 051187e
Refactor message handling to use Sembast storage streams instead of E…
chebizarro 534e752
Add stream providers and watch methods for sessions and messages
chebizarro f8e61a2
Refactor storage and session providers, add error handling and remove…
chebizarro b9f8e13
Add auto-reset to button and improve order request ID generation for …
chebizarro 5e4382b
Fix order stream to emit cached events immediately and handle empty s…
chebizarro ab34fe0
Refactor storage repositories to use base class and improve message h…
chebizarro 31d7b20
Merge pull request #61 from bitcoininvenice/wip
chebizarro a027e54
Add FSM-based order status tracking and update UI to use canonical st…
chebizarro 01fba26
Refactor message stream to use watchAllMessages and emit latest message
chebizarro 6b6024c
More refactoring of MostroStorage
chebizarro 689ed27
Modified status source in TradesDetailScreen and MostroMessageDetailW…
chebizarro d08026d
Change Lifecycle to mobile only and Modify MostroStorage
chebizarro 4e7b6c0
Separated events and orders databases into separate files to prevent …
chebizarro bf7c471
Fix order not saving pubkeys when serialized
chebizarro 5d2be24
Refactor message storage and retrieval to use latest messages consist…
chebizarro 8a0c78b
Fix message watching and improve order notifier initialization
chebizarro ea13f29
Add TradeState model and providers to manage trade status and actions
chebizarro 2ff522e
Cleanup TradeDetailScreen
chebizarro 136aa0d
Convert FutureProvider to StreamProvider for real-time order updates
chebizarro 965304a
Make mostroService and eventStorage providers keepAlive and remove ca…
chebizarro 24d0e72
Add dispose logic for order notifiers and handle order cancellation c…
chebizarro 0fe7d69
Refactor NostrResponsiveButton to use direct action/orderId instead o…
chebizarro a970c3a
Rename NostrResponsiveButton to MostroReactiveButton and update refer…
chebizarro c3bbb19
Fix chat message deduplication and add sorting by creation timestamp
chebizarro 0a6ad39
Add notification permissions and enhance notification settings for An…
chebizarro c3dd554
Simplify reloadData by removing event clearing and empty list emission
chebizarro 9d5399b
Improve chat reliability and add event persistence with lifecycle man…
chebizarro 8bb0f58
Replace event provider with mostro storage and remove duplicate event…
chebizarro 4c325a5
Only request notifications on Android and filter sessions newer than …
chebizarro 2f07d2b
Only subscribe to sessions created within the last 24 hours
chebizarro c90865a
Refactor session updates and add terminal status checks for active or…
chebizarro ce672bb
Refactor button styles and remove hardcoded dimensions from reactive …
chebizarro 0f39455
Filter chats older than 36h and fix session orderId update logic
chebizarro 413d51f
Merge remote-tracking branch 'upstream/wip' into background
chebizarro 6c28f4d
Merge remote-tracking branch 'upstream/main' into background
chebizarro 4aca13c
Fix order notifier disposal and add Italian localization
chebizarro 906e3bb
Refactor background service and storage management; remove unused rep…
chebizarro a88ba04
Refactor notification handling, improve order update logic, and enhan…
chebizarro cbcd51b
Refactor notification service to use a single instance of FlutterLoca…
chebizarro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,6 @@ on: | |
| pull_request: | ||
| branches: | ||
| - main | ||
| push: | ||
| branches: | ||
| - wip | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # Contributing to Mostro Mobile | ||
|
|
||
| Welcome! Thank you for your interest in contributing to the Mostro Mobile project. This guide will help you get started, understand the project architecture, and contribute effectively. | ||
|
|
||
| --- | ||
|
|
||
| ## Table of Contents | ||
| - [How to Contribute](#how-to-contribute) | ||
| - [Project Architecture Overview](#project-architecture-overview) | ||
| - [Getting Started](#getting-started) | ||
| - [Best Practices & Tips](#best-practices--tips) | ||
| - [Contact & Further Resources](#contact--further-resources) | ||
|
|
||
| --- | ||
|
|
||
| ## How to Contribute | ||
|
|
||
| We follow the standard GitHub workflow: | ||
|
|
||
| 1. **Fork the repository** | ||
| 2. **Create a new branch** for your feature or bugfix | ||
| 3. **Write clear, descriptive commit messages** | ||
| 4. **Push your branch** and open a Pull Request (PR) | ||
| 5. **Describe your changes** thoroughly in the PR | ||
| 6. **Participate in code review** and address feedback | ||
|
|
||
| For bug reports and feature requests, please [open an issue](https://github.com/MostroP2P/mobile/issues) with: | ||
| - Clear title and description | ||
| - Steps to reproduce (for bugs) | ||
| - Screenshots/logs if relevant | ||
|
|
||
| --- | ||
|
|
||
| ## Project Architecture Overview | ||
|
|
||
| Mostro Mobile is a Flutter app designed with modularity and maintainability in mind. Here’s a high-level overview of the architecture and key technologies: | ||
|
|
||
| ### 1. State Management: Riverpod & Notifier Pattern | ||
| - **Riverpod** is used for dependency injection and state management. | ||
| - Providers are organized by feature, e.g., `features/order/providers/order_notifier_provider.dart`. | ||
| - The **Notifier pattern** is used for complex state logic (e.g., order submission, authentication). Notifiers encapsulate business logic and expose state via providers. | ||
| - Dedicated state providers are often used to track transient UI states, such as submission progress or error messages. | ||
|
|
||
| ### 2. Data Persistence: Sembast | ||
| - **Sembast** is a NoSQL database used for local data persistence. | ||
| - Database initialization is handled in `shared/providers/mostro_database_provider.dart`. | ||
| - Data repositories (e.g., `data/repositories/base_storage.dart`) abstract CRUD operations and encode/decode models. | ||
| - All local data access should go through repository classes, not direct database calls. | ||
|
|
||
| ### 3. Connectivity: NostrService | ||
| - Connectivity with the Nostr protocol is handled by `services/nostr_service.dart`. | ||
| - The `NostrService` manages relay connections, event subscriptions, and message handling. | ||
| - All Nostr-related logic should be routed through this service or its providers. | ||
|
|
||
| ### 4. Routing: GoRouter | ||
| - Navigation is managed using **GoRouter**. | ||
| - The main router configuration is set up in `core/app.dart` (see the `goRouter` instance). | ||
| - Route definitions are centralized for maintainability and deep linking. | ||
|
|
||
| ### 5. Internationalization (i18n) | ||
| - Internationalization is handled using the `intl` package and Flutter’s localization tools. | ||
| - Localization files are in `lib/l10n/` and generated code in `lib/generated/`. | ||
| - Use `S.of(context).yourKey` for all user-facing strings. | ||
|
|
||
| ### 6. Other Key Patterns & Utilities | ||
| - **Background Services:** Found in `lib/background/` for handling background tasks (e.g., notifications, data sync). | ||
| - **Notifications:** Managed via `notifications/` and corresponding providers. | ||
| - **Shared Utilities:** Common widgets, helpers, and providers live in `shared/`. | ||
| - **Testing:** Tests are in the `test/` and `integration_test/` directories. | ||
|
|
||
| --- | ||
|
|
||
| ## Getting Started | ||
|
|
||
| 1. **Clone the repo:** | ||
| ```sh | ||
| git clone https://github.com/chebizarro/mobile.git | ||
| cd mobile | ||
| ``` | ||
| 2. **Install dependencies:** | ||
| ```sh | ||
| flutter pub get | ||
| ``` | ||
| 3. **Run the app:** | ||
| ```sh | ||
| flutter run | ||
| ``` | ||
| 4. **Configure environment:** | ||
| - Localization: Run `flutter gen-l10n` if you add new strings. | ||
| - Platform-specific setup: See `README.md` for details. | ||
|
|
||
| 5. **Testing:** | ||
| - Unit tests: `flutter test` | ||
| - Integration tests: `flutter test integration_test/` | ||
|
|
||
| 6. **Linting & Formatting:** | ||
| - Check code style: `flutter analyze` | ||
| - Format code: `flutter format .` | ||
|
|
||
| --- | ||
|
|
||
| ## Best Practices & Tips | ||
|
|
||
| - **Follow the existing folder and provider structure.** | ||
| - **Use Riverpod for all state management.** Avoid mixing with other state solutions. | ||
| - **Encapsulate business logic in Notifiers** and expose state via providers. | ||
| - **Use repositories for all data access** (Sembast or Nostr). | ||
| - **Keep UI code declarative and side-effect free.** | ||
| - **For SnackBars, dialogs, or overlays,** always use a post-frame callback to avoid build-phase errors (see `NostrResponsiveButton` pattern). | ||
| - **Refer to existing features** (e.g., order submission, chat) for implementation examples. | ||
|
|
||
| --- | ||
|
|
||
| ## Contact & Further Resources | ||
|
|
||
| - **Main repo:** [https://github.com/MostroP2P/mobile](https://github.com/MostroP2P/mobile) | ||
| - **Questions/Help:** Open a GitHub issue or discussion | ||
| - **Docs:** See `README.md` and code comments for more details | ||
|
|
||
| Happy contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" | ||
| #include "Generated.xcconfig" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" | ||
| #include "Generated.xcconfig" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Uncomment this line to define a global platform for your project | ||
| # platform :ios, '12.0' | ||
|
|
||
| # CocoaPods analytics sends network stats synchronously affecting flutter build latency. | ||
| ENV['COCOAPODS_DISABLE_STATS'] = 'true' | ||
|
|
||
| project 'Runner', { | ||
| 'Debug' => :debug, | ||
| 'Profile' => :release, | ||
| 'Release' => :release, | ||
| } | ||
|
|
||
| def flutter_root | ||
| generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) | ||
| unless File.exist?(generated_xcode_build_settings_path) | ||
| raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" | ||
| end | ||
|
|
||
| File.foreach(generated_xcode_build_settings_path) do |line| | ||
| matches = line.match(/FLUTTER_ROOT\=(.*)/) | ||
| return matches[1].strip if matches | ||
| end | ||
| raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" | ||
| end | ||
|
|
||
| require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | ||
|
|
||
| flutter_ios_podfile_setup | ||
|
|
||
| target 'Runner' do | ||
| use_frameworks! | ||
|
|
||
| flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) | ||
| target 'RunnerTests' do | ||
| inherit! :search_paths | ||
| end | ||
| end | ||
|
|
||
| post_install do |installer| | ||
| installer.pods_project.targets.each do |target| | ||
| flutter_additional_ios_build_settings(target) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import 'package:dart_nostr/dart_nostr.dart'; | ||
| import 'package:mostro_mobile/features/settings/settings.dart'; | ||
|
|
||
| abstract class BackgroundService { | ||
| Future<void> init(); | ||
| void subscribe(List<NostrFilter> filters); | ||
| void updateSettings(Settings settings); | ||
| Future<void> setForegroundStatus(bool isForeground); | ||
| Future<bool> unsubscribe(String subscriptionId); | ||
| Future<void> unsubscribeAll(); | ||
| Future<int> getActiveSubscriptionCount(); | ||
| bool get isRunning; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.