mirror of
https://github.com/immich-app/immich.git
synced 2025-12-14 01:10:38 +03:00
Compare commits
3 Commits
feature/re
...
feat/inlin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
023d2195f9 | ||
|
|
c482bdfae7 | ||
|
|
0dadfc52dd |
2
mobile/drift_schemas/main/drift_schema_v1.json
generated
2
mobile/drift_schemas/main/drift_schema_v1.json
generated
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ const String kSecuredPinCode = "secured_pin_code";
|
|||||||
|
|
||||||
// Timeline constants
|
// Timeline constants
|
||||||
const int kTimelineNoneSegmentSize = 120;
|
const int kTimelineNoneSegmentSize = 120;
|
||||||
const int kTimelineAssetLoadBatchSize = 256;
|
const int kTimelineAssetLoadBatchSize = 1024;
|
||||||
const int kTimelineAssetLoadOppositeSize = 64;
|
const int kTimelineAssetLoadOppositeSize = 64;
|
||||||
|
|
||||||
// Widget keys
|
// Widget keys
|
||||||
|
|||||||
58
mobile/lib/infrastructure/entities/asset_triggers.drift
Normal file
58
mobile/lib/infrastructure/entities/asset_triggers.drift
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import 'remote_asset.entity.dart';
|
||||||
|
import 'local_asset.entity.dart';
|
||||||
|
|
||||||
|
-- TRIGGERS ON local_asset_entity
|
||||||
|
|
||||||
|
-- Find and update the remote_id in local_asset_entity and local_id in remote_asset_entity when checksum is set
|
||||||
|
CREATE TRIGGER IF NOT EXISTS tr_local_asset_update_checksum_set_ids
|
||||||
|
AFTER UPDATE OF checksum ON local_asset_entity
|
||||||
|
FOR EACH ROW
|
||||||
|
WHEN NEW.checksum IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
UPDATE local_asset_entity
|
||||||
|
SET remote_id = (SELECT id FROM remote_asset_entity WHERE checksum = NEW.checksum LIMIT 1)
|
||||||
|
WHERE id = NEW.id;
|
||||||
|
|
||||||
|
UPDATE remote_asset_entity
|
||||||
|
SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = NEW.checksum ORDER BY id ASC LIMIT 1)
|
||||||
|
WHERE checksum = NEW.checksum;
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- When a local asset is updated, relink remote assets that had a checksum match
|
||||||
|
CREATE TRIGGER IF NOT EXISTS tr_local_asset_update_old_checksum_set_remote_asset_local_id
|
||||||
|
AFTER UPDATE OF checksum ON local_asset_entity
|
||||||
|
FOR EACH ROW
|
||||||
|
WHEN OLD.checksum IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
UPDATE remote_asset_entity
|
||||||
|
SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = OLD.checksum ORDER BY id ASC LIMIT 1)
|
||||||
|
WHERE checksum = OLD.checksum;
|
||||||
|
END;
|
||||||
|
|
||||||
|
-- remote_asset_entity.checksum is a 1..* relationship with local_asset_entity.checksum.
|
||||||
|
-- When a local asset is deleted, update remote assets that had a checksum match
|
||||||
|
-- to ensure their local_id is set to the first matching local asset or NULL
|
||||||
|
CREATE TRIGGER IF NOT EXISTS tr_local_asset_delete_update_remote_asset_local_id
|
||||||
|
AFTER DELETE ON local_asset_entity
|
||||||
|
FOR EACH ROW
|
||||||
|
WHEN OLD.checksum IS NOT NULL
|
||||||
|
BEGIN
|
||||||
|
UPDATE remote_asset_entity
|
||||||
|
SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = OLD.checksum ORDER BY id ASC LIMIT 1)
|
||||||
|
WHERE checksum = OLD.checksum;
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
||||||
|
-- TRIGGERS ON remote_asset_entity
|
||||||
|
|
||||||
|
-- Find and update local_id in remote_asset_entity when a new remote asset is inserted
|
||||||
|
CREATE TRIGGER IF NOT EXISTS tr_remote_asset_insert_set_local_id
|
||||||
|
AFTER INSERT ON remote_asset_entity
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE remote_asset_entity
|
||||||
|
SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = NEW.checksum ORDER BY id ASC LIMIT 1)
|
||||||
|
WHERE id = NEW.id;
|
||||||
|
|
||||||
|
UPDATE local_asset_entity SET remote_id = NEW.id WHERE checksum = NEW.checksum;
|
||||||
|
END;
|
||||||
16
mobile/lib/infrastructure/entities/asset_triggers.drift.dart
generated
Normal file
16
mobile/lib/infrastructure/entities/asset_triggers.drift.dart
generated
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// dart format width=80
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
import 'package:drift/drift.dart' as i0;
|
||||||
|
|
||||||
|
i0.Trigger get trLocalAssetUpdateChecksumSetIds => i0.Trigger(
|
||||||
|
'CREATE TRIGGER IF NOT EXISTS tr_local_asset_update_checksum_set_ids AFTER UPDATE OF checksum ON local_asset_entity WHEN NEW.checksum IS NOT NULL BEGIN UPDATE local_asset_entity SET remote_id = (SELECT id FROM remote_asset_entity WHERE checksum = NEW.checksum LIMIT 1) WHERE id = NEW.id;UPDATE remote_asset_entity SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = NEW.checksum ORDER BY id ASC LIMIT 1) WHERE checksum = NEW.checksum;END',
|
||||||
|
'tr_local_asset_update_checksum_set_ids');
|
||||||
|
i0.Trigger get trLocalAssetUpdateOldChecksumSetRemoteAssetLocalId => i0.Trigger(
|
||||||
|
'CREATE TRIGGER IF NOT EXISTS tr_local_asset_update_old_checksum_set_remote_asset_local_id AFTER UPDATE OF checksum ON local_asset_entity WHEN OLD.checksum IS NOT NULL BEGIN UPDATE remote_asset_entity SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = OLD.checksum ORDER BY id ASC LIMIT 1) WHERE checksum = OLD.checksum;END',
|
||||||
|
'tr_local_asset_update_old_checksum_set_remote_asset_local_id');
|
||||||
|
i0.Trigger get trLocalAssetDeleteUpdateRemoteAssetLocalId => i0.Trigger(
|
||||||
|
'CREATE TRIGGER IF NOT EXISTS tr_local_asset_delete_update_remote_asset_local_id AFTER DELETE ON local_asset_entity WHEN OLD.checksum IS NOT NULL BEGIN UPDATE remote_asset_entity SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = OLD.checksum ORDER BY id ASC LIMIT 1) WHERE checksum = OLD.checksum;END',
|
||||||
|
'tr_local_asset_delete_update_remote_asset_local_id');
|
||||||
|
i0.Trigger get trRemoteAssetInsertSetLocalId => i0.Trigger(
|
||||||
|
'CREATE TRIGGER IF NOT EXISTS tr_remote_asset_insert_set_local_id AFTER INSERT ON remote_asset_entity BEGIN UPDATE remote_asset_entity SET local_id = (SELECT id FROM local_asset_entity WHERE checksum = NEW.checksum ORDER BY id ASC LIMIT 1) WHERE id = NEW.id;UPDATE local_asset_entity SET remote_id = NEW.id WHERE checksum = NEW.checksum;END',
|
||||||
|
'tr_remote_asset_insert_set_local_id');
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.drift.dart';
|
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.drift.dart';
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.dart';
|
||||||
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/asset.mixin.dart';
|
||||||
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
import 'package:immich_mobile/infrastructure/utils/drift_default.mixin.dart';
|
||||||
|
|
||||||
@@ -9,6 +10,11 @@ class LocalAssetEntity extends Table with DriftDefaultsMixin, AssetEntityMixin {
|
|||||||
const LocalAssetEntity();
|
const LocalAssetEntity();
|
||||||
|
|
||||||
TextColumn get id => text()();
|
TextColumn get id => text()();
|
||||||
|
|
||||||
|
TextColumn get remoteId => text()
|
||||||
|
.nullable()
|
||||||
|
.references(RemoteAssetEntity, #id, onDelete: KeyAction.setNull)();
|
||||||
|
|
||||||
TextColumn get checksum => text().nullable()();
|
TextColumn get checksum => text().nullable()();
|
||||||
|
|
||||||
// Only used during backup to mirror the favorite status of the asset in the server
|
// Only used during backup to mirror the favorite status of the asset in the server
|
||||||
@@ -30,6 +36,6 @@ extension LocalAssetEntityDataDomainEx on LocalAssetEntityData {
|
|||||||
isFavorite: isFavorite,
|
isFavorite: isFavorite,
|
||||||
height: height,
|
height: height,
|
||||||
width: width,
|
width: width,
|
||||||
remoteId: null,
|
remoteId: remoteId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart' as i2;
|
|||||||
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.dart'
|
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.dart'
|
||||||
as i3;
|
as i3;
|
||||||
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i4;
|
import 'package:drift/src/runtime/query_builder/query_builder.dart' as i4;
|
||||||
|
import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.dart'
|
||||||
|
as i5;
|
||||||
|
import 'package:drift/internal/modular.dart' as i6;
|
||||||
|
|
||||||
typedef $$LocalAssetEntityTableCreateCompanionBuilder
|
typedef $$LocalAssetEntityTableCreateCompanionBuilder
|
||||||
= i1.LocalAssetEntityCompanion Function({
|
= i1.LocalAssetEntityCompanion Function({
|
||||||
@@ -18,6 +21,7 @@ typedef $$LocalAssetEntityTableCreateCompanionBuilder
|
|||||||
i0.Value<int?> height,
|
i0.Value<int?> height,
|
||||||
i0.Value<int?> durationInSeconds,
|
i0.Value<int?> durationInSeconds,
|
||||||
required String id,
|
required String id,
|
||||||
|
i0.Value<String?> remoteId,
|
||||||
i0.Value<String?> checksum,
|
i0.Value<String?> checksum,
|
||||||
i0.Value<bool> isFavorite,
|
i0.Value<bool> isFavorite,
|
||||||
});
|
});
|
||||||
@@ -31,10 +35,43 @@ typedef $$LocalAssetEntityTableUpdateCompanionBuilder
|
|||||||
i0.Value<int?> height,
|
i0.Value<int?> height,
|
||||||
i0.Value<int?> durationInSeconds,
|
i0.Value<int?> durationInSeconds,
|
||||||
i0.Value<String> id,
|
i0.Value<String> id,
|
||||||
|
i0.Value<String?> remoteId,
|
||||||
i0.Value<String?> checksum,
|
i0.Value<String?> checksum,
|
||||||
i0.Value<bool> isFavorite,
|
i0.Value<bool> isFavorite,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final class $$LocalAssetEntityTableReferences extends i0.BaseReferences<
|
||||||
|
i0.GeneratedDatabase, i1.$LocalAssetEntityTable, i1.LocalAssetEntityData> {
|
||||||
|
$$LocalAssetEntityTableReferences(
|
||||||
|
super.$_db, super.$_table, super.$_typedResult);
|
||||||
|
|
||||||
|
static i5.$RemoteAssetEntityTable _remoteIdTable(i0.GeneratedDatabase db) =>
|
||||||
|
i6.ReadDatabaseContainer(db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity')
|
||||||
|
.createAlias(i0.$_aliasNameGenerator(
|
||||||
|
i6.ReadDatabaseContainer(db)
|
||||||
|
.resultSet<i1.$LocalAssetEntityTable>('local_asset_entity')
|
||||||
|
.remoteId,
|
||||||
|
i6.ReadDatabaseContainer(db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity')
|
||||||
|
.id));
|
||||||
|
|
||||||
|
i5.$$RemoteAssetEntityTableProcessedTableManager? get remoteId {
|
||||||
|
final $_column = $_itemColumn<String>('remote_id');
|
||||||
|
if ($_column == null) return null;
|
||||||
|
final manager = i5
|
||||||
|
.$$RemoteAssetEntityTableTableManager(
|
||||||
|
$_db,
|
||||||
|
i6.ReadDatabaseContainer($_db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity'))
|
||||||
|
.filter((f) => f.id.sqlEquals($_column));
|
||||||
|
final item = $_typedResult.readTableOrNull(_remoteIdTable($_db));
|
||||||
|
if (item == null) return manager;
|
||||||
|
return i0.ProcessedTableManager(
|
||||||
|
manager.$state.copyWith(prefetchedData: [item]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class $$LocalAssetEntityTableFilterComposer
|
class $$LocalAssetEntityTableFilterComposer
|
||||||
extends i0.Composer<i0.GeneratedDatabase, i1.$LocalAssetEntityTable> {
|
extends i0.Composer<i0.GeneratedDatabase, i1.$LocalAssetEntityTable> {
|
||||||
$$LocalAssetEntityTableFilterComposer({
|
$$LocalAssetEntityTableFilterComposer({
|
||||||
@@ -76,6 +113,28 @@ class $$LocalAssetEntityTableFilterComposer
|
|||||||
|
|
||||||
i0.ColumnFilters<bool> get isFavorite => $composableBuilder(
|
i0.ColumnFilters<bool> get isFavorite => $composableBuilder(
|
||||||
column: $table.isFavorite, builder: (column) => i0.ColumnFilters(column));
|
column: $table.isFavorite, builder: (column) => i0.ColumnFilters(column));
|
||||||
|
|
||||||
|
i5.$$RemoteAssetEntityTableFilterComposer get remoteId {
|
||||||
|
final i5.$$RemoteAssetEntityTableFilterComposer composer = $composerBuilder(
|
||||||
|
composer: this,
|
||||||
|
getCurrentColumn: (t) => t.remoteId,
|
||||||
|
referencedTable: i6.ReadDatabaseContainer($db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity'),
|
||||||
|
getReferencedColumn: (t) => t.id,
|
||||||
|
builder: (joinBuilder,
|
||||||
|
{$addJoinBuilderToRootComposer,
|
||||||
|
$removeJoinBuilderFromRootComposer}) =>
|
||||||
|
i5.$$RemoteAssetEntityTableFilterComposer(
|
||||||
|
$db: $db,
|
||||||
|
$table: i6.ReadDatabaseContainer($db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity'),
|
||||||
|
$addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer,
|
||||||
|
joinBuilder: joinBuilder,
|
||||||
|
$removeJoinBuilderFromRootComposer:
|
||||||
|
$removeJoinBuilderFromRootComposer,
|
||||||
|
));
|
||||||
|
return composer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$LocalAssetEntityTableOrderingComposer
|
class $$LocalAssetEntityTableOrderingComposer
|
||||||
@@ -120,6 +179,30 @@ class $$LocalAssetEntityTableOrderingComposer
|
|||||||
i0.ColumnOrderings<bool> get isFavorite => $composableBuilder(
|
i0.ColumnOrderings<bool> get isFavorite => $composableBuilder(
|
||||||
column: $table.isFavorite,
|
column: $table.isFavorite,
|
||||||
builder: (column) => i0.ColumnOrderings(column));
|
builder: (column) => i0.ColumnOrderings(column));
|
||||||
|
|
||||||
|
i5.$$RemoteAssetEntityTableOrderingComposer get remoteId {
|
||||||
|
final i5.$$RemoteAssetEntityTableOrderingComposer composer =
|
||||||
|
$composerBuilder(
|
||||||
|
composer: this,
|
||||||
|
getCurrentColumn: (t) => t.remoteId,
|
||||||
|
referencedTable: i6.ReadDatabaseContainer($db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity'),
|
||||||
|
getReferencedColumn: (t) => t.id,
|
||||||
|
builder: (joinBuilder,
|
||||||
|
{$addJoinBuilderToRootComposer,
|
||||||
|
$removeJoinBuilderFromRootComposer}) =>
|
||||||
|
i5.$$RemoteAssetEntityTableOrderingComposer(
|
||||||
|
$db: $db,
|
||||||
|
$table: i6.ReadDatabaseContainer($db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>(
|
||||||
|
'remote_asset_entity'),
|
||||||
|
$addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer,
|
||||||
|
joinBuilder: joinBuilder,
|
||||||
|
$removeJoinBuilderFromRootComposer:
|
||||||
|
$removeJoinBuilderFromRootComposer,
|
||||||
|
));
|
||||||
|
return composer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$LocalAssetEntityTableAnnotationComposer
|
class $$LocalAssetEntityTableAnnotationComposer
|
||||||
@@ -160,6 +243,30 @@ class $$LocalAssetEntityTableAnnotationComposer
|
|||||||
|
|
||||||
i0.GeneratedColumn<bool> get isFavorite => $composableBuilder(
|
i0.GeneratedColumn<bool> get isFavorite => $composableBuilder(
|
||||||
column: $table.isFavorite, builder: (column) => column);
|
column: $table.isFavorite, builder: (column) => column);
|
||||||
|
|
||||||
|
i5.$$RemoteAssetEntityTableAnnotationComposer get remoteId {
|
||||||
|
final i5.$$RemoteAssetEntityTableAnnotationComposer composer =
|
||||||
|
$composerBuilder(
|
||||||
|
composer: this,
|
||||||
|
getCurrentColumn: (t) => t.remoteId,
|
||||||
|
referencedTable: i6.ReadDatabaseContainer($db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>('remote_asset_entity'),
|
||||||
|
getReferencedColumn: (t) => t.id,
|
||||||
|
builder: (joinBuilder,
|
||||||
|
{$addJoinBuilderToRootComposer,
|
||||||
|
$removeJoinBuilderFromRootComposer}) =>
|
||||||
|
i5.$$RemoteAssetEntityTableAnnotationComposer(
|
||||||
|
$db: $db,
|
||||||
|
$table: i6.ReadDatabaseContainer($db)
|
||||||
|
.resultSet<i5.$RemoteAssetEntityTable>(
|
||||||
|
'remote_asset_entity'),
|
||||||
|
$addJoinBuilderToRootComposer: $addJoinBuilderToRootComposer,
|
||||||
|
joinBuilder: joinBuilder,
|
||||||
|
$removeJoinBuilderFromRootComposer:
|
||||||
|
$removeJoinBuilderFromRootComposer,
|
||||||
|
));
|
||||||
|
return composer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
||||||
@@ -171,13 +278,9 @@ class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i1.$$LocalAssetEntityTableAnnotationComposer,
|
i1.$$LocalAssetEntityTableAnnotationComposer,
|
||||||
$$LocalAssetEntityTableCreateCompanionBuilder,
|
$$LocalAssetEntityTableCreateCompanionBuilder,
|
||||||
$$LocalAssetEntityTableUpdateCompanionBuilder,
|
$$LocalAssetEntityTableUpdateCompanionBuilder,
|
||||||
(
|
(i1.LocalAssetEntityData, i1.$$LocalAssetEntityTableReferences),
|
||||||
i1.LocalAssetEntityData,
|
i1.LocalAssetEntityData,
|
||||||
i0.BaseReferences<i0.GeneratedDatabase, i1.$LocalAssetEntityTable,
|
i0.PrefetchHooks Function({bool remoteId})> {
|
||||||
i1.LocalAssetEntityData>
|
|
||||||
),
|
|
||||||
i1.LocalAssetEntityData,
|
|
||||||
i0.PrefetchHooks Function()> {
|
|
||||||
$$LocalAssetEntityTableTableManager(
|
$$LocalAssetEntityTableTableManager(
|
||||||
i0.GeneratedDatabase db, i1.$LocalAssetEntityTable table)
|
i0.GeneratedDatabase db, i1.$LocalAssetEntityTable table)
|
||||||
: super(i0.TableManagerState(
|
: super(i0.TableManagerState(
|
||||||
@@ -199,6 +302,7 @@ class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i0.Value<int?> height = const i0.Value.absent(),
|
i0.Value<int?> height = const i0.Value.absent(),
|
||||||
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
||||||
i0.Value<String> id = const i0.Value.absent(),
|
i0.Value<String> id = const i0.Value.absent(),
|
||||||
|
i0.Value<String?> remoteId = const i0.Value.absent(),
|
||||||
i0.Value<String?> checksum = const i0.Value.absent(),
|
i0.Value<String?> checksum = const i0.Value.absent(),
|
||||||
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
||||||
}) =>
|
}) =>
|
||||||
@@ -211,6 +315,7 @@ class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
height: height,
|
height: height,
|
||||||
durationInSeconds: durationInSeconds,
|
durationInSeconds: durationInSeconds,
|
||||||
id: id,
|
id: id,
|
||||||
|
remoteId: remoteId,
|
||||||
checksum: checksum,
|
checksum: checksum,
|
||||||
isFavorite: isFavorite,
|
isFavorite: isFavorite,
|
||||||
),
|
),
|
||||||
@@ -223,6 +328,7 @@ class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i0.Value<int?> height = const i0.Value.absent(),
|
i0.Value<int?> height = const i0.Value.absent(),
|
||||||
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
||||||
required String id,
|
required String id,
|
||||||
|
i0.Value<String?> remoteId = const i0.Value.absent(),
|
||||||
i0.Value<String?> checksum = const i0.Value.absent(),
|
i0.Value<String?> checksum = const i0.Value.absent(),
|
||||||
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
||||||
}) =>
|
}) =>
|
||||||
@@ -235,13 +341,52 @@ class $$LocalAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
height: height,
|
height: height,
|
||||||
durationInSeconds: durationInSeconds,
|
durationInSeconds: durationInSeconds,
|
||||||
id: id,
|
id: id,
|
||||||
|
remoteId: remoteId,
|
||||||
checksum: checksum,
|
checksum: checksum,
|
||||||
isFavorite: isFavorite,
|
isFavorite: isFavorite,
|
||||||
),
|
),
|
||||||
withReferenceMapper: (p0) => p0
|
withReferenceMapper: (p0) => p0
|
||||||
.map((e) => (e.readTable(table), i0.BaseReferences(db, table, e)))
|
.map((e) => (
|
||||||
|
e.readTable(table),
|
||||||
|
i1.$$LocalAssetEntityTableReferences(db, table, e)
|
||||||
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
prefetchHooksCallback: null,
|
prefetchHooksCallback: ({remoteId = false}) {
|
||||||
|
return i0.PrefetchHooks(
|
||||||
|
db: db,
|
||||||
|
explicitlyWatchedTables: [],
|
||||||
|
addJoins: <
|
||||||
|
T extends i0.TableManagerState<
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic,
|
||||||
|
dynamic>>(state) {
|
||||||
|
if (remoteId) {
|
||||||
|
state = state.withJoin(
|
||||||
|
currentTable: table,
|
||||||
|
currentColumn: table.remoteId,
|
||||||
|
referencedTable:
|
||||||
|
i1.$$LocalAssetEntityTableReferences._remoteIdTable(db),
|
||||||
|
referencedColumn: i1.$$LocalAssetEntityTableReferences
|
||||||
|
._remoteIdTable(db)
|
||||||
|
.id,
|
||||||
|
) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
},
|
||||||
|
getPrefetchedDataCallback: (items) async {
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,13 +399,9 @@ typedef $$LocalAssetEntityTableProcessedTableManager = i0.ProcessedTableManager<
|
|||||||
i1.$$LocalAssetEntityTableAnnotationComposer,
|
i1.$$LocalAssetEntityTableAnnotationComposer,
|
||||||
$$LocalAssetEntityTableCreateCompanionBuilder,
|
$$LocalAssetEntityTableCreateCompanionBuilder,
|
||||||
$$LocalAssetEntityTableUpdateCompanionBuilder,
|
$$LocalAssetEntityTableUpdateCompanionBuilder,
|
||||||
(
|
(i1.LocalAssetEntityData, i1.$$LocalAssetEntityTableReferences),
|
||||||
i1.LocalAssetEntityData,
|
i1.LocalAssetEntityData,
|
||||||
i0.BaseReferences<i0.GeneratedDatabase, i1.$LocalAssetEntityTable,
|
i0.PrefetchHooks Function({bool remoteId})>;
|
||||||
i1.LocalAssetEntityData>
|
|
||||||
),
|
|
||||||
i1.LocalAssetEntityData,
|
|
||||||
i0.PrefetchHooks Function()>;
|
|
||||||
i0.Index get idxLocalAssetChecksum => i0.Index('idx_local_asset_checksum',
|
i0.Index get idxLocalAssetChecksum => i0.Index('idx_local_asset_checksum',
|
||||||
'CREATE INDEX idx_local_asset_checksum ON local_asset_entity (checksum)');
|
'CREATE INDEX idx_local_asset_checksum ON local_asset_entity (checksum)');
|
||||||
|
|
||||||
@@ -321,6 +462,15 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity
|
|||||||
late final i0.GeneratedColumn<String> id = i0.GeneratedColumn<String>(
|
late final i0.GeneratedColumn<String> id = i0.GeneratedColumn<String>(
|
||||||
'id', aliasedName, false,
|
'id', aliasedName, false,
|
||||||
type: i0.DriftSqlType.string, requiredDuringInsert: true);
|
type: i0.DriftSqlType.string, requiredDuringInsert: true);
|
||||||
|
static const i0.VerificationMeta _remoteIdMeta =
|
||||||
|
const i0.VerificationMeta('remoteId');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<String> remoteId = i0.GeneratedColumn<String>(
|
||||||
|
'remote_id', aliasedName, true,
|
||||||
|
type: i0.DriftSqlType.string,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
defaultConstraints: i0.GeneratedColumn.constraintIsAlways(
|
||||||
|
'REFERENCES remote_asset_entity (id) ON DELETE SET NULL'));
|
||||||
static const i0.VerificationMeta _checksumMeta =
|
static const i0.VerificationMeta _checksumMeta =
|
||||||
const i0.VerificationMeta('checksum');
|
const i0.VerificationMeta('checksum');
|
||||||
@override
|
@override
|
||||||
@@ -347,6 +497,7 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity
|
|||||||
height,
|
height,
|
||||||
durationInSeconds,
|
durationInSeconds,
|
||||||
id,
|
id,
|
||||||
|
remoteId,
|
||||||
checksum,
|
checksum,
|
||||||
isFavorite
|
isFavorite
|
||||||
];
|
];
|
||||||
@@ -394,6 +545,10 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity
|
|||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_idMeta);
|
context.missing(_idMeta);
|
||||||
}
|
}
|
||||||
|
if (data.containsKey('remote_id')) {
|
||||||
|
context.handle(_remoteIdMeta,
|
||||||
|
remoteId.isAcceptableOrUnknown(data['remote_id']!, _remoteIdMeta));
|
||||||
|
}
|
||||||
if (data.containsKey('checksum')) {
|
if (data.containsKey('checksum')) {
|
||||||
context.handle(_checksumMeta,
|
context.handle(_checksumMeta,
|
||||||
checksum.isAcceptableOrUnknown(data['checksum']!, _checksumMeta));
|
checksum.isAcceptableOrUnknown(data['checksum']!, _checksumMeta));
|
||||||
@@ -431,6 +586,8 @@ class $LocalAssetEntityTable extends i3.LocalAssetEntity
|
|||||||
i0.DriftSqlType.int, data['${effectivePrefix}duration_in_seconds']),
|
i0.DriftSqlType.int, data['${effectivePrefix}duration_in_seconds']),
|
||||||
id: attachedDatabase.typeMapping
|
id: attachedDatabase.typeMapping
|
||||||
.read(i0.DriftSqlType.string, data['${effectivePrefix}id'])!,
|
.read(i0.DriftSqlType.string, data['${effectivePrefix}id'])!,
|
||||||
|
remoteId: attachedDatabase.typeMapping
|
||||||
|
.read(i0.DriftSqlType.string, data['${effectivePrefix}remote_id']),
|
||||||
checksum: attachedDatabase.typeMapping
|
checksum: attachedDatabase.typeMapping
|
||||||
.read(i0.DriftSqlType.string, data['${effectivePrefix}checksum']),
|
.read(i0.DriftSqlType.string, data['${effectivePrefix}checksum']),
|
||||||
isFavorite: attachedDatabase.typeMapping
|
isFavorite: attachedDatabase.typeMapping
|
||||||
@@ -461,6 +618,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
final int? height;
|
final int? height;
|
||||||
final int? durationInSeconds;
|
final int? durationInSeconds;
|
||||||
final String id;
|
final String id;
|
||||||
|
final String? remoteId;
|
||||||
final String? checksum;
|
final String? checksum;
|
||||||
final bool isFavorite;
|
final bool isFavorite;
|
||||||
const LocalAssetEntityData(
|
const LocalAssetEntityData(
|
||||||
@@ -472,6 +630,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
this.height,
|
this.height,
|
||||||
this.durationInSeconds,
|
this.durationInSeconds,
|
||||||
required this.id,
|
required this.id,
|
||||||
|
this.remoteId,
|
||||||
this.checksum,
|
this.checksum,
|
||||||
required this.isFavorite});
|
required this.isFavorite});
|
||||||
@override
|
@override
|
||||||
@@ -494,6 +653,9 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
map['duration_in_seconds'] = i0.Variable<int>(durationInSeconds);
|
map['duration_in_seconds'] = i0.Variable<int>(durationInSeconds);
|
||||||
}
|
}
|
||||||
map['id'] = i0.Variable<String>(id);
|
map['id'] = i0.Variable<String>(id);
|
||||||
|
if (!nullToAbsent || remoteId != null) {
|
||||||
|
map['remote_id'] = i0.Variable<String>(remoteId);
|
||||||
|
}
|
||||||
if (!nullToAbsent || checksum != null) {
|
if (!nullToAbsent || checksum != null) {
|
||||||
map['checksum'] = i0.Variable<String>(checksum);
|
map['checksum'] = i0.Variable<String>(checksum);
|
||||||
}
|
}
|
||||||
@@ -514,6 +676,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
height: serializer.fromJson<int?>(json['height']),
|
height: serializer.fromJson<int?>(json['height']),
|
||||||
durationInSeconds: serializer.fromJson<int?>(json['durationInSeconds']),
|
durationInSeconds: serializer.fromJson<int?>(json['durationInSeconds']),
|
||||||
id: serializer.fromJson<String>(json['id']),
|
id: serializer.fromJson<String>(json['id']),
|
||||||
|
remoteId: serializer.fromJson<String?>(json['remoteId']),
|
||||||
checksum: serializer.fromJson<String?>(json['checksum']),
|
checksum: serializer.fromJson<String?>(json['checksum']),
|
||||||
isFavorite: serializer.fromJson<bool>(json['isFavorite']),
|
isFavorite: serializer.fromJson<bool>(json['isFavorite']),
|
||||||
);
|
);
|
||||||
@@ -531,6 +694,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
'height': serializer.toJson<int?>(height),
|
'height': serializer.toJson<int?>(height),
|
||||||
'durationInSeconds': serializer.toJson<int?>(durationInSeconds),
|
'durationInSeconds': serializer.toJson<int?>(durationInSeconds),
|
||||||
'id': serializer.toJson<String>(id),
|
'id': serializer.toJson<String>(id),
|
||||||
|
'remoteId': serializer.toJson<String?>(remoteId),
|
||||||
'checksum': serializer.toJson<String?>(checksum),
|
'checksum': serializer.toJson<String?>(checksum),
|
||||||
'isFavorite': serializer.toJson<bool>(isFavorite),
|
'isFavorite': serializer.toJson<bool>(isFavorite),
|
||||||
};
|
};
|
||||||
@@ -545,6 +709,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
i0.Value<int?> height = const i0.Value.absent(),
|
i0.Value<int?> height = const i0.Value.absent(),
|
||||||
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
||||||
String? id,
|
String? id,
|
||||||
|
i0.Value<String?> remoteId = const i0.Value.absent(),
|
||||||
i0.Value<String?> checksum = const i0.Value.absent(),
|
i0.Value<String?> checksum = const i0.Value.absent(),
|
||||||
bool? isFavorite}) =>
|
bool? isFavorite}) =>
|
||||||
i1.LocalAssetEntityData(
|
i1.LocalAssetEntityData(
|
||||||
@@ -558,6 +723,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
? durationInSeconds.value
|
? durationInSeconds.value
|
||||||
: this.durationInSeconds,
|
: this.durationInSeconds,
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
remoteId: remoteId.present ? remoteId.value : this.remoteId,
|
||||||
checksum: checksum.present ? checksum.value : this.checksum,
|
checksum: checksum.present ? checksum.value : this.checksum,
|
||||||
isFavorite: isFavorite ?? this.isFavorite,
|
isFavorite: isFavorite ?? this.isFavorite,
|
||||||
);
|
);
|
||||||
@@ -573,6 +739,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
? data.durationInSeconds.value
|
? data.durationInSeconds.value
|
||||||
: this.durationInSeconds,
|
: this.durationInSeconds,
|
||||||
id: data.id.present ? data.id.value : this.id,
|
id: data.id.present ? data.id.value : this.id,
|
||||||
|
remoteId: data.remoteId.present ? data.remoteId.value : this.remoteId,
|
||||||
checksum: data.checksum.present ? data.checksum.value : this.checksum,
|
checksum: data.checksum.present ? data.checksum.value : this.checksum,
|
||||||
isFavorite:
|
isFavorite:
|
||||||
data.isFavorite.present ? data.isFavorite.value : this.isFavorite,
|
data.isFavorite.present ? data.isFavorite.value : this.isFavorite,
|
||||||
@@ -590,6 +757,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
..write('height: $height, ')
|
..write('height: $height, ')
|
||||||
..write('durationInSeconds: $durationInSeconds, ')
|
..write('durationInSeconds: $durationInSeconds, ')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
|
..write('remoteId: $remoteId, ')
|
||||||
..write('checksum: $checksum, ')
|
..write('checksum: $checksum, ')
|
||||||
..write('isFavorite: $isFavorite')
|
..write('isFavorite: $isFavorite')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
@@ -598,7 +766,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(name, type, createdAt, updatedAt, width,
|
int get hashCode => Object.hash(name, type, createdAt, updatedAt, width,
|
||||||
height, durationInSeconds, id, checksum, isFavorite);
|
height, durationInSeconds, id, remoteId, checksum, isFavorite);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
@@ -611,6 +779,7 @@ class LocalAssetEntityData extends i0.DataClass
|
|||||||
other.height == this.height &&
|
other.height == this.height &&
|
||||||
other.durationInSeconds == this.durationInSeconds &&
|
other.durationInSeconds == this.durationInSeconds &&
|
||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
|
other.remoteId == this.remoteId &&
|
||||||
other.checksum == this.checksum &&
|
other.checksum == this.checksum &&
|
||||||
other.isFavorite == this.isFavorite);
|
other.isFavorite == this.isFavorite);
|
||||||
}
|
}
|
||||||
@@ -625,6 +794,7 @@ class LocalAssetEntityCompanion
|
|||||||
final i0.Value<int?> height;
|
final i0.Value<int?> height;
|
||||||
final i0.Value<int?> durationInSeconds;
|
final i0.Value<int?> durationInSeconds;
|
||||||
final i0.Value<String> id;
|
final i0.Value<String> id;
|
||||||
|
final i0.Value<String?> remoteId;
|
||||||
final i0.Value<String?> checksum;
|
final i0.Value<String?> checksum;
|
||||||
final i0.Value<bool> isFavorite;
|
final i0.Value<bool> isFavorite;
|
||||||
const LocalAssetEntityCompanion({
|
const LocalAssetEntityCompanion({
|
||||||
@@ -636,6 +806,7 @@ class LocalAssetEntityCompanion
|
|||||||
this.height = const i0.Value.absent(),
|
this.height = const i0.Value.absent(),
|
||||||
this.durationInSeconds = const i0.Value.absent(),
|
this.durationInSeconds = const i0.Value.absent(),
|
||||||
this.id = const i0.Value.absent(),
|
this.id = const i0.Value.absent(),
|
||||||
|
this.remoteId = const i0.Value.absent(),
|
||||||
this.checksum = const i0.Value.absent(),
|
this.checksum = const i0.Value.absent(),
|
||||||
this.isFavorite = const i0.Value.absent(),
|
this.isFavorite = const i0.Value.absent(),
|
||||||
});
|
});
|
||||||
@@ -648,6 +819,7 @@ class LocalAssetEntityCompanion
|
|||||||
this.height = const i0.Value.absent(),
|
this.height = const i0.Value.absent(),
|
||||||
this.durationInSeconds = const i0.Value.absent(),
|
this.durationInSeconds = const i0.Value.absent(),
|
||||||
required String id,
|
required String id,
|
||||||
|
this.remoteId = const i0.Value.absent(),
|
||||||
this.checksum = const i0.Value.absent(),
|
this.checksum = const i0.Value.absent(),
|
||||||
this.isFavorite = const i0.Value.absent(),
|
this.isFavorite = const i0.Value.absent(),
|
||||||
}) : name = i0.Value(name),
|
}) : name = i0.Value(name),
|
||||||
@@ -662,6 +834,7 @@ class LocalAssetEntityCompanion
|
|||||||
i0.Expression<int>? height,
|
i0.Expression<int>? height,
|
||||||
i0.Expression<int>? durationInSeconds,
|
i0.Expression<int>? durationInSeconds,
|
||||||
i0.Expression<String>? id,
|
i0.Expression<String>? id,
|
||||||
|
i0.Expression<String>? remoteId,
|
||||||
i0.Expression<String>? checksum,
|
i0.Expression<String>? checksum,
|
||||||
i0.Expression<bool>? isFavorite,
|
i0.Expression<bool>? isFavorite,
|
||||||
}) {
|
}) {
|
||||||
@@ -674,6 +847,7 @@ class LocalAssetEntityCompanion
|
|||||||
if (height != null) 'height': height,
|
if (height != null) 'height': height,
|
||||||
if (durationInSeconds != null) 'duration_in_seconds': durationInSeconds,
|
if (durationInSeconds != null) 'duration_in_seconds': durationInSeconds,
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
|
if (remoteId != null) 'remote_id': remoteId,
|
||||||
if (checksum != null) 'checksum': checksum,
|
if (checksum != null) 'checksum': checksum,
|
||||||
if (isFavorite != null) 'is_favorite': isFavorite,
|
if (isFavorite != null) 'is_favorite': isFavorite,
|
||||||
});
|
});
|
||||||
@@ -688,6 +862,7 @@ class LocalAssetEntityCompanion
|
|||||||
i0.Value<int?>? height,
|
i0.Value<int?>? height,
|
||||||
i0.Value<int?>? durationInSeconds,
|
i0.Value<int?>? durationInSeconds,
|
||||||
i0.Value<String>? id,
|
i0.Value<String>? id,
|
||||||
|
i0.Value<String?>? remoteId,
|
||||||
i0.Value<String?>? checksum,
|
i0.Value<String?>? checksum,
|
||||||
i0.Value<bool>? isFavorite}) {
|
i0.Value<bool>? isFavorite}) {
|
||||||
return i1.LocalAssetEntityCompanion(
|
return i1.LocalAssetEntityCompanion(
|
||||||
@@ -699,6 +874,7 @@ class LocalAssetEntityCompanion
|
|||||||
height: height ?? this.height,
|
height: height ?? this.height,
|
||||||
durationInSeconds: durationInSeconds ?? this.durationInSeconds,
|
durationInSeconds: durationInSeconds ?? this.durationInSeconds,
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
remoteId: remoteId ?? this.remoteId,
|
||||||
checksum: checksum ?? this.checksum,
|
checksum: checksum ?? this.checksum,
|
||||||
isFavorite: isFavorite ?? this.isFavorite,
|
isFavorite: isFavorite ?? this.isFavorite,
|
||||||
);
|
);
|
||||||
@@ -732,6 +908,9 @@ class LocalAssetEntityCompanion
|
|||||||
if (id.present) {
|
if (id.present) {
|
||||||
map['id'] = i0.Variable<String>(id.value);
|
map['id'] = i0.Variable<String>(id.value);
|
||||||
}
|
}
|
||||||
|
if (remoteId.present) {
|
||||||
|
map['remote_id'] = i0.Variable<String>(remoteId.value);
|
||||||
|
}
|
||||||
if (checksum.present) {
|
if (checksum.present) {
|
||||||
map['checksum'] = i0.Variable<String>(checksum.value);
|
map['checksum'] = i0.Variable<String>(checksum.value);
|
||||||
}
|
}
|
||||||
@@ -752,6 +931,7 @@ class LocalAssetEntityCompanion
|
|||||||
..write('height: $height, ')
|
..write('height: $height, ')
|
||||||
..write('durationInSeconds: $durationInSeconds, ')
|
..write('durationInSeconds: $durationInSeconds, ')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
|
..write('remoteId: $remoteId, ')
|
||||||
..write('checksum: $checksum, ')
|
..write('checksum: $checksum, ')
|
||||||
..write('isFavorite: $isFavorite')
|
..write('isFavorite: $isFavorite')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ mergedAsset: SELECT * FROM
|
|||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
rae.id as remote_id,
|
rae.id as remote_id,
|
||||||
lae.id as local_id,
|
rae.local_id as local_id,
|
||||||
rae.name,
|
rae.name,
|
||||||
rae."type",
|
rae."type",
|
||||||
rae.created_at,
|
rae.created_at,
|
||||||
@@ -19,13 +19,11 @@ mergedAsset: SELECT * FROM
|
|||||||
rae.owner_id
|
rae.owner_id
|
||||||
FROM
|
FROM
|
||||||
remote_asset_entity rae
|
remote_asset_entity rae
|
||||||
LEFT JOIN
|
|
||||||
local_asset_entity lae ON rae.checksum = lae.checksum
|
|
||||||
WHERE
|
WHERE
|
||||||
rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id in ?
|
rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id in ?
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
NULL as remote_id,
|
lae.remote_id as remote_id,
|
||||||
lae.id as local_id,
|
lae.id as local_id,
|
||||||
lae.name,
|
lae.name,
|
||||||
lae."type",
|
lae."type",
|
||||||
@@ -40,10 +38,8 @@ mergedAsset: SELECT * FROM
|
|||||||
NULL as owner_id
|
NULL as owner_id
|
||||||
FROM
|
FROM
|
||||||
local_asset_entity lae
|
local_asset_entity lae
|
||||||
LEFT JOIN
|
|
||||||
remote_asset_entity rae ON rae.checksum = lae.checksum
|
|
||||||
WHERE
|
WHERE
|
||||||
rae.id IS NULL
|
lae.remote_id IS NULL
|
||||||
)
|
)
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT $limit;
|
LIMIT $limit;
|
||||||
@@ -62,8 +58,6 @@ FROM
|
|||||||
rae.created_at
|
rae.created_at
|
||||||
FROM
|
FROM
|
||||||
remote_asset_entity rae
|
remote_asset_entity rae
|
||||||
LEFT JOIN
|
|
||||||
local_asset_entity lae ON rae.checksum = lae.checksum
|
|
||||||
WHERE
|
WHERE
|
||||||
rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id in ?
|
rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id in ?
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@@ -72,10 +66,8 @@ FROM
|
|||||||
lae.created_at
|
lae.created_at
|
||||||
FROM
|
FROM
|
||||||
local_asset_entity lae
|
local_asset_entity lae
|
||||||
LEFT JOIN
|
|
||||||
remote_asset_entity rae ON rae.checksum = lae.checksum
|
|
||||||
WHERE
|
WHERE
|
||||||
rae.id IS NULL
|
lae.remote_id IS NULL
|
||||||
)
|
)
|
||||||
GROUP BY bucket_date
|
GROUP BY bucket_date
|
||||||
ORDER BY bucket_date DESC;
|
ORDER BY bucket_date DESC;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class MergedAssetDrift extends i1.ModularAccessor {
|
|||||||
final generatedlimit = $write(limit, startIndex: $arrayStartIndex);
|
final generatedlimit = $write(limit, startIndex: $arrayStartIndex);
|
||||||
$arrayStartIndex += generatedlimit.amountOfVariables;
|
$arrayStartIndex += generatedlimit.amountOfVariables;
|
||||||
return customSelect(
|
return customSelect(
|
||||||
'SELECT * FROM (SELECT rae.id AS remote_id, lae.id AS local_id, rae.name, rae.type, rae.created_at, rae.updated_at, rae.width, rae.height, rae.duration_in_seconds, rae.is_favorite, rae.thumb_hash, rae.checksum, rae.owner_id FROM remote_asset_entity AS rae LEFT JOIN local_asset_entity AS lae ON rae.checksum = lae.checksum WHERE rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id IN ($expandedvar1) UNION ALL SELECT NULL AS remote_id, lae.id AS local_id, lae.name, lae.type, lae.created_at, lae.updated_at, lae.width, lae.height, lae.duration_in_seconds, lae.is_favorite, NULL AS thumb_hash, lae.checksum, NULL AS owner_id FROM local_asset_entity AS lae LEFT JOIN remote_asset_entity AS rae ON rae.checksum = lae.checksum WHERE rae.id IS NULL) ORDER BY created_at DESC ${generatedlimit.sql}',
|
'SELECT * FROM (SELECT rae.id AS remote_id, rae.local_id AS local_id, rae.name, rae.type, rae.created_at, rae.updated_at, rae.width, rae.height, rae.duration_in_seconds, rae.is_favorite, rae.thumb_hash, rae.checksum, rae.owner_id FROM remote_asset_entity AS rae WHERE rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id IN ($expandedvar1) UNION ALL SELECT lae.remote_id AS remote_id, lae.id AS local_id, lae.name, lae.type, lae.created_at, lae.updated_at, lae.width, lae.height, lae.duration_in_seconds, lae.is_favorite, NULL AS thumb_hash, lae.checksum, NULL AS owner_id FROM local_asset_entity AS lae WHERE lae.remote_id IS NULL) ORDER BY created_at DESC ${generatedlimit.sql}',
|
||||||
variables: [
|
variables: [
|
||||||
for (var $ in var1) i0.Variable<String>($),
|
for (var $ in var1) i0.Variable<String>($),
|
||||||
...generatedlimit.introducedVariables
|
...generatedlimit.introducedVariables
|
||||||
@@ -51,7 +51,7 @@ class MergedAssetDrift extends i1.ModularAccessor {
|
|||||||
final expandedvar2 = $expandVar($arrayStartIndex, var2.length);
|
final expandedvar2 = $expandVar($arrayStartIndex, var2.length);
|
||||||
$arrayStartIndex += var2.length;
|
$arrayStartIndex += var2.length;
|
||||||
return customSelect(
|
return customSelect(
|
||||||
'SELECT COUNT(*) AS asset_count, CASE WHEN ?1 = 0 THEN STRFTIME(\'%Y-%m-%d\', created_at, \'localtime\') WHEN ?1 = 1 THEN STRFTIME(\'%Y-%m\', created_at, \'localtime\') END AS bucket_date FROM (SELECT rae.name, rae.created_at FROM remote_asset_entity AS rae LEFT JOIN local_asset_entity AS lae ON rae.checksum = lae.checksum WHERE rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id IN ($expandedvar2) UNION ALL SELECT lae.name, lae.created_at FROM local_asset_entity AS lae LEFT JOIN remote_asset_entity AS rae ON rae.checksum = lae.checksum WHERE rae.id IS NULL) GROUP BY bucket_date ORDER BY bucket_date DESC',
|
'SELECT COUNT(*) AS asset_count, CASE WHEN ?1 = 0 THEN STRFTIME(\'%Y-%m-%d\', created_at, \'localtime\') WHEN ?1 = 1 THEN STRFTIME(\'%Y-%m\', created_at, \'localtime\') END AS bucket_date FROM (SELECT rae.name, rae.created_at FROM remote_asset_entity AS rae WHERE rae.deleted_at IS NULL AND rae.visibility = 0 AND rae.owner_id IN ($expandedvar2) UNION ALL SELECT lae.name, lae.created_at FROM local_asset_entity AS lae WHERE lae.remote_id IS NULL) GROUP BY bucket_date ORDER BY bucket_date DESC',
|
||||||
variables: [
|
variables: [
|
||||||
i0.Variable<int>(groupBy),
|
i0.Variable<int>(groupBy),
|
||||||
for (var $ in var2) i0.Variable<String>($)
|
for (var $ in var2) i0.Variable<String>($)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class RemoteAssetEntity extends Table
|
|||||||
|
|
||||||
TextColumn get id => text()();
|
TextColumn get id => text()();
|
||||||
|
|
||||||
|
TextColumn get localId => text().nullable()();
|
||||||
|
|
||||||
TextColumn get checksum => text()();
|
TextColumn get checksum => text()();
|
||||||
|
|
||||||
BoolColumn get isFavorite => boolean().withDefault(const Constant(false))();
|
BoolColumn get isFavorite => boolean().withDefault(const Constant(false))();
|
||||||
@@ -51,6 +53,6 @@ extension RemoteAssetEntityDataDomainEx on RemoteAssetEntityData {
|
|||||||
width: width,
|
width: width,
|
||||||
thumbHash: thumbHash,
|
thumbHash: thumbHash,
|
||||||
visibility: visibility,
|
visibility: visibility,
|
||||||
localId: null,
|
localId: localId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ typedef $$RemoteAssetEntityTableCreateCompanionBuilder
|
|||||||
i0.Value<int?> height,
|
i0.Value<int?> height,
|
||||||
i0.Value<int?> durationInSeconds,
|
i0.Value<int?> durationInSeconds,
|
||||||
required String id,
|
required String id,
|
||||||
|
i0.Value<String?> localId,
|
||||||
required String checksum,
|
required String checksum,
|
||||||
i0.Value<bool> isFavorite,
|
i0.Value<bool> isFavorite,
|
||||||
required String ownerId,
|
required String ownerId,
|
||||||
@@ -39,6 +40,7 @@ typedef $$RemoteAssetEntityTableUpdateCompanionBuilder
|
|||||||
i0.Value<int?> height,
|
i0.Value<int?> height,
|
||||||
i0.Value<int?> durationInSeconds,
|
i0.Value<int?> durationInSeconds,
|
||||||
i0.Value<String> id,
|
i0.Value<String> id,
|
||||||
|
i0.Value<String?> localId,
|
||||||
i0.Value<String> checksum,
|
i0.Value<String> checksum,
|
||||||
i0.Value<bool> isFavorite,
|
i0.Value<bool> isFavorite,
|
||||||
i0.Value<String> ownerId,
|
i0.Value<String> ownerId,
|
||||||
@@ -118,6 +120,9 @@ class $$RemoteAssetEntityTableFilterComposer
|
|||||||
i0.ColumnFilters<String> get id => $composableBuilder(
|
i0.ColumnFilters<String> get id => $composableBuilder(
|
||||||
column: $table.id, builder: (column) => i0.ColumnFilters(column));
|
column: $table.id, builder: (column) => i0.ColumnFilters(column));
|
||||||
|
|
||||||
|
i0.ColumnFilters<String> get localId => $composableBuilder(
|
||||||
|
column: $table.localId, builder: (column) => i0.ColumnFilters(column));
|
||||||
|
|
||||||
i0.ColumnFilters<String> get checksum => $composableBuilder(
|
i0.ColumnFilters<String> get checksum => $composableBuilder(
|
||||||
column: $table.checksum, builder: (column) => i0.ColumnFilters(column));
|
column: $table.checksum, builder: (column) => i0.ColumnFilters(column));
|
||||||
|
|
||||||
@@ -198,6 +203,9 @@ class $$RemoteAssetEntityTableOrderingComposer
|
|||||||
i0.ColumnOrderings<String> get id => $composableBuilder(
|
i0.ColumnOrderings<String> get id => $composableBuilder(
|
||||||
column: $table.id, builder: (column) => i0.ColumnOrderings(column));
|
column: $table.id, builder: (column) => i0.ColumnOrderings(column));
|
||||||
|
|
||||||
|
i0.ColumnOrderings<String> get localId => $composableBuilder(
|
||||||
|
column: $table.localId, builder: (column) => i0.ColumnOrderings(column));
|
||||||
|
|
||||||
i0.ColumnOrderings<String> get checksum => $composableBuilder(
|
i0.ColumnOrderings<String> get checksum => $composableBuilder(
|
||||||
column: $table.checksum, builder: (column) => i0.ColumnOrderings(column));
|
column: $table.checksum, builder: (column) => i0.ColumnOrderings(column));
|
||||||
|
|
||||||
@@ -277,6 +285,9 @@ class $$RemoteAssetEntityTableAnnotationComposer
|
|||||||
i0.GeneratedColumn<String> get id =>
|
i0.GeneratedColumn<String> get id =>
|
||||||
$composableBuilder(column: $table.id, builder: (column) => column);
|
$composableBuilder(column: $table.id, builder: (column) => column);
|
||||||
|
|
||||||
|
i0.GeneratedColumn<String> get localId =>
|
||||||
|
$composableBuilder(column: $table.localId, builder: (column) => column);
|
||||||
|
|
||||||
i0.GeneratedColumn<String> get checksum =>
|
i0.GeneratedColumn<String> get checksum =>
|
||||||
$composableBuilder(column: $table.checksum, builder: (column) => column);
|
$composableBuilder(column: $table.checksum, builder: (column) => column);
|
||||||
|
|
||||||
@@ -352,6 +363,7 @@ class $$RemoteAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i0.Value<int?> height = const i0.Value.absent(),
|
i0.Value<int?> height = const i0.Value.absent(),
|
||||||
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
||||||
i0.Value<String> id = const i0.Value.absent(),
|
i0.Value<String> id = const i0.Value.absent(),
|
||||||
|
i0.Value<String?> localId = const i0.Value.absent(),
|
||||||
i0.Value<String> checksum = const i0.Value.absent(),
|
i0.Value<String> checksum = const i0.Value.absent(),
|
||||||
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
||||||
i0.Value<String> ownerId = const i0.Value.absent(),
|
i0.Value<String> ownerId = const i0.Value.absent(),
|
||||||
@@ -369,6 +381,7 @@ class $$RemoteAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
height: height,
|
height: height,
|
||||||
durationInSeconds: durationInSeconds,
|
durationInSeconds: durationInSeconds,
|
||||||
id: id,
|
id: id,
|
||||||
|
localId: localId,
|
||||||
checksum: checksum,
|
checksum: checksum,
|
||||||
isFavorite: isFavorite,
|
isFavorite: isFavorite,
|
||||||
ownerId: ownerId,
|
ownerId: ownerId,
|
||||||
@@ -386,6 +399,7 @@ class $$RemoteAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
i0.Value<int?> height = const i0.Value.absent(),
|
i0.Value<int?> height = const i0.Value.absent(),
|
||||||
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
||||||
required String id,
|
required String id,
|
||||||
|
i0.Value<String?> localId = const i0.Value.absent(),
|
||||||
required String checksum,
|
required String checksum,
|
||||||
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
i0.Value<bool> isFavorite = const i0.Value.absent(),
|
||||||
required String ownerId,
|
required String ownerId,
|
||||||
@@ -403,6 +417,7 @@ class $$RemoteAssetEntityTableTableManager extends i0.RootTableManager<
|
|||||||
height: height,
|
height: height,
|
||||||
durationInSeconds: durationInSeconds,
|
durationInSeconds: durationInSeconds,
|
||||||
id: id,
|
id: id,
|
||||||
|
localId: localId,
|
||||||
checksum: checksum,
|
checksum: checksum,
|
||||||
isFavorite: isFavorite,
|
isFavorite: isFavorite,
|
||||||
ownerId: ownerId,
|
ownerId: ownerId,
|
||||||
@@ -530,6 +545,12 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||||||
late final i0.GeneratedColumn<String> id = i0.GeneratedColumn<String>(
|
late final i0.GeneratedColumn<String> id = i0.GeneratedColumn<String>(
|
||||||
'id', aliasedName, false,
|
'id', aliasedName, false,
|
||||||
type: i0.DriftSqlType.string, requiredDuringInsert: true);
|
type: i0.DriftSqlType.string, requiredDuringInsert: true);
|
||||||
|
static const i0.VerificationMeta _localIdMeta =
|
||||||
|
const i0.VerificationMeta('localId');
|
||||||
|
@override
|
||||||
|
late final i0.GeneratedColumn<String> localId = i0.GeneratedColumn<String>(
|
||||||
|
'local_id', aliasedName, true,
|
||||||
|
type: i0.DriftSqlType.string, requiredDuringInsert: false);
|
||||||
static const i0.VerificationMeta _checksumMeta =
|
static const i0.VerificationMeta _checksumMeta =
|
||||||
const i0.VerificationMeta('checksum');
|
const i0.VerificationMeta('checksum');
|
||||||
@override
|
@override
|
||||||
@@ -589,6 +610,7 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||||||
height,
|
height,
|
||||||
durationInSeconds,
|
durationInSeconds,
|
||||||
id,
|
id,
|
||||||
|
localId,
|
||||||
checksum,
|
checksum,
|
||||||
isFavorite,
|
isFavorite,
|
||||||
ownerId,
|
ownerId,
|
||||||
@@ -641,6 +663,10 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_idMeta);
|
context.missing(_idMeta);
|
||||||
}
|
}
|
||||||
|
if (data.containsKey('local_id')) {
|
||||||
|
context.handle(_localIdMeta,
|
||||||
|
localId.isAcceptableOrUnknown(data['local_id']!, _localIdMeta));
|
||||||
|
}
|
||||||
if (data.containsKey('checksum')) {
|
if (data.containsKey('checksum')) {
|
||||||
context.handle(_checksumMeta,
|
context.handle(_checksumMeta,
|
||||||
checksum.isAcceptableOrUnknown(data['checksum']!, _checksumMeta));
|
checksum.isAcceptableOrUnknown(data['checksum']!, _checksumMeta));
|
||||||
@@ -700,6 +726,8 @@ class $RemoteAssetEntityTable extends i3.RemoteAssetEntity
|
|||||||
i0.DriftSqlType.int, data['${effectivePrefix}duration_in_seconds']),
|
i0.DriftSqlType.int, data['${effectivePrefix}duration_in_seconds']),
|
||||||
id: attachedDatabase.typeMapping
|
id: attachedDatabase.typeMapping
|
||||||
.read(i0.DriftSqlType.string, data['${effectivePrefix}id'])!,
|
.read(i0.DriftSqlType.string, data['${effectivePrefix}id'])!,
|
||||||
|
localId: attachedDatabase.typeMapping
|
||||||
|
.read(i0.DriftSqlType.string, data['${effectivePrefix}local_id']),
|
||||||
checksum: attachedDatabase.typeMapping
|
checksum: attachedDatabase.typeMapping
|
||||||
.read(i0.DriftSqlType.string, data['${effectivePrefix}checksum'])!,
|
.read(i0.DriftSqlType.string, data['${effectivePrefix}checksum'])!,
|
||||||
isFavorite: attachedDatabase.typeMapping
|
isFavorite: attachedDatabase.typeMapping
|
||||||
@@ -744,6 +772,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
final int? height;
|
final int? height;
|
||||||
final int? durationInSeconds;
|
final int? durationInSeconds;
|
||||||
final String id;
|
final String id;
|
||||||
|
final String? localId;
|
||||||
final String checksum;
|
final String checksum;
|
||||||
final bool isFavorite;
|
final bool isFavorite;
|
||||||
final String ownerId;
|
final String ownerId;
|
||||||
@@ -760,6 +789,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
this.height,
|
this.height,
|
||||||
this.durationInSeconds,
|
this.durationInSeconds,
|
||||||
required this.id,
|
required this.id,
|
||||||
|
this.localId,
|
||||||
required this.checksum,
|
required this.checksum,
|
||||||
required this.isFavorite,
|
required this.isFavorite,
|
||||||
required this.ownerId,
|
required this.ownerId,
|
||||||
@@ -787,6 +817,9 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
map['duration_in_seconds'] = i0.Variable<int>(durationInSeconds);
|
map['duration_in_seconds'] = i0.Variable<int>(durationInSeconds);
|
||||||
}
|
}
|
||||||
map['id'] = i0.Variable<String>(id);
|
map['id'] = i0.Variable<String>(id);
|
||||||
|
if (!nullToAbsent || localId != null) {
|
||||||
|
map['local_id'] = i0.Variable<String>(localId);
|
||||||
|
}
|
||||||
map['checksum'] = i0.Variable<String>(checksum);
|
map['checksum'] = i0.Variable<String>(checksum);
|
||||||
map['is_favorite'] = i0.Variable<bool>(isFavorite);
|
map['is_favorite'] = i0.Variable<bool>(isFavorite);
|
||||||
map['owner_id'] = i0.Variable<String>(ownerId);
|
map['owner_id'] = i0.Variable<String>(ownerId);
|
||||||
@@ -819,6 +852,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
height: serializer.fromJson<int?>(json['height']),
|
height: serializer.fromJson<int?>(json['height']),
|
||||||
durationInSeconds: serializer.fromJson<int?>(json['durationInSeconds']),
|
durationInSeconds: serializer.fromJson<int?>(json['durationInSeconds']),
|
||||||
id: serializer.fromJson<String>(json['id']),
|
id: serializer.fromJson<String>(json['id']),
|
||||||
|
localId: serializer.fromJson<String?>(json['localId']),
|
||||||
checksum: serializer.fromJson<String>(json['checksum']),
|
checksum: serializer.fromJson<String>(json['checksum']),
|
||||||
isFavorite: serializer.fromJson<bool>(json['isFavorite']),
|
isFavorite: serializer.fromJson<bool>(json['isFavorite']),
|
||||||
ownerId: serializer.fromJson<String>(json['ownerId']),
|
ownerId: serializer.fromJson<String>(json['ownerId']),
|
||||||
@@ -842,6 +876,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
'height': serializer.toJson<int?>(height),
|
'height': serializer.toJson<int?>(height),
|
||||||
'durationInSeconds': serializer.toJson<int?>(durationInSeconds),
|
'durationInSeconds': serializer.toJson<int?>(durationInSeconds),
|
||||||
'id': serializer.toJson<String>(id),
|
'id': serializer.toJson<String>(id),
|
||||||
|
'localId': serializer.toJson<String?>(localId),
|
||||||
'checksum': serializer.toJson<String>(checksum),
|
'checksum': serializer.toJson<String>(checksum),
|
||||||
'isFavorite': serializer.toJson<bool>(isFavorite),
|
'isFavorite': serializer.toJson<bool>(isFavorite),
|
||||||
'ownerId': serializer.toJson<String>(ownerId),
|
'ownerId': serializer.toJson<String>(ownerId),
|
||||||
@@ -862,6 +897,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
i0.Value<int?> height = const i0.Value.absent(),
|
i0.Value<int?> height = const i0.Value.absent(),
|
||||||
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
i0.Value<int?> durationInSeconds = const i0.Value.absent(),
|
||||||
String? id,
|
String? id,
|
||||||
|
i0.Value<String?> localId = const i0.Value.absent(),
|
||||||
String? checksum,
|
String? checksum,
|
||||||
bool? isFavorite,
|
bool? isFavorite,
|
||||||
String? ownerId,
|
String? ownerId,
|
||||||
@@ -880,6 +916,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
? durationInSeconds.value
|
? durationInSeconds.value
|
||||||
: this.durationInSeconds,
|
: this.durationInSeconds,
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
localId: localId.present ? localId.value : this.localId,
|
||||||
checksum: checksum ?? this.checksum,
|
checksum: checksum ?? this.checksum,
|
||||||
isFavorite: isFavorite ?? this.isFavorite,
|
isFavorite: isFavorite ?? this.isFavorite,
|
||||||
ownerId: ownerId ?? this.ownerId,
|
ownerId: ownerId ?? this.ownerId,
|
||||||
@@ -901,6 +938,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
? data.durationInSeconds.value
|
? data.durationInSeconds.value
|
||||||
: this.durationInSeconds,
|
: this.durationInSeconds,
|
||||||
id: data.id.present ? data.id.value : this.id,
|
id: data.id.present ? data.id.value : this.id,
|
||||||
|
localId: data.localId.present ? data.localId.value : this.localId,
|
||||||
checksum: data.checksum.present ? data.checksum.value : this.checksum,
|
checksum: data.checksum.present ? data.checksum.value : this.checksum,
|
||||||
isFavorite:
|
isFavorite:
|
||||||
data.isFavorite.present ? data.isFavorite.value : this.isFavorite,
|
data.isFavorite.present ? data.isFavorite.value : this.isFavorite,
|
||||||
@@ -926,6 +964,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
..write('height: $height, ')
|
..write('height: $height, ')
|
||||||
..write('durationInSeconds: $durationInSeconds, ')
|
..write('durationInSeconds: $durationInSeconds, ')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
|
..write('localId: $localId, ')
|
||||||
..write('checksum: $checksum, ')
|
..write('checksum: $checksum, ')
|
||||||
..write('isFavorite: $isFavorite, ')
|
..write('isFavorite: $isFavorite, ')
|
||||||
..write('ownerId: $ownerId, ')
|
..write('ownerId: $ownerId, ')
|
||||||
@@ -947,6 +986,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
height,
|
height,
|
||||||
durationInSeconds,
|
durationInSeconds,
|
||||||
id,
|
id,
|
||||||
|
localId,
|
||||||
checksum,
|
checksum,
|
||||||
isFavorite,
|
isFavorite,
|
||||||
ownerId,
|
ownerId,
|
||||||
@@ -966,6 +1006,7 @@ class RemoteAssetEntityData extends i0.DataClass
|
|||||||
other.height == this.height &&
|
other.height == this.height &&
|
||||||
other.durationInSeconds == this.durationInSeconds &&
|
other.durationInSeconds == this.durationInSeconds &&
|
||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
|
other.localId == this.localId &&
|
||||||
other.checksum == this.checksum &&
|
other.checksum == this.checksum &&
|
||||||
other.isFavorite == this.isFavorite &&
|
other.isFavorite == this.isFavorite &&
|
||||||
other.ownerId == this.ownerId &&
|
other.ownerId == this.ownerId &&
|
||||||
@@ -985,6 +1026,7 @@ class RemoteAssetEntityCompanion
|
|||||||
final i0.Value<int?> height;
|
final i0.Value<int?> height;
|
||||||
final i0.Value<int?> durationInSeconds;
|
final i0.Value<int?> durationInSeconds;
|
||||||
final i0.Value<String> id;
|
final i0.Value<String> id;
|
||||||
|
final i0.Value<String?> localId;
|
||||||
final i0.Value<String> checksum;
|
final i0.Value<String> checksum;
|
||||||
final i0.Value<bool> isFavorite;
|
final i0.Value<bool> isFavorite;
|
||||||
final i0.Value<String> ownerId;
|
final i0.Value<String> ownerId;
|
||||||
@@ -1001,6 +1043,7 @@ class RemoteAssetEntityCompanion
|
|||||||
this.height = const i0.Value.absent(),
|
this.height = const i0.Value.absent(),
|
||||||
this.durationInSeconds = const i0.Value.absent(),
|
this.durationInSeconds = const i0.Value.absent(),
|
||||||
this.id = const i0.Value.absent(),
|
this.id = const i0.Value.absent(),
|
||||||
|
this.localId = const i0.Value.absent(),
|
||||||
this.checksum = const i0.Value.absent(),
|
this.checksum = const i0.Value.absent(),
|
||||||
this.isFavorite = const i0.Value.absent(),
|
this.isFavorite = const i0.Value.absent(),
|
||||||
this.ownerId = const i0.Value.absent(),
|
this.ownerId = const i0.Value.absent(),
|
||||||
@@ -1018,6 +1061,7 @@ class RemoteAssetEntityCompanion
|
|||||||
this.height = const i0.Value.absent(),
|
this.height = const i0.Value.absent(),
|
||||||
this.durationInSeconds = const i0.Value.absent(),
|
this.durationInSeconds = const i0.Value.absent(),
|
||||||
required String id,
|
required String id,
|
||||||
|
this.localId = const i0.Value.absent(),
|
||||||
required String checksum,
|
required String checksum,
|
||||||
this.isFavorite = const i0.Value.absent(),
|
this.isFavorite = const i0.Value.absent(),
|
||||||
required String ownerId,
|
required String ownerId,
|
||||||
@@ -1040,6 +1084,7 @@ class RemoteAssetEntityCompanion
|
|||||||
i0.Expression<int>? height,
|
i0.Expression<int>? height,
|
||||||
i0.Expression<int>? durationInSeconds,
|
i0.Expression<int>? durationInSeconds,
|
||||||
i0.Expression<String>? id,
|
i0.Expression<String>? id,
|
||||||
|
i0.Expression<String>? localId,
|
||||||
i0.Expression<String>? checksum,
|
i0.Expression<String>? checksum,
|
||||||
i0.Expression<bool>? isFavorite,
|
i0.Expression<bool>? isFavorite,
|
||||||
i0.Expression<String>? ownerId,
|
i0.Expression<String>? ownerId,
|
||||||
@@ -1057,6 +1102,7 @@ class RemoteAssetEntityCompanion
|
|||||||
if (height != null) 'height': height,
|
if (height != null) 'height': height,
|
||||||
if (durationInSeconds != null) 'duration_in_seconds': durationInSeconds,
|
if (durationInSeconds != null) 'duration_in_seconds': durationInSeconds,
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
|
if (localId != null) 'local_id': localId,
|
||||||
if (checksum != null) 'checksum': checksum,
|
if (checksum != null) 'checksum': checksum,
|
||||||
if (isFavorite != null) 'is_favorite': isFavorite,
|
if (isFavorite != null) 'is_favorite': isFavorite,
|
||||||
if (ownerId != null) 'owner_id': ownerId,
|
if (ownerId != null) 'owner_id': ownerId,
|
||||||
@@ -1076,6 +1122,7 @@ class RemoteAssetEntityCompanion
|
|||||||
i0.Value<int?>? height,
|
i0.Value<int?>? height,
|
||||||
i0.Value<int?>? durationInSeconds,
|
i0.Value<int?>? durationInSeconds,
|
||||||
i0.Value<String>? id,
|
i0.Value<String>? id,
|
||||||
|
i0.Value<String?>? localId,
|
||||||
i0.Value<String>? checksum,
|
i0.Value<String>? checksum,
|
||||||
i0.Value<bool>? isFavorite,
|
i0.Value<bool>? isFavorite,
|
||||||
i0.Value<String>? ownerId,
|
i0.Value<String>? ownerId,
|
||||||
@@ -1092,6 +1139,7 @@ class RemoteAssetEntityCompanion
|
|||||||
height: height ?? this.height,
|
height: height ?? this.height,
|
||||||
durationInSeconds: durationInSeconds ?? this.durationInSeconds,
|
durationInSeconds: durationInSeconds ?? this.durationInSeconds,
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
localId: localId ?? this.localId,
|
||||||
checksum: checksum ?? this.checksum,
|
checksum: checksum ?? this.checksum,
|
||||||
isFavorite: isFavorite ?? this.isFavorite,
|
isFavorite: isFavorite ?? this.isFavorite,
|
||||||
ownerId: ownerId ?? this.ownerId,
|
ownerId: ownerId ?? this.ownerId,
|
||||||
@@ -1130,6 +1178,9 @@ class RemoteAssetEntityCompanion
|
|||||||
if (id.present) {
|
if (id.present) {
|
||||||
map['id'] = i0.Variable<String>(id.value);
|
map['id'] = i0.Variable<String>(id.value);
|
||||||
}
|
}
|
||||||
|
if (localId.present) {
|
||||||
|
map['local_id'] = i0.Variable<String>(localId.value);
|
||||||
|
}
|
||||||
if (checksum.present) {
|
if (checksum.present) {
|
||||||
map['checksum'] = i0.Variable<String>(checksum.value);
|
map['checksum'] = i0.Variable<String>(checksum.value);
|
||||||
}
|
}
|
||||||
@@ -1167,6 +1218,7 @@ class RemoteAssetEntityCompanion
|
|||||||
..write('height: $height, ')
|
..write('height: $height, ')
|
||||||
..write('durationInSeconds: $durationInSeconds, ')
|
..write('durationInSeconds: $durationInSeconds, ')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
|
..write('localId: $localId, ')
|
||||||
..write('checksum: $checksum, ')
|
..write('checksum: $checksum, ')
|
||||||
..write('isFavorite: $isFavorite, ')
|
..write('isFavorite: $isFavorite, ')
|
||||||
..write('ownerId: $ownerId, ')
|
..write('ownerId: $ownerId, ')
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class IsarDatabaseRepository implements IDatabaseRepository {
|
|||||||
],
|
],
|
||||||
include: {
|
include: {
|
||||||
'package:immich_mobile/infrastructure/entities/merged_asset.drift',
|
'package:immich_mobile/infrastructure/entities/merged_asset.drift',
|
||||||
|
'package:immich_mobile/infrastructure/entities/asset_triggers.drift',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
class Drift extends $Drift implements IDatabaseRepository {
|
class Drift extends $Drift implements IDatabaseRepository {
|
||||||
|
|||||||
@@ -7,31 +7,33 @@ import 'package:immich_mobile/infrastructure/entities/remote_asset.entity.drift.
|
|||||||
as i2;
|
as i2;
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/local_asset.entity.drift.dart'
|
||||||
as i3;
|
as i3;
|
||||||
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/asset_triggers.drift.dart'
|
||||||
as i4;
|
as i4;
|
||||||
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/user_metadata.entity.drift.dart'
|
||||||
as i5;
|
as i5;
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_album.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/partner.entity.drift.dart'
|
||||||
as i6;
|
as i6;
|
||||||
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/local_album.entity.drift.dart'
|
||||||
as i7;
|
as i7;
|
||||||
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/local_album_asset.entity.drift.dart'
|
||||||
as i8;
|
as i8;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_album.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/exif.entity.drift.dart'
|
||||||
as i9;
|
as i9;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/remote_album.entity.drift.dart'
|
||||||
as i10;
|
as i10;
|
||||||
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/remote_album_asset.entity.drift.dart'
|
||||||
as i11;
|
as i11;
|
||||||
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/remote_album_user.entity.drift.dart'
|
||||||
as i12;
|
as i12;
|
||||||
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/memory.entity.drift.dart'
|
||||||
as i13;
|
as i13;
|
||||||
import 'package:immich_mobile/infrastructure/entities/stack.entity.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/memory_asset.entity.drift.dart'
|
||||||
as i14;
|
as i14;
|
||||||
import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart'
|
import 'package:immich_mobile/infrastructure/entities/stack.entity.drift.dart'
|
||||||
as i15;
|
as i15;
|
||||||
import 'package:drift/internal/modular.dart' as i16;
|
import 'package:immich_mobile/infrastructure/entities/merged_asset.drift.dart'
|
||||||
|
as i16;
|
||||||
|
import 'package:drift/internal/modular.dart' as i17;
|
||||||
|
|
||||||
abstract class $Drift extends i0.GeneratedDatabase {
|
abstract class $Drift extends i0.GeneratedDatabase {
|
||||||
$Drift(i0.QueryExecutor e) : super(e);
|
$Drift(i0.QueryExecutor e) : super(e);
|
||||||
@@ -41,28 +43,28 @@ abstract class $Drift extends i0.GeneratedDatabase {
|
|||||||
i2.$RemoteAssetEntityTable(this);
|
i2.$RemoteAssetEntityTable(this);
|
||||||
late final i3.$LocalAssetEntityTable localAssetEntity =
|
late final i3.$LocalAssetEntityTable localAssetEntity =
|
||||||
i3.$LocalAssetEntityTable(this);
|
i3.$LocalAssetEntityTable(this);
|
||||||
late final i4.$UserMetadataEntityTable userMetadataEntity =
|
late final i5.$UserMetadataEntityTable userMetadataEntity =
|
||||||
i4.$UserMetadataEntityTable(this);
|
i5.$UserMetadataEntityTable(this);
|
||||||
late final i5.$PartnerEntityTable partnerEntity =
|
late final i6.$PartnerEntityTable partnerEntity =
|
||||||
i5.$PartnerEntityTable(this);
|
i6.$PartnerEntityTable(this);
|
||||||
late final i6.$LocalAlbumEntityTable localAlbumEntity =
|
late final i7.$LocalAlbumEntityTable localAlbumEntity =
|
||||||
i6.$LocalAlbumEntityTable(this);
|
i7.$LocalAlbumEntityTable(this);
|
||||||
late final i7.$LocalAlbumAssetEntityTable localAlbumAssetEntity =
|
late final i8.$LocalAlbumAssetEntityTable localAlbumAssetEntity =
|
||||||
i7.$LocalAlbumAssetEntityTable(this);
|
i8.$LocalAlbumAssetEntityTable(this);
|
||||||
late final i8.$RemoteExifEntityTable remoteExifEntity =
|
late final i9.$RemoteExifEntityTable remoteExifEntity =
|
||||||
i8.$RemoteExifEntityTable(this);
|
i9.$RemoteExifEntityTable(this);
|
||||||
late final i9.$RemoteAlbumEntityTable remoteAlbumEntity =
|
late final i10.$RemoteAlbumEntityTable remoteAlbumEntity =
|
||||||
i9.$RemoteAlbumEntityTable(this);
|
i10.$RemoteAlbumEntityTable(this);
|
||||||
late final i10.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity =
|
late final i11.$RemoteAlbumAssetEntityTable remoteAlbumAssetEntity =
|
||||||
i10.$RemoteAlbumAssetEntityTable(this);
|
i11.$RemoteAlbumAssetEntityTable(this);
|
||||||
late final i11.$RemoteAlbumUserEntityTable remoteAlbumUserEntity =
|
late final i12.$RemoteAlbumUserEntityTable remoteAlbumUserEntity =
|
||||||
i11.$RemoteAlbumUserEntityTable(this);
|
i12.$RemoteAlbumUserEntityTable(this);
|
||||||
late final i12.$MemoryEntityTable memoryEntity = i12.$MemoryEntityTable(this);
|
late final i13.$MemoryEntityTable memoryEntity = i13.$MemoryEntityTable(this);
|
||||||
late final i13.$MemoryAssetEntityTable memoryAssetEntity =
|
late final i14.$MemoryAssetEntityTable memoryAssetEntity =
|
||||||
i13.$MemoryAssetEntityTable(this);
|
i14.$MemoryAssetEntityTable(this);
|
||||||
late final i14.$StackEntityTable stackEntity = i14.$StackEntityTable(this);
|
late final i15.$StackEntityTable stackEntity = i15.$StackEntityTable(this);
|
||||||
i15.MergedAssetDrift get mergedAssetDrift => i16.ReadDatabaseContainer(this)
|
i16.MergedAssetDrift get mergedAssetDrift => i17.ReadDatabaseContainer(this)
|
||||||
.accessor<i15.MergedAssetDrift>(i15.MergedAssetDrift.new);
|
.accessor<i16.MergedAssetDrift>(i16.MergedAssetDrift.new);
|
||||||
@override
|
@override
|
||||||
Iterable<i0.TableInfo<i0.Table, Object?>> get allTables =>
|
Iterable<i0.TableInfo<i0.Table, Object?>> get allTables =>
|
||||||
allSchemaEntities.whereType<i0.TableInfo<i0.Table, Object?>>();
|
allSchemaEntities.whereType<i0.TableInfo<i0.Table, Object?>>();
|
||||||
@@ -71,6 +73,10 @@ abstract class $Drift extends i0.GeneratedDatabase {
|
|||||||
userEntity,
|
userEntity,
|
||||||
remoteAssetEntity,
|
remoteAssetEntity,
|
||||||
localAssetEntity,
|
localAssetEntity,
|
||||||
|
i4.trLocalAssetUpdateChecksumSetIds,
|
||||||
|
i4.trLocalAssetUpdateOldChecksumSetRemoteAssetLocalId,
|
||||||
|
i4.trLocalAssetDeleteUpdateRemoteAssetLocalId,
|
||||||
|
i4.trRemoteAssetInsertSetLocalId,
|
||||||
i3.idxLocalAssetChecksum,
|
i3.idxLocalAssetChecksum,
|
||||||
i2.uQRemoteAssetOwnerChecksum,
|
i2.uQRemoteAssetOwnerChecksum,
|
||||||
i2.idxRemoteAssetChecksum,
|
i2.idxRemoteAssetChecksum,
|
||||||
@@ -97,6 +103,43 @@ abstract class $Drift extends i0.GeneratedDatabase {
|
|||||||
i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.delete),
|
i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.delete),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
i0.WritePropagation(
|
||||||
|
on: i0.TableUpdateQuery.onTableName('remote_asset_entity',
|
||||||
|
limitUpdateKind: i0.UpdateKind.delete),
|
||||||
|
result: [
|
||||||
|
i0.TableUpdate('local_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
i0.WritePropagation(
|
||||||
|
on: i0.TableUpdateQuery.onTableName('local_asset_entity',
|
||||||
|
limitUpdateKind: i0.UpdateKind.update),
|
||||||
|
result: [
|
||||||
|
i0.TableUpdate('local_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
i0.WritePropagation(
|
||||||
|
on: i0.TableUpdateQuery.onTableName('local_asset_entity',
|
||||||
|
limitUpdateKind: i0.UpdateKind.update),
|
||||||
|
result: [
|
||||||
|
i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
i0.WritePropagation(
|
||||||
|
on: i0.TableUpdateQuery.onTableName('local_asset_entity',
|
||||||
|
limitUpdateKind: i0.UpdateKind.delete),
|
||||||
|
result: [
|
||||||
|
i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
i0.WritePropagation(
|
||||||
|
on: i0.TableUpdateQuery.onTableName('remote_asset_entity',
|
||||||
|
limitUpdateKind: i0.UpdateKind.insert),
|
||||||
|
result: [
|
||||||
|
i0.TableUpdate('remote_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
i0.TableUpdate('local_asset_entity', kind: i0.UpdateKind.update),
|
||||||
|
],
|
||||||
|
),
|
||||||
i0.WritePropagation(
|
i0.WritePropagation(
|
||||||
on: i0.TableUpdateQuery.onTableName('user_entity',
|
on: i0.TableUpdateQuery.onTableName('user_entity',
|
||||||
limitUpdateKind: i0.UpdateKind.delete),
|
limitUpdateKind: i0.UpdateKind.delete),
|
||||||
@@ -232,27 +275,27 @@ class $DriftManager {
|
|||||||
i2.$$RemoteAssetEntityTableTableManager(_db, _db.remoteAssetEntity);
|
i2.$$RemoteAssetEntityTableTableManager(_db, _db.remoteAssetEntity);
|
||||||
i3.$$LocalAssetEntityTableTableManager get localAssetEntity =>
|
i3.$$LocalAssetEntityTableTableManager get localAssetEntity =>
|
||||||
i3.$$LocalAssetEntityTableTableManager(_db, _db.localAssetEntity);
|
i3.$$LocalAssetEntityTableTableManager(_db, _db.localAssetEntity);
|
||||||
i4.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
|
i5.$$UserMetadataEntityTableTableManager get userMetadataEntity =>
|
||||||
i4.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
|
i5.$$UserMetadataEntityTableTableManager(_db, _db.userMetadataEntity);
|
||||||
i5.$$PartnerEntityTableTableManager get partnerEntity =>
|
i6.$$PartnerEntityTableTableManager get partnerEntity =>
|
||||||
i5.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
|
i6.$$PartnerEntityTableTableManager(_db, _db.partnerEntity);
|
||||||
i6.$$LocalAlbumEntityTableTableManager get localAlbumEntity =>
|
i7.$$LocalAlbumEntityTableTableManager get localAlbumEntity =>
|
||||||
i6.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity);
|
i7.$$LocalAlbumEntityTableTableManager(_db, _db.localAlbumEntity);
|
||||||
i7.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i7
|
i8.$$LocalAlbumAssetEntityTableTableManager get localAlbumAssetEntity => i8
|
||||||
.$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity);
|
.$$LocalAlbumAssetEntityTableTableManager(_db, _db.localAlbumAssetEntity);
|
||||||
i8.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
|
i9.$$RemoteExifEntityTableTableManager get remoteExifEntity =>
|
||||||
i8.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
|
i9.$$RemoteExifEntityTableTableManager(_db, _db.remoteExifEntity);
|
||||||
i9.$$RemoteAlbumEntityTableTableManager get remoteAlbumEntity =>
|
i10.$$RemoteAlbumEntityTableTableManager get remoteAlbumEntity =>
|
||||||
i9.$$RemoteAlbumEntityTableTableManager(_db, _db.remoteAlbumEntity);
|
i10.$$RemoteAlbumEntityTableTableManager(_db, _db.remoteAlbumEntity);
|
||||||
i10.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
|
i11.$$RemoteAlbumAssetEntityTableTableManager get remoteAlbumAssetEntity =>
|
||||||
i10.$$RemoteAlbumAssetEntityTableTableManager(
|
i11.$$RemoteAlbumAssetEntityTableTableManager(
|
||||||
_db, _db.remoteAlbumAssetEntity);
|
_db, _db.remoteAlbumAssetEntity);
|
||||||
i11.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i11
|
i12.$$RemoteAlbumUserEntityTableTableManager get remoteAlbumUserEntity => i12
|
||||||
.$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity);
|
.$$RemoteAlbumUserEntityTableTableManager(_db, _db.remoteAlbumUserEntity);
|
||||||
i12.$$MemoryEntityTableTableManager get memoryEntity =>
|
i13.$$MemoryEntityTableTableManager get memoryEntity =>
|
||||||
i12.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
|
i13.$$MemoryEntityTableTableManager(_db, _db.memoryEntity);
|
||||||
i13.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
|
i14.$$MemoryAssetEntityTableTableManager get memoryAssetEntity =>
|
||||||
i13.$$MemoryAssetEntityTableTableManager(_db, _db.memoryAssetEntity);
|
i14.$$MemoryAssetEntityTableTableManager(_db, _db.memoryAssetEntity);
|
||||||
i14.$$StackEntityTableTableManager get stackEntity =>
|
i15.$$StackEntityTableTableManager get stackEntity =>
|
||||||
i14.$$StackEntityTableTableManager(_db, _db.stackEntity);
|
i15.$$StackEntityTableTableManager(_db, _db.stackEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ class DriftLocalAlbumRepository extends DriftDatabaseRepository {
|
|||||||
durationInSeconds: Value(asset.durationInSeconds),
|
durationInSeconds: Value(asset.durationInSeconds),
|
||||||
id: asset.id,
|
id: asset.id,
|
||||||
checksum: const Value(null),
|
checksum: const Value(null),
|
||||||
|
remoteId: const Value(null),
|
||||||
);
|
);
|
||||||
batch.insert<$LocalAssetEntityTable, LocalAssetEntityData>(
|
batch.insert<$LocalAssetEntityTable, LocalAssetEntityData>(
|
||||||
_db.localAssetEntity,
|
_db.localAssetEntity,
|
||||||
|
|||||||
@@ -9,23 +9,10 @@ class DriftLocalAssetRepository extends DriftDatabaseRepository {
|
|||||||
const DriftLocalAssetRepository(this._db) : super(_db);
|
const DriftLocalAssetRepository(this._db) : super(_db);
|
||||||
|
|
||||||
Stream<LocalAsset?> watchAsset(String id) {
|
Stream<LocalAsset?> watchAsset(String id) {
|
||||||
final query = _db.localAssetEntity
|
final query = _db.localAssetEntity.select()
|
||||||
.select()
|
..where((row) => row.id.equals(id));
|
||||||
.addColumns([_db.localAssetEntity.id]).join([
|
|
||||||
leftOuterJoin(
|
|
||||||
_db.remoteAssetEntity,
|
|
||||||
_db.localAssetEntity.checksum.equalsExp(_db.remoteAssetEntity.checksum),
|
|
||||||
useColumns: false,
|
|
||||||
),
|
|
||||||
])
|
|
||||||
..where(_db.localAssetEntity.id.equals(id));
|
|
||||||
|
|
||||||
return query.map((row) {
|
return query.map((row) => row.toDto()).watchSingleOrNull();
|
||||||
final asset = row.readTable(_db.localAssetEntity).toDto();
|
|
||||||
return asset.copyWith(
|
|
||||||
remoteId: row.read(_db.remoteAssetEntity.id),
|
|
||||||
);
|
|
||||||
}).watchSingleOrNull();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateHashes(Iterable<LocalAsset> hashes) {
|
Future<void> updateHashes(Iterable<LocalAsset> hashes) {
|
||||||
|
|||||||
@@ -30,23 +30,10 @@ class RemoteAssetRepository extends DriftDatabaseRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Stream<RemoteAsset?> watchAsset(String id) {
|
Stream<RemoteAsset?> watchAsset(String id) {
|
||||||
final query = _db.remoteAssetEntity
|
final query = _db.remoteAssetEntity.select()
|
||||||
.select()
|
..where((row) => row.id.equals(id));
|
||||||
.addColumns([_db.localAssetEntity.id]).join([
|
|
||||||
leftOuterJoin(
|
|
||||||
_db.localAssetEntity,
|
|
||||||
_db.remoteAssetEntity.checksum.equalsExp(_db.localAssetEntity.checksum),
|
|
||||||
useColumns: false,
|
|
||||||
),
|
|
||||||
])
|
|
||||||
..where(_db.remoteAssetEntity.id.equals(id));
|
|
||||||
|
|
||||||
return query.map((row) {
|
return query.map((row) => row.toDto()).watchSingleOrNull();
|
||||||
final asset = row.readTable(_db.remoteAssetEntity).toDto();
|
|
||||||
return asset.copyWith(
|
|
||||||
localId: row.read(_db.localAssetEntity.id),
|
|
||||||
);
|
|
||||||
}).watchSingleOrNull();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ExifInfo?> getExif(String id) {
|
Future<ExifInfo?> getExif(String id) {
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
import 'dart:convert' hide Codec;
|
|
||||||
import 'dart:ui';
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:thumbhash/thumbhash.dart';
|
|
||||||
|
|
||||||
class ThumbHashProvider extends ImageProvider<ThumbHashProvider> {
|
|
||||||
final String thumbHash;
|
|
||||||
|
|
||||||
const ThumbHashProvider({
|
|
||||||
required this.thumbHash,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<ThumbHashProvider> obtainKey(ImageConfiguration configuration) {
|
|
||||||
return SynchronousFuture(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
ImageStreamCompleter loadImage(
|
|
||||||
ThumbHashProvider key,
|
|
||||||
ImageDecoderCallback decode,
|
|
||||||
) {
|
|
||||||
return MultiFrameImageStreamCompleter(
|
|
||||||
codec: _loadCodec(key, decode),
|
|
||||||
scale: 1.0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Codec> _loadCodec(
|
|
||||||
ThumbHashProvider key,
|
|
||||||
ImageDecoderCallback decode,
|
|
||||||
) async {
|
|
||||||
final image = thumbHashToRGBA(base64Decode(key.thumbHash));
|
|
||||||
return decode(await ImmutableBuffer.fromUint8List(rgbaToBmp(image)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
if (identical(this, other)) return true;
|
|
||||||
if (other is ThumbHashProvider) {
|
|
||||||
return thumbHash == other.thumbHash;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => thumbHash.hashCode;
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/thumb_hash_provider.dart';
|
import 'package:immich_mobile/widgets/common/thumbhash.dart';
|
||||||
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
|
||||||
import 'package:immich_mobile/widgets/common/fade_in_placeholder_image.dart';
|
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:octo_image/octo_image.dart';
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
@@ -56,13 +54,7 @@ OctoPlaceholderBuilder _blurHashPlaceholderBuilder(
|
|||||||
String? thumbHash, {
|
String? thumbHash, {
|
||||||
BoxFit? fit,
|
BoxFit? fit,
|
||||||
}) {
|
}) {
|
||||||
return (context) => thumbHash == null
|
return (context) => Thumbhash(blurhash: thumbHash, fit: fit ?? BoxFit.cover);
|
||||||
? const ThumbnailPlaceholder()
|
|
||||||
: FadeInPlaceholderImage(
|
|
||||||
placeholder: const ThumbnailPlaceholder(),
|
|
||||||
image: ThumbHashProvider(thumbHash: thumbHash),
|
|
||||||
fit: fit ?? BoxFit.cover,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OctoErrorBuilder _blurHashErrorBuilder(
|
OctoErrorBuilder _blurHashErrorBuilder(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/full_image.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/images/full_image.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
import 'package:immich_mobile/presentation/widgets/images/image_provider.dart';
|
||||||
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
|
import 'package:immich_mobile/widgets/common/thumbhash.dart';
|
||||||
|
|
||||||
class DriftMemoryCard extends StatelessWidget {
|
class DriftMemoryCard extends StatelessWidget {
|
||||||
final RemoteAsset asset;
|
final RemoteAsset asset;
|
||||||
@@ -117,29 +117,18 @@ class _BlurredBackdrop extends HookWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final blurhash = useDriftBlurHashRef(asset).value;
|
final blurhash = asset.thumbHash;
|
||||||
if (blurhash != null) {
|
if (blurhash != null) {
|
||||||
// Use a nice cheap blur hash image decoration
|
// Use a nice cheap blur hash image decoration
|
||||||
return Container(
|
return Thumbhash(blurhash: blurhash, fit: BoxFit.cover);
|
||||||
decoration: BoxDecoration(
|
}
|
||||||
image: DecorationImage(
|
|
||||||
image: MemoryImage(
|
|
||||||
blurhash,
|
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.withValues(alpha: 0.2),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Fall back to using a more expensive image filtered
|
// Fall back to using a more expensive image filtered
|
||||||
// Since the ImmichImage is already precached, we can
|
// Since the ImmichImage is already precached, we can
|
||||||
// safely use that as the image provider
|
// safely use that as the image provider
|
||||||
return ImageFiltered(
|
return ImageFiltered(
|
||||||
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
||||||
child: Container(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: getFullImageProvider(
|
image: getFullImageProvider(
|
||||||
@@ -149,11 +138,8 @@ class _BlurredBackdrop extends HookWidget {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Container(
|
child: const ColoredBox(color: Color.fromRGBO(0, 0, 0, 0.2)),
|
||||||
color: Colors.black.withValues(alpha: 0.2),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|
||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
|
||||||
import 'package:thumbhash/thumbhash.dart' as thumbhash;
|
|
||||||
|
|
||||||
ObjectRef<Uint8List?> useBlurHashRef(Asset? asset) {
|
|
||||||
if (asset?.thumbhash == null) {
|
|
||||||
return useRef(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final rbga = thumbhash.thumbHashToRGBA(
|
|
||||||
base64Decode(asset!.thumbhash!),
|
|
||||||
);
|
|
||||||
|
|
||||||
return useRef(thumbhash.rgbaToBmp(rbga));
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectRef<Uint8List?> useDriftBlurHashRef(RemoteAsset? asset) {
|
|
||||||
if (asset?.thumbHash == null) {
|
|
||||||
return useRef(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final rbga = thumbhash.thumbHashToRGBA(
|
|
||||||
base64Decode(asset!.thumbHash!),
|
|
||||||
);
|
|
||||||
|
|
||||||
return useRef(thumbhash.rgbaToBmp(rbga));
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:immich_mobile/widgets/common/transparent_image.dart';
|
|
||||||
|
|
||||||
class FadeInPlaceholderImage extends StatelessWidget {
|
|
||||||
final Widget placeholder;
|
|
||||||
final ImageProvider image;
|
|
||||||
final Duration duration;
|
|
||||||
final BoxFit fit;
|
|
||||||
|
|
||||||
const FadeInPlaceholderImage({
|
|
||||||
super.key,
|
|
||||||
required this.placeholder,
|
|
||||||
required this.image,
|
|
||||||
this.duration = const Duration(milliseconds: 100),
|
|
||||||
this.fit = BoxFit.cover,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SizedBox.expand(
|
|
||||||
child: Stack(
|
|
||||||
fit: StackFit.expand,
|
|
||||||
children: [
|
|
||||||
placeholder,
|
|
||||||
FadeInImage(
|
|
||||||
fadeInDuration: duration,
|
|
||||||
image: image,
|
|
||||||
fit: fit,
|
|
||||||
placeholder: MemoryImage(kTransparentImage),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/providers/image/immich_local_thumbnail_provider.dart';
|
import 'package:immich_mobile/providers/image/immich_local_thumbnail_provider.dart';
|
||||||
import 'package:immich_mobile/providers/image/immich_remote_thumbnail_provider.dart';
|
import 'package:immich_mobile/providers/image/immich_remote_thumbnail_provider.dart';
|
||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
|
|
||||||
import 'package:immich_mobile/utils/thumbnail_utils.dart';
|
import 'package:immich_mobile/utils/thumbnail_utils.dart';
|
||||||
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
||||||
import 'package:immich_mobile/widgets/common/thumbhash_placeholder.dart';
|
import 'package:immich_mobile/widgets/common/thumbhash_placeholder.dart';
|
||||||
@@ -64,7 +61,6 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
Uint8List? blurhash = useBlurHashRef(asset).value;
|
|
||||||
final userId = ref.watch(currentUserProvider)?.id;
|
final userId = ref.watch(currentUserProvider)?.id;
|
||||||
|
|
||||||
if (asset == null) {
|
if (asset == null) {
|
||||||
@@ -82,7 +78,7 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
asset!.exifInfo,
|
asset!.exifInfo,
|
||||||
asset!.fileCreatedAt,
|
asset!.fileCreatedAt,
|
||||||
asset!.type,
|
asset!.type,
|
||||||
[],
|
const [],
|
||||||
);
|
);
|
||||||
|
|
||||||
final thumbnailProviderInstance = ImmichThumbnail.imageProvider(
|
final thumbnailProviderInstance = ImmichThumbnail.imageProvider(
|
||||||
@@ -94,7 +90,7 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
thumbnailProviderInstance.evict();
|
thumbnailProviderInstance.evict();
|
||||||
|
|
||||||
final originalErrorWidgetBuilder =
|
final originalErrorWidgetBuilder =
|
||||||
blurHashErrorBuilder(blurhash, fit: fit);
|
blurHashErrorBuilder(asset?.thumbhash, fit: fit);
|
||||||
return originalErrorWidgetBuilder(ctx, error, stackTrace);
|
return originalErrorWidgetBuilder(ctx, error, stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +101,8 @@ class ImmichThumbnail extends HookConsumerWidget {
|
|||||||
fadeInDuration: Duration.zero,
|
fadeInDuration: Duration.zero,
|
||||||
fadeOutDuration: const Duration(milliseconds: 100),
|
fadeOutDuration: const Duration(milliseconds: 100),
|
||||||
octoSet: OctoSet(
|
octoSet: OctoSet(
|
||||||
placeholderBuilder: blurHashPlaceholderBuilder(blurhash, fit: fit),
|
placeholderBuilder:
|
||||||
|
blurHashPlaceholderBuilder(asset?.thumbhash, fit: fit),
|
||||||
errorBuilder: customErrorBuilder,
|
errorBuilder: customErrorBuilder,
|
||||||
),
|
),
|
||||||
image: thumbnailProviderInstance,
|
image: thumbnailProviderInstance,
|
||||||
|
|||||||
194
mobile/lib/widgets/common/thumbhash.dart
Normal file
194
mobile/lib/widgets/common/thumbhash.dart
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:ui' as ui;
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:thumbhash/thumbhash.dart' as thumbhash;
|
||||||
|
|
||||||
|
class ThumbhashImage extends RenderBox {
|
||||||
|
Color _placeholderColor;
|
||||||
|
ui.Image? _image;
|
||||||
|
BoxFit _fit;
|
||||||
|
|
||||||
|
ThumbhashImage({
|
||||||
|
required ui.Image? image,
|
||||||
|
required BoxFit fit,
|
||||||
|
required Color placeholderColor,
|
||||||
|
}) : _image = image,
|
||||||
|
_fit = fit,
|
||||||
|
_placeholderColor = placeholderColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(PaintingContext context, Offset offset) {
|
||||||
|
final image = _image;
|
||||||
|
final rect = offset & size;
|
||||||
|
if (image == null) {
|
||||||
|
final paint = Paint();
|
||||||
|
paint.color = _placeholderColor;
|
||||||
|
context.canvas.drawRect(rect, paint);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
paintImage(
|
||||||
|
canvas: context.canvas,
|
||||||
|
rect: rect,
|
||||||
|
image: image,
|
||||||
|
fit: _fit,
|
||||||
|
filterQuality: FilterQuality.low,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void performLayout() {
|
||||||
|
size = constraints.biggest;
|
||||||
|
}
|
||||||
|
|
||||||
|
set image(ui.Image? value) {
|
||||||
|
if (_image != value) {
|
||||||
|
_image = value;
|
||||||
|
markNeedsPaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set fit(BoxFit value) {
|
||||||
|
if (_fit != value) {
|
||||||
|
_fit = value;
|
||||||
|
markNeedsPaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set placeholderColor(Color value) {
|
||||||
|
if (_placeholderColor != value) {
|
||||||
|
_placeholderColor = value;
|
||||||
|
markNeedsPaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ThumbhashLeaf extends LeafRenderObjectWidget {
|
||||||
|
final ui.Image? image;
|
||||||
|
final BoxFit fit;
|
||||||
|
final Color placeholderColor;
|
||||||
|
|
||||||
|
const ThumbhashLeaf({
|
||||||
|
super.key,
|
||||||
|
required this.image,
|
||||||
|
required this.fit,
|
||||||
|
required this.placeholderColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
RenderObject createRenderObject(BuildContext context) {
|
||||||
|
return ThumbhashImage(
|
||||||
|
image: image,
|
||||||
|
fit: fit,
|
||||||
|
placeholderColor: placeholderColor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void updateRenderObject(BuildContext context, ThumbhashImage renderObject) {
|
||||||
|
renderObject.fit = fit;
|
||||||
|
renderObject.image = image;
|
||||||
|
renderObject.placeholderColor = placeholderColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Thumbhash extends StatefulWidget {
|
||||||
|
final String? blurhash;
|
||||||
|
final BoxFit fit;
|
||||||
|
final Color placeholderColor;
|
||||||
|
|
||||||
|
const Thumbhash({
|
||||||
|
required this.blurhash,
|
||||||
|
this.fit = BoxFit.cover,
|
||||||
|
this.placeholderColor = const Color.fromRGBO(0, 0, 0, 0.2),
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<Thumbhash> createState() => _ThumbhashState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ThumbhashState extends State<Thumbhash> {
|
||||||
|
String? blurhash;
|
||||||
|
BoxFit? fit;
|
||||||
|
ui.Image? _image;
|
||||||
|
Color? placeholderColor;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
final blurhash_ = blurhash = widget.blurhash;
|
||||||
|
fit = widget.fit;
|
||||||
|
placeholderColor = widget.placeholderColor;
|
||||||
|
if (blurhash_ == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final image = thumbhash.thumbHashToRGBA(base64.decode(blurhash_));
|
||||||
|
_decode(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _decode(thumbhash.Image image) async {
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final buffer = await ImmutableBuffer.fromUint8List(image.rgba);
|
||||||
|
if (!mounted) {
|
||||||
|
buffer.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final descriptor = ImageDescriptor.raw(
|
||||||
|
buffer,
|
||||||
|
width: image.width,
|
||||||
|
height: image.height,
|
||||||
|
pixelFormat: PixelFormat.rgba8888,
|
||||||
|
);
|
||||||
|
if (!mounted) {
|
||||||
|
buffer.dispose();
|
||||||
|
descriptor.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final codec = await descriptor.instantiateCodec(
|
||||||
|
targetWidth: image.width,
|
||||||
|
targetHeight: image.height,
|
||||||
|
);
|
||||||
|
if (!mounted) {
|
||||||
|
buffer.dispose();
|
||||||
|
descriptor.dispose();
|
||||||
|
codec.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final frame = (await codec.getNextFrame()).image;
|
||||||
|
buffer.dispose();
|
||||||
|
descriptor.dispose();
|
||||||
|
codec.dispose();
|
||||||
|
if (!mounted) {
|
||||||
|
frame.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_image = frame;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ThumbhashLeaf(
|
||||||
|
image: _image,
|
||||||
|
fit: fit!,
|
||||||
|
placeholderColor: placeholderColor!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_image?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:immich_mobile/widgets/asset_grid/thumbnail_placeholder.dart';
|
import 'package:immich_mobile/widgets/common/thumbhash.dart';
|
||||||
import 'package:immich_mobile/widgets/common/fade_in_placeholder_image.dart';
|
|
||||||
import 'package:octo_image/octo_image.dart';
|
import 'package:octo_image/octo_image.dart';
|
||||||
|
|
||||||
/// Simple set to show [OctoPlaceholder.circularProgressIndicator] as
|
/// Simple set to show [OctoPlaceholder.circularProgressIndicator] as
|
||||||
/// placeholder and [OctoError.icon] as error.
|
/// placeholder and [OctoError.icon] as error.
|
||||||
OctoSet blurHashOrPlaceholder(
|
OctoSet blurHashOrPlaceholder(
|
||||||
Uint8List? blurhash, {
|
String? blurhash, {
|
||||||
BoxFit? fit,
|
BoxFit fit = BoxFit.cover,
|
||||||
Text? errorMessage,
|
Text? errorMessage,
|
||||||
}) {
|
}) {
|
||||||
return OctoSet(
|
return OctoSet(
|
||||||
@@ -19,21 +17,15 @@ OctoSet blurHashOrPlaceholder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
OctoPlaceholderBuilder blurHashPlaceholderBuilder(
|
OctoPlaceholderBuilder blurHashPlaceholderBuilder(
|
||||||
Uint8List? blurhash, {
|
String? blurhash, {
|
||||||
BoxFit? fit,
|
required BoxFit fit,
|
||||||
}) {
|
}) {
|
||||||
return (context) => blurhash == null
|
return (context) => Thumbhash(blurhash: blurhash, fit: fit);
|
||||||
? const ThumbnailPlaceholder()
|
|
||||||
: FadeInPlaceholderImage(
|
|
||||||
placeholder: const ThumbnailPlaceholder(),
|
|
||||||
image: MemoryImage(blurhash),
|
|
||||||
fit: fit ?? BoxFit.cover,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OctoErrorBuilder blurHashErrorBuilder(
|
OctoErrorBuilder blurHashErrorBuilder(
|
||||||
Uint8List? blurhash, {
|
String? blurhash, {
|
||||||
BoxFit? fit,
|
BoxFit fit = BoxFit.cover,
|
||||||
Text? message,
|
Text? message,
|
||||||
IconData? icon,
|
IconData? icon,
|
||||||
Color? iconColor,
|
Color? iconColor,
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
|||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/pages/common/native_video_viewer.page.dart';
|
import 'package:immich_mobile/pages/common/native_video_viewer.page.dart';
|
||||||
import 'package:immich_mobile/utils/hooks/blurhash_hook.dart';
|
|
||||||
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
import 'package:immich_mobile/widgets/common/immich_image.dart';
|
||||||
|
import 'package:immich_mobile/widgets/common/thumbhash.dart';
|
||||||
|
|
||||||
class MemoryCard extends StatelessWidget {
|
class MemoryCard extends StatelessWidget {
|
||||||
final Asset asset;
|
final Asset asset;
|
||||||
@@ -113,29 +113,23 @@ class _BlurredBackdrop extends HookWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final blurhash = useBlurHashRef(asset).value;
|
final blurhash = asset.thumbhash;
|
||||||
if (blurhash != null) {
|
if (blurhash != null) {
|
||||||
// Use a nice cheap blur hash image decoration
|
// Use a nice cheap blur hash image decoration
|
||||||
return Container(
|
return Stack(
|
||||||
decoration: BoxDecoration(
|
children: [
|
||||||
image: DecorationImage(
|
const ColoredBox(color: Color.fromRGBO(0, 0, 0, 0.2)),
|
||||||
image: MemoryImage(
|
Thumbhash(blurhash: blurhash, fit: BoxFit.cover),
|
||||||
blurhash,
|
],
|
||||||
),
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.withValues(alpha: 0.2),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// Fall back to using a more expensive image filtered
|
// Fall back to using a more expensive image filtered
|
||||||
// Since the ImmichImage is already precached, we can
|
// Since the ImmichImage is already precached, we can
|
||||||
// safely use that as the image provider
|
// safely use that as the image provider
|
||||||
return ImageFiltered(
|
return ImageFiltered(
|
||||||
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
imageFilter: ImageFilter.blur(sigmaX: 30, sigmaY: 30),
|
||||||
child: Container(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: DecorationImage(
|
image: DecorationImage(
|
||||||
image: ImmichImage.imageProvider(
|
image: ImmichImage.imageProvider(
|
||||||
@@ -146,11 +140,8 @@ class _BlurredBackdrop extends HookWidget {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Container(
|
child: const ColoredBox(color: Color.fromRGBO(0, 0, 0, 0.2)),
|
||||||
color: Colors.black.withValues(alpha: 0.2),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user