Skip to content

feature: Added update notification and download links per platform#362

Merged
PartyDonut merged 2 commits intodevelopfrom
feature/update-check
Jun 1, 2025
Merged

feature: Added update notification and download links per platform#362
PartyDonut merged 2 commits intodevelopfrom
feature/update-check

Conversation

@PartyDonut
Copy link
Copy Markdown
Collaborator

Pull Request Description

Implements a update notification the user can disable if wanted.
Only gives a notification because updating desktop with the different amount of packages would be less then trivial.

Updates are shown on mobile devices but no notification by default because the update using appstores.

Issue Being Fixed

Resolves #154

@PartyDonut PartyDonut added the feature New feature or request label Jun 1, 2025
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Jun 1, 2025

Reviewer's Guide

This PR adds a GitHub‐based update checker that polls for new releases, stores user preferences in the settings model, and surfaces update notifications and download links in the UI per platform.

Sequence diagram for Automatic Update Check Process

sequenceDiagram
    participant Timer
    participant UpdateProvider
    participant ClientSettingsProvider
    participant UpdateChecker
    participant GitHubAPI
    participant HasNewUpdateProvider
    participant SettingsUserIcon

    Timer->>UpdateProvider: Triggers periodic check (_fetchLatest)
    UpdateProvider->>ClientSettingsProvider: Read checkForUpdates setting
    alt checkForUpdates is true
        UpdateProvider->>UpdateChecker: fetchRecentReleases()
        UpdateChecker->>GitHubAPI: GET /repos/{owner}/{repo}/releases
        GitHubAPI-->>UpdateChecker: Release data (JSON)
        UpdateChecker-->>UpdateProvider: List~ReleaseInfo~
        UpdateProvider->>UpdateProvider: Update state (UpdatesModel)
        alt New update found AND (lastViewedUpdate != latestRelease.version)
            UpdateProvider->>HasNewUpdateProvider: Update state (true)
            HasNewUpdateProvider->>SettingsUserIcon: Update UI (show indicator)
        end
    end
Loading

Sequence diagram for User Viewing Update Details and Interaction

sequenceDiagram
    actor User
    participant SettingsScreen
    participant AboutSettingsRoute
    participant SettingsUpdateInformation
    participant UpdateProvider
    participant ClientSettingsProvider
    participant Browser

    User->>SettingsScreen: Navigates to Settings
    SettingsScreen->>HasNewUpdateProvider: Check for new update status
    alt New update available (via HasNewUpdateProvider)
        SettingsScreen-->>User: Displays "New Release Found" card
        User->>SettingsScreen: Taps "New Release Found" card (navigates to About)
    else User navigates to "About" directly
        User->>SettingsScreen: Taps "About" section
    end
    SettingsScreen->>AboutSettingsRoute: Navigate
    AboutSettingsRoute->>SettingsUpdateInformation: Display
    SettingsUpdateInformation->>UpdateProvider: Get UpdatesModel (releases)
    UpdateProvider-->>SettingsUpdateInformation: UpdatesModel
    SettingsUpdateInformation-->>User: Show release list (versions, changelogs, download links)
    opt User views latest release details
        SettingsUpdateInformation->>ClientSettingsProvider: update(lastViewedUpdate = latestRelease.version)
        ClientSettingsProvider-->>ClientSettingsProvider: Persist change
        SettingsUpdateInformation->>HasNewUpdateProvider: (Potentially causes update to false)
    end
    opt User clicks download link
        User->>SettingsUpdateInformation: Taps download link for a release
        SettingsUpdateInformation->>Browser: Opens GitHub URL for download
    end
    opt User toggles update check setting
        User->>SettingsUpdateInformation: Toggles "Check for Updates" switch
        SettingsUpdateInformation->>ClientSettingsProvider: update(checkForUpdates = newValue)
        ClientSettingsProvider-->>ClientSettingsProvider: Persist change
    end
Loading

File-Level Changes

Change Details Files
Extend client settings model to track update preferences
  • Introduce checkForUpdates and lastViewedUpdate fields in the freezed model
  • Wire up JSON serialization and default values for the new fields
  • Include the new properties in copyWith, toString, diagnostics, equality
lib/models/settings/client_settings_model.freezed.dart
lib/models/settings/client_settings_model.g.dart
lib/models/settings/client_settings_model.dart
Implement utility to fetch and parse GitHub releases
  • Create UpdateChecker to fetch releases via GitHub API
  • Define ReleaseInfo with version comparison and platform‐specific download URL grouping
  • Add extension to prettify download key labels
lib/util/update_checker.dart
Create Riverpod providers for update polling and notification
  • Add Update notifier with periodic polling and state management
  • Define UpdatesModel and a hasNewUpdateProvider to expose notification flag
  • Cancel timers when disabling update checks
lib/providers/update_provider.dart
lib/providers/update_provider.freezed.dart
lib/providers/update_provider.g.dart
Integrate update UI elements across the app
  • Overlay an info badge on the user icon when a new update is available
  • Display a new release card in settings if an update exists
  • Embed a SettingsUpdateInformation section in the About page with toggle and expandable changelog entries
lib/widgets/navigation_scaffold/components/settings_user_icon.dart
lib/screens/settings/settings_screen.dart
lib/screens/settings/about_settings_page.dart
lib/screens/settings/widgets/settings_update_information.dart
lib/widgets/navigation_scaffold/components/side_navigation_bar.dart
Add Markdown support for changelog display
  • Add markdown_widget dependency to pubspec.yaml
  • Use MarkdownWidget to render release notes in the update information UI
pubspec.yaml
lib/screens/settings/widgets/settings_update_information.dart

Assessment against linked issues

Issue Objective Addressed Explanation

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @PartyDonut - I've reviewed your changes - here's some feedback:

  • In SettingsUpdateInformation.initState, you’re marking updates as viewed on widget build—consider moving that into a user action (e.g. when they expand or tap the update) so updates aren’t flagged as seen prematurely.
  • Enhance UpdateChecker.fetchRecentReleases with proper exception handling, retries and a GitHub‐compatible User-Agent header to avoid silent failures and API rate limits.
  • The hasNewUpdateProvider uses defaultTargetPlatform which won’t catch web or custom builds correctly—consider a more robust platform check (e.g. using kIsWeb or explicit desktop flags).
Here's what I looked at during the review
  • 🟡 General issues: 4 issues found
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@PartyDonut PartyDonut merged commit 2c71dde into develop Jun 1, 2025
1 check passed
@PartyDonut PartyDonut deleted the feature/update-check branch June 1, 2025 19:36
Julien9969 pushed a commit to Julien9969/Fladder that referenced this pull request Sep 7, 2025
…onutWare#362)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💡 [Desktop] Add option to auto update the app.

1 participant