Minor fixes

This commit is contained in:
franzap
2024-06-18 20:23:17 -03:00
parent cada21fc25
commit d380aef4df
3 changed files with 20 additions and 17 deletions
+4 -4
View File
@@ -117,7 +117,7 @@ class App extends BaseApp with DataModelMixin<App> {
final file = File(path.join(dir.path, hash));
installOnDevice() async {
notifier.state = DeviceInstallProgress();
notifier.state = VerifyingHashProgress();
if (await _isHashMismatch(file.path, hash)) {
var e = 'Hash mismatch, ';
@@ -344,10 +344,10 @@ Future<bool> _isHashMismatch(String path, String hash) async {
final digestOutputSink = AccumulatorSink<Digest>();
final digestInputSink = sha256.startChunkedConversion(digestOutputSink);
String? digest;
try {
while (true) {
final chunk = await reader.readChunk(1024 * 1024);
// Chunk size determined from approximate cpu/memory profiling
final chunk = await reader.readChunk(2048);
if (chunk.isEmpty) {
break; // EOF
}
@@ -385,7 +385,7 @@ class DownloadingInstallProgress extends AppInstallProgress {
DownloadingInstallProgress(this.progress);
}
class DeviceInstallProgress extends AppInstallProgress {}
class VerifyingHashProgress extends AppInstallProgress {}
class HashVerifiedInstallProgress extends AppInstallProgress {}
+8 -6
View File
@@ -475,7 +475,10 @@ class InstallButton extends ConsumerWidget {
_ => switch (progress) {
IdleInstallProgress() => () {
// show trust dialog only if first install
if (app.canInstall && !disabled) {
if (disabled) {
context.showError('Missing signer');
}
if (app.canInstall) {
showDialog(
context: context,
builder: (BuildContext context) {
@@ -500,7 +503,7 @@ class InstallButton extends ConsumerWidget {
child: LinearPercentIndicator(
lineHeight: 40,
percent: switch (progress) {
DeviceInstallProgress() => 1,
VerifyingHashProgress() => 1,
DownloadingInstallProgress(:final progress) => progress,
_ => switch (app.status) {
AppInstallStatus.updated => 1,
@@ -538,16 +541,15 @@ class InstallButton extends ConsumerWidget {
'${(progress * 100).floor()}%',
style: TextStyle(fontWeight: FontWeight.bold),
),
DeviceInstallProgress() => compact
VerifyingHashProgress() => compact
? SizedBox(
width: 14, height: 14, child: CircularProgressIndicator())
: Text(
'Requesting ${app.canUpdate ? 'update' : 'installation'} on device'),
: Text('Verifying file integrity'),
HashVerifiedInstallProgress() => compact
? SizedBox(
width: 14, height: 14, child: CircularProgressIndicator())
: Text(
'Hash verified, ${app.canUpdate ? 'updating' : 'installing'}'),
'Hash verified, requesting ${app.canUpdate ? 'update' : 'installation'}'),
ErrorInstallProgress() => compact
? SizedBox(width: 14, height: 14, child: Icon(Icons.error))
: Text('Error, tap to see message'),
+8 -7
View File
@@ -23,7 +23,6 @@ class SettingsScreen extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final systemInfoState = ref.watch(systemInfoProvider);
final controller = useTextEditingController();
// throw 'Invalid testing error';
final user = ref.settings
.watchOne('_', alsoWatch: (_) => {_.user})
.model!
@@ -58,12 +57,14 @@ class SettingsScreen extends HookConsumerWidget {
loadingWidget: SizedBox(
width: 14, height: 14, child: CircularProgressIndicator()),
onPressed: () async {
final text =
'${controller.text.trim()} [from ${user.npub} on ${DateFormat('MMMM d, y').format(DateTime.now())}]';
final event = BaseEvent(content: text).sign(kI);
await ref.apps.nostrAdapter.notifier
.publish(event, relayUrls: ['wss://relay.zap.store']);
controller.clear();
if (controller.text.trim().isNotEmpty) {
final text =
'${controller.text.trim()} [from ${user.npub} on ${DateFormat('MMMM d, y').format(DateTime.now())}]';
final event = BaseEvent(content: text).sign(kI);
await ref.apps.nostrAdapter.notifier
.publish(event, relayUrls: ['wss://relay.zap.store']);
controller.clear();
}
},
builder: (context, child, callback, state) {
return switch (state) {