checkForReleaseNotes method

Future<ReleaseNotesResult> checkForReleaseNotes({
  1. String? lastSeenVersion,
})

Checks if there are release notes to show based on the last seen version. Also triggers a fetch of the latest changelog if the version has changed.

Implementation

Future<ReleaseNotesResult> checkForReleaseNotes({
  String? lastSeenVersion,
}) async {
  final cachedChangelog = await getStoredChangelog();

  if (lastSeenVersion != appVersion || cachedChangelog.isEmpty) {
    // Fetch in background, do not await
    fetchAndStoreChangelog();
  }

  final releaseNotes = getRecentReleaseNotes(
    currentVersion: appVersion,
    previousVersion: lastSeenVersion,
    changelogContent: cachedChangelog,
  );

  return ReleaseNotesResult(
    hasReleaseNotes: releaseNotes.isNotEmpty,
    releaseNotes: releaseNotes,
  );
}