Skip to content

Attachment package refactor #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dean-journeyapps
Copy link
Contributor

No description provided.

Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments from a quick look.

Also, I assume supabase-todolist-new-attachments was copied from the old one? For a review it would be easier if the changes were in the same project so I can see what has changed. But that can happen in the end.

Comment on lines +5 to +6
export 'src/implementations/attachment_context.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this exporting the implementation?

export 'src/implementations/attachment_service.dart';
export 'src/implementations/attachment_context.dart';
export 'src/abstractions/remote_storage.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already exported by common.dart

Comment on lines +22 to +29
static AttachmentState fromInt(int value) {
if (value < 0 || value >= AttachmentState.values.length) {
throw ArgumentError('Invalid value for AttachmentState: $value');
}
return AttachmentState.values[value];
}

int toInt() => index;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually put these in the enum class itself if you add a semicolon after the last enum member (archived in this case).

/// Class used to implement the attachment queue.
/// Requires a database client, remote storage adapter, and an attachment directory name.
class AttachmentQueue {
final dynamic db;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have to be dynamic?

final Duration syncInterval;
final int archivedCacheLimit;
final Duration syncThrottleDuration;
final List<String>? subdirectories;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need explicit subdirectories or can we make the local storage adapter create subdirectories on demand?

I remember one issue with the previous implementation was that users wanted to create subdirectories based on data (e.g. one directory per list in the standard todolist demo), and that's very inconvenient with a list like this.

Comment on lines +13 to +22
setUp(() async {
tempDir = await Directory.systemTemp.createTemp('local_storage_test_');
storage = IOLocalStorage(tempDir);
});

tearDown(() async {
if (await tempDir.exists()) {
await tempDir.delete(recursive: true);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a requirement , but you can use the test_descriptor which is really convenient when you need each test to operate on an independent directory. It can also be used to assert the state of the file system after some IOLocalStorage operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants