mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 01:11:36 +03:00
fix: update JSON serialization for ActionButtonType and improve type safety
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:immich_mobile/domain/models/store.model.dart';
|
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/user.model.dart';
|
import 'package:immich_mobile/domain/models/user.model.dart';
|
||||||
@@ -87,7 +86,11 @@ class IsarStoreRepository extends IsarDatabaseRepository implements IStoreReposi
|
|||||||
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
||||||
const (UserDto) =>
|
const (UserDto) =>
|
||||||
entity.strValue == null ? null : await IsarUserRepository(_db).getByUserId(entity.strValue!),
|
entity.strValue == null ? null : await IsarUserRepository(_db).getByUserId(entity.strValue!),
|
||||||
const (List<ActionButtonType>) => jsonDecode(entity.strValue ?? '[]') as T,
|
const (List<ActionButtonType>) =>
|
||||||
|
(jsonDecode(entity.strValue ?? '[]') as List<dynamic>)
|
||||||
|
.map<ActionButtonType>((d) => ActionButtonType.values.byName(d))
|
||||||
|
.toList()
|
||||||
|
as T,
|
||||||
_ => null,
|
_ => null,
|
||||||
}
|
}
|
||||||
as T?;
|
as T?;
|
||||||
@@ -179,7 +182,11 @@ class DriftStoreRepository extends DriftDatabaseRepository implements IStoreRepo
|
|||||||
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
const (DateTime) => entity.intValue == null ? null : DateTime.fromMillisecondsSinceEpoch(entity.intValue!),
|
||||||
const (UserDto) =>
|
const (UserDto) =>
|
||||||
entity.stringValue == null ? null : await DriftAuthUserRepository(_db).get(entity.stringValue!),
|
entity.stringValue == null ? null : await DriftAuthUserRepository(_db).get(entity.stringValue!),
|
||||||
const (List<ActionButtonType>) => jsonDecode(entity.stringValue ?? '[]') as T,
|
const (List<ActionButtonType>) =>
|
||||||
|
(jsonDecode(entity.stringValue ?? '[]') as List<dynamic>)
|
||||||
|
.map<ActionButtonType>((d) => ActionButtonType.values.byName(d))
|
||||||
|
.toList()
|
||||||
|
as T,
|
||||||
_ => null,
|
_ => null,
|
||||||
}
|
}
|
||||||
as T?;
|
as T?;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ enum ActionButtonType {
|
|||||||
unstack,
|
unstack,
|
||||||
likeActivity;
|
likeActivity;
|
||||||
|
|
||||||
dynamic toJson() => name;
|
String toJson() => name;
|
||||||
|
|
||||||
bool shouldShow(ActionButtonContext context) {
|
bool shouldShow(ActionButtonContext context) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
|
|||||||
Reference in New Issue
Block a user