Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/supabase-todolist/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions demos/supabase-todolist/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -45,4 +45,4 @@ post_install do |installer|
end
end
end
end
end
12 changes: 6 additions & 6 deletions demos/supabase-todolist/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875
camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqlite3: 6e2d4a4879854d0ec86b476bf3c3e30870bac273
sqlite3_flutter_libs: eb769059df0356dc52ddda040f09cacc9391a7cf
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812

PODFILE CHECKSUM: adb9c9fb405cdaf8ac7cbd45ad6db78acaa58c33
PODFILE CHECKSUM: 13e359f40c4925bcdf0c1bfa13aeba35011fde30

COCOAPODS: 1.14.3
6 changes: 3 additions & 3 deletions demos/supabase-todolist/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -419,7 +419,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -468,7 +468,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
3 changes: 2 additions & 1 deletion demos/supabase-todolist/lib/models/schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ Schema schema = Schema(([
Column.text('name'),
Column.text('owner_id')
]),
AttachmentsQueueTable()
AttachmentsQueueTable(
attachmentsQueueTableName: defaultAttachmentsQueueTableName)
]));
2 changes: 1 addition & 1 deletion demos/supabase-todolist/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ packages:
path: "../../packages/powersync_attachments_helper"
relative: true
source: path
version: "0.1.5"
version: "0.2.0"
realtime_client:
dependency: transitive
description:
Expand Down
7 changes: 6 additions & 1 deletion packages/powersync_attachments_helper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## 0.2.0

- Potentially BREAKING CHANGE for users who rely on multiple attachment queues.
Moved away from randomly generating queue table name in favour of a user creating a queue and table using a name of their choosing.

## 0.1.5

- Allow different file extensions besides jpg
- Allow different file extensions besides jpg.

## 0.1.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ library;
export 'src/attachments_queue.dart';
export 'src/remote_storage_adapter.dart' show AbstractRemoteStorageAdapter;
export 'src/attachments_queue_table.dart'
show Attachment, AttachmentState, AttachmentsQueueTable;
show
Attachment,
AttachmentState,
AttachmentsQueueTable,
defaultAttachmentsQueueTableName;
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ abstract class AbstractAttachmentQueue {
late AttachmentsService attachmentsService;
late SyncingService syncingService;
final LocalStorageAdapter localStorage = LocalStorageAdapter();
String attachmentsQueueTableName;

AbstractAttachmentQueue(
{required this.db,
required this.remoteStorage,
this.attachmentDirectoryName = 'attachments',
this.attachmentsQueueTableName = defaultAttachmentsQueueTableName,
performInitialSync = true}) {
attachmentsService =
AttachmentsService(db, localStorage, attachmentDirectoryName);
attachmentsService = AttachmentsService(
db, localStorage, attachmentDirectoryName, attachmentsQueueTableName);
syncingService = SyncingService(
db, remoteStorage, localStorage, attachmentsService, getLocalUri);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:powersync/powersync.dart';
import 'package:powersync/sqlite3.dart' as sqlite;
import 'dart:math';

/// Global reference to the attachment queue table
final String attachmentsQueueTable = 'queue_${_getRandomString(6)}';
const defaultAttachmentsQueueTableName = 'attachments_queue';

/// Class used to create the attachment queue table
/// The table is local only and will not be visible in the remote database
Expand Down Expand Up @@ -74,11 +72,12 @@ enum AttachmentState {

class AttachmentsQueueTable extends Table {
AttachmentsQueueTable(
{List<Column> additionalColumns = const [],
{String attachmentsQueueTableName = defaultAttachmentsQueueTableName,
List<Column> additionalColumns = const [],
List<Index> indexes = const [],
String? viewName})
: super.localOnly(
attachmentsQueueTable,
attachmentsQueueTableName,
[
const Column.text('filename'),
const Column.text('local_uri'),
Expand All @@ -91,9 +90,3 @@ class AttachmentsQueueTable extends Table {
viewName: viewName,
indexes: indexes);
}

const _chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
Random _rnd = Random();

String _getRandomString(int length) => String.fromCharCodes(Iterable.generate(
length, (_) => _chars.codeUnitAt(_rnd.nextInt(_chars.length))));
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class AttachmentsService {
final PowerSyncDatabase db;
final LocalStorageAdapter localStorage;
final String attachmentDirectoryName;
final String attachmentsQueueTableName;

AttachmentsService(this.db, this.localStorage, this.attachmentDirectoryName);
AttachmentsService(this.db, this.localStorage, this.attachmentDirectoryName,
this.attachmentsQueueTableName);

/// Table used for storing attachments in the attachment queue.
get table {
return attachmentsQueueTable;
return attachmentsQueueTableName;
}

/// Delete the attachment from the attachment queue.
Expand Down
2 changes: 1 addition & 1 deletion packages/powersync_attachments_helper/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: powersync_attachments_helper
description: A helper library for handling attachments when using PowerSync.
version: 0.1.5
version: 0.2.0
repository: https://github.com/powersync-ja/powersync.dart
homepage: https://www.powersync.com/
environment:
Expand Down