Skip to content

Conversation

@chebizarro
Copy link
Contributor

@chebizarro chebizarro commented Apr 30, 2025

This PR delivers a comprehensive set of enhancements and fixes across the codebase, with a primary focus on:

  • Robust background service management for message/event handling
  • Reliable and user-friendly notification delivery throughout the app
  • Improved state synchronization and error handling
  • General codebase cleanup, refactoring, and bug fixes

Key Points

Background Services

  • Refactored and stabilized the background service architecture for both mobile and desktop.
  • Improved session management and background message polling, ensuring that order and chat events are processed even when the app is not in the foreground.
  • Added/updated lifecycle hooks to start, stop, and update background services in response to user actions and app state changes.
  • Enhanced error logging and recovery for background isolates and service failures.
  • Ensured background services respect user settings and update their configuration dynamically.

Notification System

  • Centralized notification logic via a dedicated notification provider and notifier classes.
  • Improved reliability of in-app notifications for all Mostro protocol events, including PaymentRequest, CantDo, Dispute, and Order updates.
  • Added contextual information to notifications (e.g., order IDs, reasons, next actions) for better user guidance.
  • Fixed issues where notifications could be missed or repeated due to provider disposal or subscription errors.

Finite State Machine & Event Handling

  • Refactored notifiers (including PaymentRequestNotifier) to ensure correct subscription to message streams and robust state transitions.
  • Improved synchronization between MostroStorage and notifier families, fixing issues where events were not reflected in the UI.
  • Ensured all notifiers are initialized and synchronized at app startup, addressing edge cases with missed or out-of-order events.

Codebase Quality & Reliability

  • Cleaned up unused imports, dead code, and redundant logic across providers and notifiers.
  • Improved logging and error reporting for storage, background, and notification subsystems.
  • Added/updated unit and integration tests for background services, notification flows, and MostroStorage methods.
  • Enhanced documentation and inline comments for maintainability.

Other Notable Changes

  • Updated provider initialization logic to avoid premature disposal and ensure all relevant state is retained.
  • Improved user experience in trade/order screens by making notifications and state transitions more responsive and reliable.
  • Refined session and chat management to ensure seamless transitions between foreground and background states.

Migration & Testing Notes
Migration: Major breaking changes to data models, users should not use on live data.
Testing: Please report any missed notifications or unexpected state changes.
This PR lays the groundwork for a more robust, user-friendly, and reliable Mostro Mobile experience, especially in scenarios involving background activity and real-time notifications.

Summary by CodeRabbit

  • New Features

    • Added background service support for persistent event subscriptions and notifications on mobile and desktop.
    • Introduced local notification functionality for new Mostro events.
    • Implemented system tray integration for desktop platforms.
    • Added reactive, success-aware action buttons throughout the app.
    • Provided deterministic, memorable nicknames for user public keys.
    • Enhanced About screen with clearer app and instance information.
    • Added lifecycle management for app foreground/background transitions.
    • Introduced Mostro finite-state-machine (FSM) for order lifecycle management.
    • Added new reactive streams for messages and order status.
    • Added notification permission request helper for Android 13+.
  • Improvements

    • Unified and streamlined state management using Riverpod providers and Notifiers.
    • Standardized page transitions with fade animations.
    • Improved order and trade detail screens with clear finite-state-machine-driven actions.
    • Enhanced session and order initialization logic for better reliability.
    • Optimized message and event storage with new querying and streaming capabilities.
    • Updated notification and permission handling for Android and iOS.
    • Improved error handling, loading states, and manual refresh controls in trade and chat screens.
    • Refined background service initialization and communication.
    • Improved MostroService and NostrService with provider-driven architecture.
    • Enhanced chat room subscription and message deduplication logic.
    • Improved button state management and error handling in order submission.
    • Refined session notifier with filtering and update methods.
  • Bug Fixes

    • Fixed serialization bugs in order models.
    • Corrected import paths and removed unused or redundant code.
    • Fixed null handling in session peer setter.
    • Fixed notification icon metadata and Android manifest permissions.
  • Refactor

    • Simplified and modernized repository and storage APIs.
    • Centralized and modularized background service and notification logic.
    • Removed unused classes, screens, and widgets for maintainability.
    • Consolidated imports and updated provider dependencies.
    • Replaced event bus with storage-based reactive streams.
    • Refactored Mostro FSM and order notifiers to remove generics and improve state handling.
    • Updated mocks to align with new interfaces and signatures.
  • Documentation

    • Added a comprehensive CONTRIBUTING.md guide.
    • Updated README with new features and progress.
  • Chores

    • Updated and added dependencies for background services, notifications, and system tray support.
    • Integrated CocoaPods for iOS and macOS.
    • Adjusted build configurations and plugin registrations across platforms.
    • Added database providers for separate event and main databases.
    • Added notification initialization and permission requests in app startup.
  • Tests

    • Updated and expanded mock classes to align with new interfaces and features.

chebizarro and others added 30 commits December 19, 2024 17:13
Fixes type

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…n Action type and AbstractOrderNotifier to consolidate orders
@coderabbitai coderabbitai bot mentioned this pull request Aug 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 4, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants