Skip to content

Commit 202c07e

Browse files
committed
ref!: smush the Prefs and Stows types together
1 parent eaad014 commit 202c07e

File tree

11 files changed

+367
-420
lines changed

11 files changed

+367
-420
lines changed

lib/components/canvas/image/png_editor_image.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class PngEditorImage extends EditorImage {
140140
Size(descriptor.width.toDouble(), descriptor.height.toDouble()));
141141

142142
if (maxSize == null) {
143-
await stows.maxImageSize.waitUntilLoaded();
143+
await stows.maxImageSize.waitUntilRead();
144144
maxSize = Size.square(stows.maxImageSize.value);
145145
}
146146
final Size reducedSize = EditorImage.resize(naturalSize, maxSize!);

lib/components/settings/update_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class UpdateManager {
3838
if (!userTriggered) {
3939
if (status.value == UpdateStatus.upToDate) {
4040
// check for updates if not already done
41-
await stows.shouldCheckForUpdates.waitUntilLoaded();
41+
await stows.shouldCheckForUpdates.waitUntilRead();
4242
if (!stows.shouldCheckForUpdates.value) return;
4343
status.value = await _checkForUpdate();
4444
}

lib/data/editor/pencil_sound.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class PencilSound {
2424
/// Loads the audio file into the audio cache
2525
/// and sets the audio context.
2626
static Future<void> preload() => Future.wait([
27-
stows.pencilSound.waitUntilLoaded().then((_) => setAudioContext()),
27+
stows.pencilSound.waitUntilRead().then((_) => setAudioContext()),
2828
_player.audioCache.loadPath(_source),
2929
]);
3030

lib/data/file_manager/file_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ class FileManager {
586586
}
587587

588588
static Future<List<String>> getRecentlyAccessed() async {
589-
await stows.recentFiles.waitUntilLoaded();
589+
await stows.recentFiles.waitUntilRead();
590590
return stows.recentFiles.value
591591
.map((String filePath) {
592592
if (filePath.endsWith(Editor.extension)) {

lib/data/nextcloud/nc_http_overrides.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class NcHttpOverrides extends HttpOverrides {
2828
X509Certificate cert, String host, int port) {
2929
if (!stows.allowInsecureConnections.loaded || !stows.url.loaded) {
3030
log.severe(
31-
'The Prefs [allowInsecureConnections] or [url] are not loaded yet. Make sure to await pref.waitUntilLoaded() for both.');
31+
'The Prefs [allowInsecureConnections] or [url] are not loaded yet. Make sure to await pref.waitUntilRead() for both.');
3232
return false;
3333
}
3434

lib/data/prefs.dart

Lines changed: 307 additions & 397 deletions
Large diffs are not rendered by default.

lib/main_common.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ Future<void> main(
6868
Stows.markAsOnMainIsolate();
6969

7070
await Future.wait([
71-
stows.customDataDir.waitUntilLoaded().then((_) => FileManager.init()),
71+
stows.customDataDir.waitUntilRead().then((_) => FileManager.init()),
7272
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS)
7373
windowManager.ensureInitialized(),
7474
workerManager.init(),
75-
stows.locale.waitUntilLoaded(),
76-
stows.url.waitUntilLoaded(),
77-
stows.allowInsecureConnections.waitUntilLoaded(),
75+
stows.locale.waitUntilRead(),
76+
stows.url.waitUntilRead(),
77+
stows.allowInsecureConnections.waitUntilRead(),
7878
PencilShader.init(),
7979
PencilSound.preload(),
8080
Printing.info().then((info) {
@@ -106,8 +106,8 @@ Future<void> main(
106106
}
107107

108108
void startSyncAfterLoaded() async {
109-
await stows.username.waitUntilLoaded();
110-
await stows.encPassword.waitUntilLoaded();
109+
await stows.username.waitUntilRead();
110+
await stows.encPassword.waitUntilRead();
111111

112112
stows.username.removeListener(startSyncAfterLoaded);
113113
stows.encPassword.removeListener(startSyncAfterLoaded);
@@ -174,8 +174,8 @@ void doBackgroundSync() {
174174
await Future.wait([
175175
FileManager.init(),
176176
workerManager.init(),
177-
stows.url.waitUntilLoaded(),
178-
stows.allowInsecureConnections.waitUntilLoaded(),
177+
stows.url.waitUntilRead(),
178+
stows.allowInsecureConnections.waitUntilRead(),
179179
]);
180180

181181
/// Only sync a few files to avoid using too much data/battery

lib/pages/user/login.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ class _NcLoginPageState extends State<NcLoginPage> {
6464
!stows.key.loaded ||
6565
!stows.iv.loaded)
6666
await Future.wait([
67-
stows.url.waitUntilLoaded(),
68-
stows.username.waitUntilLoaded(),
69-
stows.ncPassword.waitUntilLoaded(),
70-
stows.encPassword.waitUntilLoaded(),
71-
stows.key.waitUntilLoaded(),
72-
stows.iv.waitUntilLoaded(),
67+
stows.url.waitUntilRead(),
68+
stows.username.waitUntilRead(),
69+
stows.ncPassword.waitUntilRead(),
70+
stows.encPassword.waitUntilRead(),
71+
stows.key.waitUntilRead(),
72+
stows.iv.waitUntilRead(),
7373
]);
7474

7575
recheckCurrentStep();

pubspec.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,38 @@ packages:
15621562
url: "https://pub.dev"
15631563
source: hosted
15641564
version: "1.12.1"
1565+
stow:
1566+
dependency: "direct main"
1567+
description:
1568+
name: stow
1569+
sha256: a22979ca8f484123e6b1eeea5a46c3bbda31cc31db7308cd90f69daeda1cdd90
1570+
url: "https://pub.dev"
1571+
source: hosted
1572+
version: "0.2.0"
1573+
stow_codecs:
1574+
dependency: "direct main"
1575+
description:
1576+
name: stow_codecs
1577+
sha256: "08d159ff080729135bbf1036cceaecba553387018e083102fc966256f2f74557"
1578+
url: "https://pub.dev"
1579+
source: hosted
1580+
version: "1.1.1"
1581+
stow_plain:
1582+
dependency: "direct main"
1583+
description:
1584+
name: stow_plain
1585+
sha256: "59127f21e5f92e35b48e06471495c8c6762f72afc3252c1151c2f88dd0d9b8ef"
1586+
url: "https://pub.dev"
1587+
source: hosted
1588+
version: "0.2.0"
1589+
stow_secure:
1590+
dependency: "direct main"
1591+
description:
1592+
name: stow_secure
1593+
sha256: "6c498d4f762619418f7e625d17b8382141a1656a57516b485ff4e0e54bc813ea"
1594+
url: "https://pub.dev"
1595+
source: hosted
1596+
version: "0.2.0"
15651597
stream_channel:
15661598
dependency: transitive
15671599
description:

pubspec.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ dependencies:
146146
pdfrx: ^1.0.85
147147
path: ^1.9.1
148148

149+
stow: ^0.2.0
150+
stow_plain: ^0.2.0
151+
stow_secure: ^0.2.0
152+
stow_codecs: ^1.1.0
153+
149154
dev_dependencies:
150155
flutter_test:
151156
sdk: flutter

test/prefs_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void main() {
4848
SharedPreferences.setMockInitialValues({});
4949

5050
IPref<int> intPref = PlainPref('testTransformedPref', 0);
51-
await intPref.waitUntilLoaded();
51+
await intPref.waitUntilRead();
5252

5353
/// Transforms intPref's value to a bool
5454
TransformedPref<int, bool> boolPref = TransformedPref(
@@ -101,7 +101,7 @@ Future testPref<T>({
101101

102102
// Delete pref if it already exists
103103
var pref = prefBuilder();
104-
await pref.waitUntilLoaded();
104+
await pref.waitUntilRead();
105105
await pref.delete();
106106

107107
// Check that pref.delete() is idempotent (doesn't throw an error)
@@ -120,7 +120,7 @@ Future testPref<T>({
120120
expect(pref.value, defaultValue);
121121
expect(prefChanged, false);
122122

123-
await pref.waitUntilLoaded();
123+
await pref.waitUntilRead();
124124
expect(pref.loaded, true);
125125
expect(pref.value, defaultValue);
126126
expect(prefChanged, false);
@@ -139,7 +139,7 @@ Future testPref<T>({
139139
pref = prefBuilder();
140140
expect(pref.loaded, false);
141141
expect(pref.value, defaultValue);
142-
await pref.waitUntilLoaded();
142+
await pref.waitUntilRead();
143143
expect(pref.loaded, true);
144144
if (useJson) {
145145
expect(json.encode(pref.value), json.encode(alteredValue));

0 commit comments

Comments
 (0)