mirror of
https://github.com/zapstore/zapstore.git
synced 2026-10-05 20:48:24 +00:00
Minor fixes
This commit is contained in:
+4
-4
@@ -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 {}
|
||||
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user