From 1ebfb12a8483b8469eedbd45e813b153a8ab9569 Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Wed, 25 Mar 2026 22:03:56 -0300 Subject: [PATCH] Update to latest rewrite --- .gitignore | 6 ++- .../relevant_who_follow_container.dart | 48 ++++++++++++++++++- lib/widgets/version_pill_widget.dart | 34 +++++++------ lib/widgets/zap_widgets.dart | 2 +- pubspec.lock | 24 ++++------ pubspec.yaml | 24 +++++----- 6 files changed, 93 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index d333c8e..637d64a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,8 +49,10 @@ app.*.map.json # FVM (commit only the version pin/config; never the SDK itself) !.fvmrc -.fvm/** .env -reference/* \ No newline at end of file +reference/* + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/lib/widgets/relevant_who_follow_container.dart b/lib/widgets/relevant_who_follow_container.dart index df56ed7..f6e8ad8 100644 --- a/lib/widgets/relevant_who_follow_container.dart +++ b/lib/widgets/relevant_who_follow_container.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; @@ -350,6 +352,50 @@ class RelevantWhoFollowContainer extends HookConsumerWidget { } } +/// Runs a DVM request and waits for a response. +/// Replicates the old DVMRequest.run() behavior that was removed from the model layer. +Future?> _runDVMRequest( + Ref ref, + Model request, + String relays, { + Duration timeout = const Duration(seconds: 16), +}) async { + final responseKind = (request as DVMRequest).responseKind; + final source = RemoteSource(relays: relays, stream: true); + + final provider = queryKinds( + kinds: {responseKind, 7000}, + tags: { + '#e': {request.event.id}, + }, + limit: 1, + source: source, + ); + + final completer = Completer>(); + ProviderSubscription? subscription; + + try { + subscription = ref.listen(provider, (_, state) { + if (completer.isCompleted) return; + if (state case StorageData(:final models) when models.isNotEmpty) { + completer.complete(models.first); + } + }); + + await ref.read(storageNotifierProvider.notifier).publish( + {request}, + source: source, + ); + + return await completer.future.timeout(timeout); + } on TimeoutException { + return null; + } finally { + subscription?.close(); + } +} + final relevantWhoFollowProvider = FutureProvider.autoDispose .family, ({String to})>((ref, arg) async { // Require active signer and profile to submit the request @@ -370,7 +416,7 @@ final relevantWhoFollowProvider = FutureProvider.autoDispose final request = await partial.signWith(signer); // Execute against the 'vertex' relay group and await response - final response = await request.run('vertex'); + final response = await _runDVMRequest(ref, request, 'vertex'); if (response is VerifyReputationResponse) { // Fetch corresponding profiles for the returned pubkeys diff --git a/lib/widgets/version_pill_widget.dart b/lib/widgets/version_pill_widget.dart index 061e989..24a47e8 100644 --- a/lib/widgets/version_pill_widget.dart +++ b/lib/widgets/version_pill_widget.dart @@ -55,8 +55,12 @@ class VersionPillWidget extends HookConsumerWidget { }; // Resolve installed and available versions using AppExt - final installedVersion = loadedApp.installedPackage?.version; + final installedPackage = loadedApp.installedPackage; + final installedVersion = installedPackage?.version; + final installedVersionCode = installedPackage?.versionCode; final availableVersion = loadedApp.latestFileMetadata?.version; + final availableVersionCode = loadedApp.latestFileMetadata?.versionCode; + final isInstalled = loadedApp.isInstalled; final updateAvailable = loadedApp.hasUpdate; final downgradeAvailable = loadedApp.hasDowngrade; @@ -67,10 +71,12 @@ class VersionPillWidget extends HookConsumerWidget { availableVersion != null) { return _buildDualVersionPills( context, - loadedApp, installedVersion, + installedVersionCode, availableVersion, + availableVersionCode, isDowngrade: downgradeAvailable, + updateAvailable: updateAvailable, ); } @@ -83,10 +89,11 @@ class VersionPillWidget extends HookConsumerWidget { return _buildVersionPill( context, - loadedApp, version, AppColors.darkPillBackground, Colors.white, + isInstalled: isInstalled, + updateAvailable: updateAvailable, ); } @@ -103,15 +110,13 @@ class VersionPillWidget extends HookConsumerWidget { Widget _buildDualVersionPills( BuildContext context, - App loadedApp, String installedVersion, - String availableVersion, { + int? installedVersionCode, + String availableVersion, + int? availableVersionCode, { bool isDowngrade = false, + bool updateAvailable = false, }) { - // Get version codes - final installedVersionCode = loadedApp.installedPackage?.versionCode; - final availableVersionCode = loadedApp.latestFileMetadata?.versionCode; - // When version strings are equal but version codes differ, show version codes in parentheses final showVersionCodes = installedVersion == availableVersion && @@ -126,7 +131,6 @@ class VersionPillWidget extends HookConsumerWidget { Flexible( child: _buildVersionPill( context, - loadedApp, installedVersion, Theme.of(context).colorScheme.outline.withValues(alpha: 0.3), Theme.of(context).colorScheme.onSurface, @@ -146,7 +150,6 @@ class VersionPillWidget extends HookConsumerWidget { Flexible( child: _buildVersionPill( context, - loadedApp, availableVersion, isDowngrade ? Theme.of(context).colorScheme.outline.withValues(alpha: 0.3) @@ -154,7 +157,9 @@ class VersionPillWidget extends HookConsumerWidget { isDowngrade ? Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.5) : Colors.white, + isInstalled: true, isDowngrade: isDowngrade, + updateAvailable: updateAvailable, versionCode: showVersionCodes ? availableVersionCode : null, ), ), @@ -164,12 +169,13 @@ class VersionPillWidget extends HookConsumerWidget { Widget _buildVersionPill( BuildContext context, - App loadedApp, String version, Color backgroundColor, Color textColor, { bool isInstalledVersion = false, + bool isInstalled = false, bool isDowngrade = false, + bool updateAvailable = false, int? versionCode, }) { // Build display version with optional version code in parentheses @@ -181,7 +187,7 @@ class VersionPillWidget extends HookConsumerWidget { if (isDowngrade) { // Downgrade forbidden statusIcon = Icon(Icons.block, size: 12, color: textColor); - } else if (!loadedApp.isInstalled) { + } else if (!isInstalled) { // Can install statusIcon = const Icon( Icons.download_rounded, @@ -189,7 +195,7 @@ class VersionPillWidget extends HookConsumerWidget { color: Colors.white, ); } else { - if (loadedApp.hasUpdate) { + if (updateAvailable) { // Can update statusIcon = const Icon( Icons.update_outlined, diff --git a/lib/widgets/zap_widgets.dart b/lib/widgets/zap_widgets.dart index 2e5f3f1..8366b28 100644 --- a/lib/widgets/zap_widgets.dart +++ b/lib/widgets/zap_widgets.dart @@ -554,7 +554,7 @@ Future _executeZapPayment( final result = await command.execute( connectionUri: nwcString, - ref: ref, + reader: ref.read(storageNotifierProvider.notifier), timeout: const Duration(seconds: 30), ); diff --git a/pubspec.lock b/pubspec.lock index 13368c0..fc01e63 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -4,11 +4,9 @@ packages: amber_signer: dependency: "direct main" description: - path: "." - ref: "6cbedbe" - resolved-ref: "6cbedbe6ae58a952c564979002258840921b041b" - url: "https://github.com/purplebase/amber_signer" - source: git + path: "../../purplebase/amber_signer" + relative: true + source: path version: "0.2.0" any_link_preview: dependency: "direct main" @@ -684,11 +682,9 @@ packages: models: dependency: "direct main" description: - path: "." - ref: "4ef180e4d1832d2895030046d7bf4a251578f2df" - resolved-ref: "4ef180e4d1832d2895030046d7bf4a251578f2df" - url: "https://github.com/purplebase/models" - source: git + path: "../../purplebase/models" + relative: true + source: path version: "0.3.3" nm: dependency: transitive @@ -869,11 +865,9 @@ packages: purplebase: dependency: "direct main" description: - path: "." - ref: "4d1db7dd5096c6bfef398a8d14747b1e3eba930d" - resolved-ref: "4d1db7dd5096c6bfef398a8d14747b1e3eba930d" - url: "https://github.com/purplebase/purplebase" - source: git + path: "../../purplebase/purplebase" + relative: true + source: path version: "0.3.3" qr: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index 1ee7eb7..bea0e0f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -59,20 +59,20 @@ dependencies: dependency_overrides: models: - # path: ../../purplebase/models - git: - url: https://github.com/purplebase/models - ref: 4ef180e4d1832d2895030046d7bf4a251578f2df + path: ../../purplebase/models + # git: + # url: https://github.com/purplebase/models + # ref: 4ef180e4d1832d2895030046d7bf4a251578f2df purplebase: - # path: ../../purplebase/purplebase - git: - url: https://github.com/purplebase/purplebase - ref: 4d1db7dd5096c6bfef398a8d14747b1e3eba930d + path: ../../purplebase/purplebase + # git: + # url: https://github.com/purplebase/purplebase + # ref: 4d1db7dd5096c6bfef398a8d14747b1e3eba930d amber_signer: - # path: ../amber_signer - git: - url: https://github.com/purplebase/amber_signer - ref: 6cbedbe + path: ../../purplebase/amber_signer + # git: + # url: https://github.com/purplebase/amber_signer + # ref: 6cbedbe dev_dependencies: flutter_test: