Update to latest rewrite

This commit is contained in:
franzap
2026-03-25 22:03:56 -03:00
parent 9ad6ee50f1
commit 1ebfb12a84
6 changed files with 93 additions and 45 deletions
+4 -2
View File
@@ -49,8 +49,10 @@ app.*.map.json
# FVM (commit only the version pin/config; never the SDK itself)
!.fvmrc
.fvm/**
.env
reference/*
reference/*
# FVM Version Cache
.fvm/
+47 -1
View File
@@ -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<Model<dynamic>?> _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<Model<dynamic>>();
ProviderSubscription<StorageState>? 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<List<Profile>, ({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
+20 -14
View File
@@ -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,
+1 -1
View File
@@ -554,7 +554,7 @@ Future<PayInvoiceResult> _executeZapPayment(
final result = await command.execute(
connectionUri: nwcString,
ref: ref,
reader: ref.read(storageNotifierProvider.notifier),
timeout: const Duration(seconds: 30),
);
+9 -15
View File
@@ -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
+12 -12
View File
@@ -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: