perf(learn): local reads no longer wait on the instance
Every read of the person's content refreshes their keys, and a refresh asked the instance whether the account has keys until it once answered yes, which an account signing in with SimpleLogin alone never does. So on a poor connection every read waited on a request: the library's progress, a request per studyset in a row, took over five minutes, and Home was slow too. A device holding the keys already knows the account has them, so the keys now open first and the instance is asked only while no other sign says so (a device without the keys still asks at every refresh). Whats-New: The library and Home open quickly again without a good connection. Whats-New-De: Die Bibliothek und die Startseite öffnen sich ohne gute Verbindung wieder schnell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
151f848360
commit
1781553f1d
2 changed files with 44 additions and 137 deletions
|
|
@ -88,7 +88,17 @@ class ContentKeys(
|
|||
Future<void> refresh() => _refreshing.run();
|
||||
|
||||
Future<void> _refresh() async {
|
||||
if (ledger.registerHasKeys != true && registerHasKeys != null) {
|
||||
if (!_unlocked) {
|
||||
final account = await _accountKeys();
|
||||
if (account != null) {
|
||||
await cipher.unlock(account);
|
||||
_unlocked = true;
|
||||
}
|
||||
}
|
||||
// Asked only while nothing else says the account has keys: its yes
|
||||
// would change nothing then, and every read refreshes, so reads waited
|
||||
// on the instance, minutes on a poor connection (10 Nov 2026).
|
||||
if (!accountHasKeys && registerHasKeys != null) {
|
||||
try {
|
||||
// Kept only once it says yes; a no is asked again next time.
|
||||
if (await registerHasKeys!() == true) {
|
||||
|
|
@ -102,13 +112,6 @@ class ContentKeys(
|
|||
);
|
||||
}
|
||||
}
|
||||
if (!_unlocked) {
|
||||
final account = await _accountKeys();
|
||||
if (account != null) {
|
||||
await cipher.unlock(account);
|
||||
_unlocked = true;
|
||||
}
|
||||
}
|
||||
_rows = await _gateway.all();
|
||||
// Remembered, so withholding them later changes nothing here.
|
||||
if (_rows.isNotEmpty) {
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
import 'dart:io';
|
||||
|
||||
/// Whether the person answered the library's offer to make every studyset
|
||||
/// private (ADR 0019, D4), on this device: asked once, whatever the answer.
|
||||
abstract interface class PrivateOfferStore() {
|
||||
/// Whether it was answered.
|
||||
Future<bool> answered();
|
||||
|
||||
/// Notes that it was.
|
||||
Future<void> answer();
|
||||
}
|
||||
|
||||
/// [PrivateOfferStore] as a mark in the person's folder: the file is there
|
||||
/// once the offer was answered.
|
||||
class FilePrivateOfferStore(final File _mark) implements PrivateOfferStore {
|
||||
@override
|
||||
Future<bool> answered() async => _mark.existsSync();
|
||||
|
||||
@override
|
||||
Future<void> answer() async {
|
||||
await _mark.parent.create(recursive: true);
|
||||
await _mark.writeAsString('');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue