perf(settings): batch and deduplicate writes and persist panel dimensions
This commit is contained in:
1 parent
bc3fdd6119
commit
02413383d8
23 files changed
+852
-66
No files matched your search
@@ -27,8 +27,8 @@ class AppearanceSettings extends _$AppearanceSettings {
|
|||||||
|
|
||||||
Future<void> setMode(AppAppearance appearance) => _writes.run(() async {
|
Future<void> setMode(AppAppearance appearance) => _writes.run(() async {
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted) return;
|
||||||
await future;
|
final current = await future;
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted || current == appearance) return;
|
||||||
await ref.read(appearanceSettingsRepositoryProvider).save(appearance);
|
await ref.read(appearanceSettingsRepositoryProvider).save(appearance);
|
||||||
if (ref.mounted) state = AsyncData(appearance);
|
if (ref.mounted) state = AsyncData(appearance);
|
||||||
});
|
});
|
||||||
@@ -44,8 +44,8 @@ class PaletteSettings extends _$PaletteSettings {
|
|||||||
|
|
||||||
Future<void> setPalette(AppPalette palette) => _writes.run(() async {
|
Future<void> setPalette(AppPalette palette) => _writes.run(() async {
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted) return;
|
||||||
await future;
|
final current = await future;
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted || current == palette) return;
|
||||||
await ref.read(paletteSettingsRepositoryProvider).save(palette);
|
await ref.read(paletteSettingsRepositoryProvider).save(palette);
|
||||||
if (ref.mounted) state = AsyncData(palette);
|
if (ref.mounted) state = AsyncData(palette);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ final class AppearanceSettingsProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$appearanceSettingsHash() =>
|
String _$appearanceSettingsHash() =>
|
||||||
r'df889bcd3ec16a726ebc1bccd98b9e7033989a69';
|
r'c540755d69e4441b38db07394df144a0fc3544da';
|
||||||
|
|
||||||
abstract class _$AppearanceSettings extends $AsyncNotifier<AppAppearance> {
|
abstract class _$AppearanceSettings extends $AsyncNotifier<AppAppearance> {
|
||||||
FutureOr<AppAppearance> build();
|
FutureOr<AppAppearance> build();
|
||||||
@@ -78,7 +78,7 @@ final class PaletteSettingsProvider
|
|||||||
PaletteSettings create() => PaletteSettings();
|
PaletteSettings create() => PaletteSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$paletteSettingsHash() => r'95eecd4a35c8de3afbf6c94b1e13f282acb0f4ff';
|
String _$paletteSettingsHash() => r'8676c4ef0be0ce7132da7c53b9694da56e9c658d';
|
||||||
|
|
||||||
abstract class _$PaletteSettings extends $AsyncNotifier<AppPalette> {
|
abstract class _$PaletteSettings extends $AsyncNotifier<AppPalette> {
|
||||||
FutureOr<AppPalette> build();
|
FutureOr<AppPalette> build();
|
||||||
|
|||||||
@@ -89,8 +89,8 @@ class LanguageSettings extends _$LanguageSettings {
|
|||||||
|
|
||||||
Future<void> setLanguage(AppLanguage language) => _writes.run(() async {
|
Future<void> setLanguage(AppLanguage language) => _writes.run(() async {
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted) return;
|
||||||
await future;
|
final current = await future;
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted || current == language) return;
|
||||||
await ref.read(languageSettingsRepositoryProvider).save(language);
|
await ref.read(languageSettingsRepositoryProvider).save(language);
|
||||||
if (ref.mounted) state = AsyncData(language);
|
if (ref.mounted) state = AsyncData(language);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ final class LanguageSettingsProvider
|
|||||||
LanguageSettings create() => LanguageSettings();
|
LanguageSettings create() => LanguageSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$languageSettingsHash() => r'fcd5bb7f010ea5bb09f9743d9023cd1668214f43';
|
String _$languageSettingsHash() => r'6a1989abb393d00e262506572b1dfdd5b09be6c4';
|
||||||
|
|
||||||
abstract class _$LanguageSettings extends $AsyncNotifier<AppLanguage> {
|
abstract class _$LanguageSettings extends $AsyncNotifier<AppLanguage> {
|
||||||
FutureOr<AppLanguage> build();
|
FutureOr<AppLanguage> build();
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ class TimelineRulerSettings extends _$TimelineRulerSettings {
|
|||||||
Future<void> setLayout(TimelineRulerTimecodeLayout layout) =>
|
Future<void> setLayout(TimelineRulerTimecodeLayout layout) =>
|
||||||
_writes.run(() async {
|
_writes.run(() async {
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted) return;
|
||||||
await future;
|
final current = await future;
|
||||||
if (!ref.mounted) return;
|
if (!ref.mounted || current == layout) return;
|
||||||
await ref.read(timelineRulerSettingsRepositoryProvider).save(layout);
|
await ref.read(timelineRulerSettingsRepositoryProvider).save(layout);
|
||||||
if (ref.mounted) state = AsyncData(layout);
|
if (ref.mounted) state = AsyncData(layout);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ final class TimelineRulerSettingsProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$timelineRulerSettingsHash() =>
|
String _$timelineRulerSettingsHash() =>
|
||||||
r'26aef397f2aee8114b1d1229bb1c0b3f7a377f73';
|
r'4917c2ec4b2aa715c9e0e2a45cd05adb66ae6089';
|
||||||
|
|
||||||
abstract class _$TimelineRulerSettings
|
abstract class _$TimelineRulerSettings
|
||||||
extends $AsyncNotifier<TimelineRulerTimecodeLayout> {
|
extends $AsyncNotifier<TimelineRulerTimecodeLayout> {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class McpSettings extends _$McpSettings {
|
|||||||
port: port ?? current.port,
|
port: port ?? current.port,
|
||||||
);
|
);
|
||||||
_validate(next);
|
_validate(next);
|
||||||
|
if (next == current) return;
|
||||||
await _persist(next);
|
await _persist(next);
|
||||||
if (ref.mounted) state = AsyncData(next);
|
if (ref.mounted) state = AsyncData(next);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ final class McpSettingsProvider
|
|||||||
McpSettings create() => McpSettings();
|
McpSettings create() => McpSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$mcpSettingsHash() => r'122c5ad73d0eec5808c546eb66dde6c4b0f29a8a';
|
String _$mcpSettingsHash() => r'44c7a3dec17e78b4a67c5de92b1f5ae708af7f84';
|
||||||
|
|
||||||
abstract class _$McpSettings extends $AsyncNotifier<McpSettingsValue> {
|
abstract class _$McpSettings extends $AsyncNotifier<McpSettingsValue> {
|
||||||
FutureOr<McpSettingsValue> build();
|
FutureOr<McpSettingsValue> build();
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ class ProjectViewConfigurations extends Table {
|
|||||||
TextColumn get projectId => text()();
|
TextColumn get projectId => text()();
|
||||||
BoolColumn get propertiesOpen => boolean()();
|
BoolColumn get propertiesOpen => boolean()();
|
||||||
RealColumn get timelineHeight => real().nullable()();
|
RealColumn get timelineHeight => real().nullable()();
|
||||||
|
RealColumn get mediaWidth => real().nullable()();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Set<Column<Object>> get primaryKey => {projectId};
|
Set<Column<Object>> get primaryKey => {projectId};
|
||||||
@@ -169,13 +170,13 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
AppDatabase(super.executor);
|
AppDatabase(super.executor);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get schemaVersion => 4;
|
int get schemaVersion => 5;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MigrationStrategy get migration => MigrationStrategy(
|
MigrationStrategy get migration => MigrationStrategy(
|
||||||
onCreate: (migrator) => migrator.createAll(),
|
onCreate: (migrator) => migrator.createAll(),
|
||||||
onUpgrade: (migrator, from, _) async {
|
onUpgrade: (migrator, from, _) async {
|
||||||
if (from != 2 && from != 3) {
|
if (from < 2 || from > 4) {
|
||||||
throw StateError('Unsupported app database schema version: $from');
|
throw StateError('Unsupported app database schema version: $from');
|
||||||
}
|
}
|
||||||
if (from == 2) {
|
if (from == 2) {
|
||||||
@@ -184,10 +185,16 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
appearanceConfigurations.palette,
|
appearanceConfigurations.palette,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (from < 4) {
|
||||||
await migrator.addColumn(
|
await migrator.addColumn(
|
||||||
appearanceConfigurations,
|
appearanceConfigurations,
|
||||||
appearanceConfigurations.timelineRulerLayout,
|
appearanceConfigurations.timelineRulerLayout,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
await migrator.addColumn(
|
||||||
|
projectViewConfigurations,
|
||||||
|
projectViewConfigurations.mediaWidth,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
beforeOpen: (_) async {
|
beforeOpen: (_) async {
|
||||||
await customStatement('PRAGMA journal_mode = WAL');
|
await customStatement('PRAGMA journal_mode = WAL');
|
||||||
|
|||||||
@@ -3535,11 +3535,23 @@ class $ProjectViewConfigurationsTable extends ProjectViewConfigurations
|
|||||||
type: DriftSqlType.double,
|
type: DriftSqlType.double,
|
||||||
requiredDuringInsert: false,
|
requiredDuringInsert: false,
|
||||||
);
|
);
|
||||||
|
static const VerificationMeta _mediaWidthMeta = const VerificationMeta(
|
||||||
|
'mediaWidth',
|
||||||
|
);
|
||||||
|
@override
|
||||||
|
late final GeneratedColumn<double> mediaWidth = GeneratedColumn<double>(
|
||||||
|
'media_width',
|
||||||
|
aliasedName,
|
||||||
|
true,
|
||||||
|
type: DriftSqlType.double,
|
||||||
|
requiredDuringInsert: false,
|
||||||
|
);
|
||||||
@override
|
@override
|
||||||
List<GeneratedColumn> get $columns => [
|
List<GeneratedColumn> get $columns => [
|
||||||
projectId,
|
projectId,
|
||||||
propertiesOpen,
|
propertiesOpen,
|
||||||
timelineHeight,
|
timelineHeight,
|
||||||
|
mediaWidth,
|
||||||
];
|
];
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@@ -3581,6 +3593,12 @@ class $ProjectViewConfigurationsTable extends ProjectViewConfigurations
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (data.containsKey('media_width')) {
|
||||||
|
context.handle(
|
||||||
|
_mediaWidthMeta,
|
||||||
|
mediaWidth.isAcceptableOrUnknown(data['media_width']!, _mediaWidthMeta),
|
||||||
|
);
|
||||||
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3605,6 +3623,10 @@ class $ProjectViewConfigurationsTable extends ProjectViewConfigurations
|
|||||||
DriftSqlType.double,
|
DriftSqlType.double,
|
||||||
data['${effectivePrefix}timeline_height'],
|
data['${effectivePrefix}timeline_height'],
|
||||||
),
|
),
|
||||||
|
mediaWidth: attachedDatabase.typeMapping.read(
|
||||||
|
DriftSqlType.double,
|
||||||
|
data['${effectivePrefix}media_width'],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3619,10 +3641,12 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
final String projectId;
|
final String projectId;
|
||||||
final bool propertiesOpen;
|
final bool propertiesOpen;
|
||||||
final double? timelineHeight;
|
final double? timelineHeight;
|
||||||
|
final double? mediaWidth;
|
||||||
const ProjectViewConfiguration({
|
const ProjectViewConfiguration({
|
||||||
required this.projectId,
|
required this.projectId,
|
||||||
required this.propertiesOpen,
|
required this.propertiesOpen,
|
||||||
this.timelineHeight,
|
this.timelineHeight,
|
||||||
|
this.mediaWidth,
|
||||||
});
|
});
|
||||||
@override
|
@override
|
||||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
@@ -3632,6 +3656,9 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
if (!nullToAbsent || timelineHeight != null) {
|
if (!nullToAbsent || timelineHeight != null) {
|
||||||
map['timeline_height'] = Variable<double>(timelineHeight);
|
map['timeline_height'] = Variable<double>(timelineHeight);
|
||||||
}
|
}
|
||||||
|
if (!nullToAbsent || mediaWidth != null) {
|
||||||
|
map['media_width'] = Variable<double>(mediaWidth);
|
||||||
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3642,6 +3669,9 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
timelineHeight: timelineHeight == null && nullToAbsent
|
timelineHeight: timelineHeight == null && nullToAbsent
|
||||||
? const Value.absent()
|
? const Value.absent()
|
||||||
: Value(timelineHeight),
|
: Value(timelineHeight),
|
||||||
|
mediaWidth: mediaWidth == null && nullToAbsent
|
||||||
|
? const Value.absent()
|
||||||
|
: Value(mediaWidth),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3654,6 +3684,7 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
projectId: serializer.fromJson<String>(json['projectId']),
|
projectId: serializer.fromJson<String>(json['projectId']),
|
||||||
propertiesOpen: serializer.fromJson<bool>(json['propertiesOpen']),
|
propertiesOpen: serializer.fromJson<bool>(json['propertiesOpen']),
|
||||||
timelineHeight: serializer.fromJson<double?>(json['timelineHeight']),
|
timelineHeight: serializer.fromJson<double?>(json['timelineHeight']),
|
||||||
|
mediaWidth: serializer.fromJson<double?>(json['mediaWidth']),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@@ -3663,6 +3694,7 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
'projectId': serializer.toJson<String>(projectId),
|
'projectId': serializer.toJson<String>(projectId),
|
||||||
'propertiesOpen': serializer.toJson<bool>(propertiesOpen),
|
'propertiesOpen': serializer.toJson<bool>(propertiesOpen),
|
||||||
'timelineHeight': serializer.toJson<double?>(timelineHeight),
|
'timelineHeight': serializer.toJson<double?>(timelineHeight),
|
||||||
|
'mediaWidth': serializer.toJson<double?>(mediaWidth),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3670,12 +3702,14 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
String? projectId,
|
String? projectId,
|
||||||
bool? propertiesOpen,
|
bool? propertiesOpen,
|
||||||
Value<double?> timelineHeight = const Value.absent(),
|
Value<double?> timelineHeight = const Value.absent(),
|
||||||
|
Value<double?> mediaWidth = const Value.absent(),
|
||||||
}) => ProjectViewConfiguration(
|
}) => ProjectViewConfiguration(
|
||||||
projectId: projectId ?? this.projectId,
|
projectId: projectId ?? this.projectId,
|
||||||
propertiesOpen: propertiesOpen ?? this.propertiesOpen,
|
propertiesOpen: propertiesOpen ?? this.propertiesOpen,
|
||||||
timelineHeight: timelineHeight.present
|
timelineHeight: timelineHeight.present
|
||||||
? timelineHeight.value
|
? timelineHeight.value
|
||||||
: this.timelineHeight,
|
: this.timelineHeight,
|
||||||
|
mediaWidth: mediaWidth.present ? mediaWidth.value : this.mediaWidth,
|
||||||
);
|
);
|
||||||
ProjectViewConfiguration copyWithCompanion(
|
ProjectViewConfiguration copyWithCompanion(
|
||||||
ProjectViewConfigurationsCompanion data,
|
ProjectViewConfigurationsCompanion data,
|
||||||
@@ -3688,6 +3722,9 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
timelineHeight: data.timelineHeight.present
|
timelineHeight: data.timelineHeight.present
|
||||||
? data.timelineHeight.value
|
? data.timelineHeight.value
|
||||||
: this.timelineHeight,
|
: this.timelineHeight,
|
||||||
|
mediaWidth: data.mediaWidth.present
|
||||||
|
? data.mediaWidth.value
|
||||||
|
: this.mediaWidth,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3696,20 +3733,23 @@ class ProjectViewConfiguration extends DataClass
|
|||||||
return (StringBuffer('ProjectViewConfiguration(')
|
return (StringBuffer('ProjectViewConfiguration(')
|
||||||
..write('projectId: $projectId, ')
|
..write('projectId: $projectId, ')
|
||||||
..write('propertiesOpen: $propertiesOpen, ')
|
..write('propertiesOpen: $propertiesOpen, ')
|
||||||
..write('timelineHeight: $timelineHeight')
|
..write('timelineHeight: $timelineHeight, ')
|
||||||
|
..write('mediaWidth: $mediaWidth')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(projectId, propertiesOpen, timelineHeight);
|
int get hashCode =>
|
||||||
|
Object.hash(projectId, propertiesOpen, timelineHeight, mediaWidth);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
(other is ProjectViewConfiguration &&
|
(other is ProjectViewConfiguration &&
|
||||||
other.projectId == this.projectId &&
|
other.projectId == this.projectId &&
|
||||||
other.propertiesOpen == this.propertiesOpen &&
|
other.propertiesOpen == this.propertiesOpen &&
|
||||||
other.timelineHeight == this.timelineHeight);
|
other.timelineHeight == this.timelineHeight &&
|
||||||
|
other.mediaWidth == this.mediaWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProjectViewConfigurationsCompanion
|
class ProjectViewConfigurationsCompanion
|
||||||
@@ -3717,17 +3757,20 @@ class ProjectViewConfigurationsCompanion
|
|||||||
final Value<String> projectId;
|
final Value<String> projectId;
|
||||||
final Value<bool> propertiesOpen;
|
final Value<bool> propertiesOpen;
|
||||||
final Value<double?> timelineHeight;
|
final Value<double?> timelineHeight;
|
||||||
|
final Value<double?> mediaWidth;
|
||||||
final Value<int> rowid;
|
final Value<int> rowid;
|
||||||
const ProjectViewConfigurationsCompanion({
|
const ProjectViewConfigurationsCompanion({
|
||||||
this.projectId = const Value.absent(),
|
this.projectId = const Value.absent(),
|
||||||
this.propertiesOpen = const Value.absent(),
|
this.propertiesOpen = const Value.absent(),
|
||||||
this.timelineHeight = const Value.absent(),
|
this.timelineHeight = const Value.absent(),
|
||||||
|
this.mediaWidth = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
});
|
});
|
||||||
ProjectViewConfigurationsCompanion.insert({
|
ProjectViewConfigurationsCompanion.insert({
|
||||||
required String projectId,
|
required String projectId,
|
||||||
required bool propertiesOpen,
|
required bool propertiesOpen,
|
||||||
this.timelineHeight = const Value.absent(),
|
this.timelineHeight = const Value.absent(),
|
||||||
|
this.mediaWidth = const Value.absent(),
|
||||||
this.rowid = const Value.absent(),
|
this.rowid = const Value.absent(),
|
||||||
}) : projectId = Value(projectId),
|
}) : projectId = Value(projectId),
|
||||||
propertiesOpen = Value(propertiesOpen);
|
propertiesOpen = Value(propertiesOpen);
|
||||||
@@ -3735,12 +3778,14 @@ class ProjectViewConfigurationsCompanion
|
|||||||
Expression<String>? projectId,
|
Expression<String>? projectId,
|
||||||
Expression<bool>? propertiesOpen,
|
Expression<bool>? propertiesOpen,
|
||||||
Expression<double>? timelineHeight,
|
Expression<double>? timelineHeight,
|
||||||
|
Expression<double>? mediaWidth,
|
||||||
Expression<int>? rowid,
|
Expression<int>? rowid,
|
||||||
}) {
|
}) {
|
||||||
return RawValuesInsertable({
|
return RawValuesInsertable({
|
||||||
if (projectId != null) 'project_id': projectId,
|
if (projectId != null) 'project_id': projectId,
|
||||||
if (propertiesOpen != null) 'properties_open': propertiesOpen,
|
if (propertiesOpen != null) 'properties_open': propertiesOpen,
|
||||||
if (timelineHeight != null) 'timeline_height': timelineHeight,
|
if (timelineHeight != null) 'timeline_height': timelineHeight,
|
||||||
|
if (mediaWidth != null) 'media_width': mediaWidth,
|
||||||
if (rowid != null) 'rowid': rowid,
|
if (rowid != null) 'rowid': rowid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -3749,12 +3794,14 @@ class ProjectViewConfigurationsCompanion
|
|||||||
Value<String>? projectId,
|
Value<String>? projectId,
|
||||||
Value<bool>? propertiesOpen,
|
Value<bool>? propertiesOpen,
|
||||||
Value<double?>? timelineHeight,
|
Value<double?>? timelineHeight,
|
||||||
|
Value<double?>? mediaWidth,
|
||||||
Value<int>? rowid,
|
Value<int>? rowid,
|
||||||
}) {
|
}) {
|
||||||
return ProjectViewConfigurationsCompanion(
|
return ProjectViewConfigurationsCompanion(
|
||||||
projectId: projectId ?? this.projectId,
|
projectId: projectId ?? this.projectId,
|
||||||
propertiesOpen: propertiesOpen ?? this.propertiesOpen,
|
propertiesOpen: propertiesOpen ?? this.propertiesOpen,
|
||||||
timelineHeight: timelineHeight ?? this.timelineHeight,
|
timelineHeight: timelineHeight ?? this.timelineHeight,
|
||||||
|
mediaWidth: mediaWidth ?? this.mediaWidth,
|
||||||
rowid: rowid ?? this.rowid,
|
rowid: rowid ?? this.rowid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3771,6 +3818,9 @@ class ProjectViewConfigurationsCompanion
|
|||||||
if (timelineHeight.present) {
|
if (timelineHeight.present) {
|
||||||
map['timeline_height'] = Variable<double>(timelineHeight.value);
|
map['timeline_height'] = Variable<double>(timelineHeight.value);
|
||||||
}
|
}
|
||||||
|
if (mediaWidth.present) {
|
||||||
|
map['media_width'] = Variable<double>(mediaWidth.value);
|
||||||
|
}
|
||||||
if (rowid.present) {
|
if (rowid.present) {
|
||||||
map['rowid'] = Variable<int>(rowid.value);
|
map['rowid'] = Variable<int>(rowid.value);
|
||||||
}
|
}
|
||||||
@@ -3783,6 +3833,7 @@ class ProjectViewConfigurationsCompanion
|
|||||||
..write('projectId: $projectId, ')
|
..write('projectId: $projectId, ')
|
||||||
..write('propertiesOpen: $propertiesOpen, ')
|
..write('propertiesOpen: $propertiesOpen, ')
|
||||||
..write('timelineHeight: $timelineHeight, ')
|
..write('timelineHeight: $timelineHeight, ')
|
||||||
|
..write('mediaWidth: $mediaWidth, ')
|
||||||
..write('rowid: $rowid')
|
..write('rowid: $rowid')
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
@@ -6782,6 +6833,7 @@ typedef $$ProjectViewConfigurationsTableCreateCompanionBuilder =
|
|||||||
required String projectId,
|
required String projectId,
|
||||||
required bool propertiesOpen,
|
required bool propertiesOpen,
|
||||||
Value<double?> timelineHeight,
|
Value<double?> timelineHeight,
|
||||||
|
Value<double?> mediaWidth,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
});
|
});
|
||||||
typedef $$ProjectViewConfigurationsTableUpdateCompanionBuilder =
|
typedef $$ProjectViewConfigurationsTableUpdateCompanionBuilder =
|
||||||
@@ -6789,6 +6841,7 @@ typedef $$ProjectViewConfigurationsTableUpdateCompanionBuilder =
|
|||||||
Value<String> projectId,
|
Value<String> projectId,
|
||||||
Value<bool> propertiesOpen,
|
Value<bool> propertiesOpen,
|
||||||
Value<double?> timelineHeight,
|
Value<double?> timelineHeight,
|
||||||
|
Value<double?> mediaWidth,
|
||||||
Value<int> rowid,
|
Value<int> rowid,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -6815,6 +6868,11 @@ class $$ProjectViewConfigurationsTableFilterComposer
|
|||||||
column: $table.timelineHeight,
|
column: $table.timelineHeight,
|
||||||
builder: (column) => ColumnFilters(column),
|
builder: (column) => ColumnFilters(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ColumnFilters<double> get mediaWidth => $composableBuilder(
|
||||||
|
column: $table.mediaWidth,
|
||||||
|
builder: (column) => ColumnFilters(column),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$ProjectViewConfigurationsTableOrderingComposer
|
class $$ProjectViewConfigurationsTableOrderingComposer
|
||||||
@@ -6840,6 +6898,11 @@ class $$ProjectViewConfigurationsTableOrderingComposer
|
|||||||
column: $table.timelineHeight,
|
column: $table.timelineHeight,
|
||||||
builder: (column) => ColumnOrderings(column),
|
builder: (column) => ColumnOrderings(column),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ColumnOrderings<double> get mediaWidth => $composableBuilder(
|
||||||
|
column: $table.mediaWidth,
|
||||||
|
builder: (column) => ColumnOrderings(column),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$ProjectViewConfigurationsTableAnnotationComposer
|
class $$ProjectViewConfigurationsTableAnnotationComposer
|
||||||
@@ -6863,6 +6926,11 @@ class $$ProjectViewConfigurationsTableAnnotationComposer
|
|||||||
column: $table.timelineHeight,
|
column: $table.timelineHeight,
|
||||||
builder: (column) => column,
|
builder: (column) => column,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
GeneratedColumn<double> get mediaWidth => $composableBuilder(
|
||||||
|
column: $table.mediaWidth,
|
||||||
|
builder: (column) => column,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$ProjectViewConfigurationsTableTableManager
|
class $$ProjectViewConfigurationsTableTableManager
|
||||||
@@ -6914,11 +6982,13 @@ class $$ProjectViewConfigurationsTableTableManager
|
|||||||
Value<String> projectId = const Value.absent(),
|
Value<String> projectId = const Value.absent(),
|
||||||
Value<bool> propertiesOpen = const Value.absent(),
|
Value<bool> propertiesOpen = const Value.absent(),
|
||||||
Value<double?> timelineHeight = const Value.absent(),
|
Value<double?> timelineHeight = const Value.absent(),
|
||||||
|
Value<double?> mediaWidth = const Value.absent(),
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
}) => ProjectViewConfigurationsCompanion(
|
}) => ProjectViewConfigurationsCompanion(
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
propertiesOpen: propertiesOpen,
|
propertiesOpen: propertiesOpen,
|
||||||
timelineHeight: timelineHeight,
|
timelineHeight: timelineHeight,
|
||||||
|
mediaWidth: mediaWidth,
|
||||||
rowid: rowid,
|
rowid: rowid,
|
||||||
),
|
),
|
||||||
createCompanionCallback:
|
createCompanionCallback:
|
||||||
@@ -6926,11 +6996,13 @@ class $$ProjectViewConfigurationsTableTableManager
|
|||||||
required String projectId,
|
required String projectId,
|
||||||
required bool propertiesOpen,
|
required bool propertiesOpen,
|
||||||
Value<double?> timelineHeight = const Value.absent(),
|
Value<double?> timelineHeight = const Value.absent(),
|
||||||
|
Value<double?> mediaWidth = const Value.absent(),
|
||||||
Value<int> rowid = const Value.absent(),
|
Value<int> rowid = const Value.absent(),
|
||||||
}) => ProjectViewConfigurationsCompanion.insert(
|
}) => ProjectViewConfigurationsCompanion.insert(
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
propertiesOpen: propertiesOpen,
|
propertiesOpen: propertiesOpen,
|
||||||
timelineHeight: timelineHeight,
|
timelineHeight: timelineHeight,
|
||||||
|
mediaWidth: mediaWidth,
|
||||||
rowid: rowid,
|
rowid: rowid,
|
||||||
),
|
),
|
||||||
withReferenceMapper: (p0) => p0
|
withReferenceMapper: (p0) => p0
|
||||||
|
|||||||
@@ -60,10 +60,9 @@ class DriftAgentSettingsRepository implements AgentSettingsRepository {
|
|||||||
_database.transaction(() async {
|
_database.transaction(() async {
|
||||||
await _database.delete(_database.agentModels).go();
|
await _database.delete(_database.agentModels).go();
|
||||||
await _database.delete(_database.agentProviders).go();
|
await _database.delete(_database.agentProviders).go();
|
||||||
for (final provider in settings.providers) {
|
await _database.batch((batch) {
|
||||||
await _database
|
batch.insertAll(_database.agentProviders, [
|
||||||
.into(_database.agentProviders)
|
for (final provider in settings.providers)
|
||||||
.insert(
|
|
||||||
AgentProvidersCompanion.insert(
|
AgentProvidersCompanion.insert(
|
||||||
id: provider.id,
|
id: provider.id,
|
||||||
enabled: Value(provider.enabled),
|
enabled: Value(provider.enabled),
|
||||||
@@ -72,20 +71,18 @@ class DriftAgentSettingsRepository implements AgentSettingsRepository {
|
|||||||
baseUrl: provider.baseUrl,
|
baseUrl: provider.baseUrl,
|
||||||
credentialId: Value(provider.credentialId),
|
credentialId: Value(provider.credentialId),
|
||||||
),
|
),
|
||||||
);
|
]);
|
||||||
for (final model in provider.models) {
|
batch.insertAll(_database.agentModels, [
|
||||||
await _database
|
for (final provider in settings.providers)
|
||||||
.into(_database.agentModels)
|
for (final model in provider.models)
|
||||||
.insert(
|
|
||||||
AgentModelsCompanion.insert(
|
AgentModelsCompanion.insert(
|
||||||
providerId: provider.id,
|
providerId: provider.id,
|
||||||
modelId: model.id,
|
modelId: model.id,
|
||||||
contextWindow: Value(model.contextWindow),
|
contextWindow: Value(model.contextWindow),
|
||||||
maxOutputTokens: Value(model.maxOutputTokens),
|
maxOutputTokens: Value(model.maxOutputTokens),
|
||||||
),
|
),
|
||||||
);
|
]);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
await _database
|
await _database
|
||||||
.into(_database.agentConfigurations)
|
.into(_database.agentConfigurations)
|
||||||
.insertOnConflictUpdate(
|
.insertOnConflictUpdate(
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ abstract class ProjectViewSettingsData with _$ProjectViewSettingsData {
|
|||||||
const factory ProjectViewSettingsData({
|
const factory ProjectViewSettingsData({
|
||||||
@Default(false) bool propertiesOpen,
|
@Default(false) bool propertiesOpen,
|
||||||
double? timelineHeight,
|
double? timelineHeight,
|
||||||
|
double? mediaWidth,
|
||||||
}) = _ProjectViewSettingsData;
|
}) = _ProjectViewSettingsData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ class DriftProjectViewSettingsRepository
|
|||||||
: ProjectViewSettingsData(
|
: ProjectViewSettingsData(
|
||||||
propertiesOpen: row.propertiesOpen,
|
propertiesOpen: row.propertiesOpen,
|
||||||
timelineHeight: row.timelineHeight,
|
timelineHeight: row.timelineHeight,
|
||||||
|
mediaWidth: row.mediaWidth,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +115,7 @@ class DriftProjectViewSettingsRepository
|
|||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
propertiesOpen: settings.propertiesOpen,
|
propertiesOpen: settings.propertiesOpen,
|
||||||
timelineHeight: Value(settings.timelineHeight),
|
timelineHeight: Value(settings.timelineHeight),
|
||||||
|
mediaWidth: Value(settings.mediaWidth),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -464,6 +464,7 @@ class __$WorkspaceViewSettingsDataCopyWithImpl<$Res>
|
|||||||
mixin _$ProjectViewSettingsData {
|
mixin _$ProjectViewSettingsData {
|
||||||
bool get propertiesOpen;
|
bool get propertiesOpen;
|
||||||
double? get timelineHeight;
|
double? get timelineHeight;
|
||||||
|
double? get mediaWidth;
|
||||||
|
|
||||||
/// Create a copy of ProjectViewSettingsData
|
/// Create a copy of ProjectViewSettingsData
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -484,19 +485,26 @@ mixin _$ProjectViewSettingsData {
|
|||||||
(identical(other.propertiesOpen, _this.propertiesOpen) ||
|
(identical(other.propertiesOpen, _this.propertiesOpen) ||
|
||||||
other.propertiesOpen == _this.propertiesOpen) &&
|
other.propertiesOpen == _this.propertiesOpen) &&
|
||||||
(identical(other.timelineHeight, _this.timelineHeight) ||
|
(identical(other.timelineHeight, _this.timelineHeight) ||
|
||||||
other.timelineHeight == _this.timelineHeight));
|
other.timelineHeight == _this.timelineHeight) &&
|
||||||
|
(identical(other.mediaWidth, _this.mediaWidth) ||
|
||||||
|
other.mediaWidth == _this.mediaWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
final _this = this as ProjectViewSettingsData;
|
final _this = this as ProjectViewSettingsData;
|
||||||
return Object.hash(runtimeType, _this.propertiesOpen, _this.timelineHeight);
|
return Object.hash(
|
||||||
|
runtimeType,
|
||||||
|
_this.propertiesOpen,
|
||||||
|
_this.timelineHeight,
|
||||||
|
_this.mediaWidth,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
final _this = this as ProjectViewSettingsData;
|
final _this = this as ProjectViewSettingsData;
|
||||||
return 'ProjectViewSettingsData(propertiesOpen: ${_this.propertiesOpen}, timelineHeight: ${_this.timelineHeight})';
|
return 'ProjectViewSettingsData(propertiesOpen: ${_this.propertiesOpen}, timelineHeight: ${_this.timelineHeight}, mediaWidth: ${_this.mediaWidth})';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +515,7 @@ abstract mixin class $ProjectViewSettingsDataCopyWith<$Res> {
|
|||||||
$Res Function(ProjectViewSettingsData) _then,
|
$Res Function(ProjectViewSettingsData) _then,
|
||||||
) = _$ProjectViewSettingsDataCopyWithImpl;
|
) = _$ProjectViewSettingsDataCopyWithImpl;
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({bool propertiesOpen, double? timelineHeight});
|
$Res call({bool propertiesOpen, double? timelineHeight, double? mediaWidth});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -522,7 +530,11 @@ class _$ProjectViewSettingsDataCopyWithImpl<$Res>
|
|||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
@override
|
@override
|
||||||
$Res call({Object? propertiesOpen = null, Object? timelineHeight = freezed}) {
|
$Res call({
|
||||||
|
Object? propertiesOpen = null,
|
||||||
|
Object? timelineHeight = freezed,
|
||||||
|
Object? mediaWidth = freezed,
|
||||||
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
ProjectViewSettingsData(
|
ProjectViewSettingsData(
|
||||||
propertiesOpen: null == propertiesOpen
|
propertiesOpen: null == propertiesOpen
|
||||||
@@ -533,6 +545,10 @@ class _$ProjectViewSettingsDataCopyWithImpl<$Res>
|
|||||||
? _self.timelineHeight
|
? _self.timelineHeight
|
||||||
: timelineHeight // ignore: cast_nullable_to_non_nullable
|
: timelineHeight // ignore: cast_nullable_to_non_nullable
|
||||||
as double?,
|
as double?,
|
||||||
|
mediaWidth: freezed == mediaWidth
|
||||||
|
? _self.mediaWidth
|
||||||
|
: mediaWidth // ignore: cast_nullable_to_non_nullable
|
||||||
|
as double?,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -631,13 +647,22 @@ extension ProjectViewSettingsDataPatterns on ProjectViewSettingsData {
|
|||||||
|
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult maybeWhen<TResult extends Object?>(
|
TResult maybeWhen<TResult extends Object?>(
|
||||||
TResult Function(bool propertiesOpen, double? timelineHeight)? $default, {
|
TResult Function(
|
||||||
|
bool propertiesOpen,
|
||||||
|
double? timelineHeight,
|
||||||
|
double? mediaWidth,
|
||||||
|
)?
|
||||||
|
$default, {
|
||||||
required TResult orElse(),
|
required TResult orElse(),
|
||||||
}) {
|
}) {
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _ProjectViewSettingsData() when $default != null:
|
case _ProjectViewSettingsData() when $default != null:
|
||||||
return $default(_that.propertiesOpen, _that.timelineHeight);
|
return $default(
|
||||||
|
_that.propertiesOpen,
|
||||||
|
_that.timelineHeight,
|
||||||
|
_that.mediaWidth,
|
||||||
|
);
|
||||||
case _:
|
case _:
|
||||||
return orElse();
|
return orElse();
|
||||||
}
|
}
|
||||||
@@ -658,12 +683,21 @@ extension ProjectViewSettingsDataPatterns on ProjectViewSettingsData {
|
|||||||
|
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>(
|
TResult when<TResult extends Object?>(
|
||||||
TResult Function(bool propertiesOpen, double? timelineHeight) $default,
|
TResult Function(
|
||||||
|
bool propertiesOpen,
|
||||||
|
double? timelineHeight,
|
||||||
|
double? mediaWidth,
|
||||||
|
)
|
||||||
|
$default,
|
||||||
) {
|
) {
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _ProjectViewSettingsData():
|
case _ProjectViewSettingsData():
|
||||||
return $default(_that.propertiesOpen, _that.timelineHeight);
|
return $default(
|
||||||
|
_that.propertiesOpen,
|
||||||
|
_that.timelineHeight,
|
||||||
|
_that.mediaWidth,
|
||||||
|
);
|
||||||
case _:
|
case _:
|
||||||
throw StateError('Unexpected subclass');
|
throw StateError('Unexpected subclass');
|
||||||
}
|
}
|
||||||
@@ -683,12 +717,21 @@ extension ProjectViewSettingsDataPatterns on ProjectViewSettingsData {
|
|||||||
|
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult? whenOrNull<TResult extends Object?>(
|
TResult? whenOrNull<TResult extends Object?>(
|
||||||
TResult? Function(bool propertiesOpen, double? timelineHeight)? $default,
|
TResult? Function(
|
||||||
|
bool propertiesOpen,
|
||||||
|
double? timelineHeight,
|
||||||
|
double? mediaWidth,
|
||||||
|
)?
|
||||||
|
$default,
|
||||||
) {
|
) {
|
||||||
final _that = this;
|
final _that = this;
|
||||||
switch (_that) {
|
switch (_that) {
|
||||||
case _ProjectViewSettingsData() when $default != null:
|
case _ProjectViewSettingsData() when $default != null:
|
||||||
return $default(_that.propertiesOpen, _that.timelineHeight);
|
return $default(
|
||||||
|
_that.propertiesOpen,
|
||||||
|
_that.timelineHeight,
|
||||||
|
_that.mediaWidth,
|
||||||
|
);
|
||||||
case _:
|
case _:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -701,6 +744,7 @@ class _ProjectViewSettingsData extends ProjectViewSettingsData {
|
|||||||
const _ProjectViewSettingsData({
|
const _ProjectViewSettingsData({
|
||||||
this.propertiesOpen = false,
|
this.propertiesOpen = false,
|
||||||
this.timelineHeight,
|
this.timelineHeight,
|
||||||
|
this.mediaWidth,
|
||||||
}) : super._();
|
}) : super._();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -708,6 +752,8 @@ class _ProjectViewSettingsData extends ProjectViewSettingsData {
|
|||||||
final bool propertiesOpen;
|
final bool propertiesOpen;
|
||||||
@override
|
@override
|
||||||
final double? timelineHeight;
|
final double? timelineHeight;
|
||||||
|
@override
|
||||||
|
final double? mediaWidth;
|
||||||
|
|
||||||
/// Create a copy of ProjectViewSettingsData
|
/// Create a copy of ProjectViewSettingsData
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@@ -728,17 +774,19 @@ class _ProjectViewSettingsData extends ProjectViewSettingsData {
|
|||||||
(identical(other.propertiesOpen, propertiesOpen) ||
|
(identical(other.propertiesOpen, propertiesOpen) ||
|
||||||
other.propertiesOpen == propertiesOpen) &&
|
other.propertiesOpen == propertiesOpen) &&
|
||||||
(identical(other.timelineHeight, timelineHeight) ||
|
(identical(other.timelineHeight, timelineHeight) ||
|
||||||
other.timelineHeight == timelineHeight));
|
other.timelineHeight == timelineHeight) &&
|
||||||
|
(identical(other.mediaWidth, mediaWidth) ||
|
||||||
|
other.mediaWidth == mediaWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode {
|
int get hashCode {
|
||||||
return Object.hash(runtimeType, propertiesOpen, timelineHeight);
|
return Object.hash(runtimeType, propertiesOpen, timelineHeight, mediaWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ProjectViewSettingsData(propertiesOpen: $propertiesOpen, timelineHeight: $timelineHeight)';
|
return 'ProjectViewSettingsData(propertiesOpen: $propertiesOpen, timelineHeight: $timelineHeight, mediaWidth: $mediaWidth)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +799,7 @@ abstract mixin class _$ProjectViewSettingsDataCopyWith<$Res>
|
|||||||
) = __$ProjectViewSettingsDataCopyWithImpl;
|
) = __$ProjectViewSettingsDataCopyWithImpl;
|
||||||
@override
|
@override
|
||||||
@useResult
|
@useResult
|
||||||
$Res call({bool propertiesOpen, double? timelineHeight});
|
$Res call({bool propertiesOpen, double? timelineHeight, double? mediaWidth});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -766,7 +814,11 @@ class __$ProjectViewSettingsDataCopyWithImpl<$Res>
|
|||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
@override
|
||||||
@pragma('vm:prefer-inline')
|
@pragma('vm:prefer-inline')
|
||||||
$Res call({Object? propertiesOpen = null, Object? timelineHeight = freezed}) {
|
$Res call({
|
||||||
|
Object? propertiesOpen = null,
|
||||||
|
Object? timelineHeight = freezed,
|
||||||
|
Object? mediaWidth = freezed,
|
||||||
|
}) {
|
||||||
return _then(
|
return _then(
|
||||||
_ProjectViewSettingsData(
|
_ProjectViewSettingsData(
|
||||||
propertiesOpen: null == propertiesOpen
|
propertiesOpen: null == propertiesOpen
|
||||||
@@ -777,6 +829,10 @@ class __$ProjectViewSettingsDataCopyWithImpl<$Res>
|
|||||||
? _self.timelineHeight
|
? _self.timelineHeight
|
||||||
: timelineHeight // ignore: cast_nullable_to_non_nullable
|
: timelineHeight // ignore: cast_nullable_to_non_nullable
|
||||||
as double?,
|
as double?,
|
||||||
|
mediaWidth: freezed == mediaWidth
|
||||||
|
? _self.mediaWidth
|
||||||
|
: mediaWidth // ignore: cast_nullable_to_non_nullable
|
||||||
|
as double?,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ final class TimelineViewStateBinding {
|
|||||||
session,
|
session,
|
||||||
repository,
|
repository,
|
||||||
);
|
);
|
||||||
|
binding._savedViews.addAll(saved.sequences);
|
||||||
|
binding._savedActiveSequenceId = saved.activeSequenceId;
|
||||||
for (final sequenceId in sequenceIds) {
|
for (final sequenceId in sequenceIds) {
|
||||||
final controller = session.view(sequenceId);
|
final controller = session.view(sequenceId);
|
||||||
void listener() => binding._schedule(sequenceId);
|
void listener() => binding._schedule(sequenceId);
|
||||||
@@ -133,6 +135,8 @@ final class TimelineViewStateBinding {
|
|||||||
final EditorTimelineSession session;
|
final EditorTimelineSession session;
|
||||||
final TimelineViewSettingsRepository repository;
|
final TimelineViewSettingsRepository repository;
|
||||||
final Map<SequenceId, void Function()> _listeners = {};
|
final Map<SequenceId, void Function()> _listeners = {};
|
||||||
|
final Map<SequenceId, TimelineSequenceViewState> _savedViews = {};
|
||||||
|
SequenceId? _savedActiveSequenceId;
|
||||||
SequenceId? _activeSequenceId;
|
SequenceId? _activeSequenceId;
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
Future<void> _tail = Future.value();
|
Future<void> _tail = Future.value();
|
||||||
@@ -162,21 +166,36 @@ final class TimelineViewStateBinding {
|
|||||||
|
|
||||||
Future<void> _save(SequenceId sequenceId) async {
|
Future<void> _save(SequenceId sequenceId) async {
|
||||||
final controller = session.view(sequenceId);
|
final controller = session.view(sequenceId);
|
||||||
try {
|
final value = TimelineSequenceViewState(
|
||||||
await repository.save(
|
|
||||||
projectId,
|
|
||||||
timelineId,
|
|
||||||
sequenceId,
|
|
||||||
TimelineSequenceViewState(
|
|
||||||
playheadTick: controller.playheadTick,
|
playheadTick: controller.playheadTick,
|
||||||
camera: controller.camera,
|
camera: controller.camera,
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
// Selection notifications and closing can repeat the last persisted view.
|
||||||
|
// A sequence switch must still update the repository's active sequence.
|
||||||
|
if (_savedActiveSequenceId == sequenceId &&
|
||||||
|
_sameView(_savedViews[sequenceId], value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await repository.save(projectId, timelineId, sequenceId, value);
|
||||||
|
_savedViews[sequenceId] = value;
|
||||||
|
_savedActiveSequenceId = sequenceId;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// View state must never block editing or project persistence.
|
// View state must never block editing or project persistence.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _sameView(
|
||||||
|
TimelineSequenceViewState? saved,
|
||||||
|
TimelineSequenceViewState next,
|
||||||
|
) =>
|
||||||
|
saved != null &&
|
||||||
|
saved.playheadTick == next.playheadTick &&
|
||||||
|
saved.camera.baseTick == next.camera.baseTick &&
|
||||||
|
saved.camera.fractionalTick == next.camera.fractionalTick &&
|
||||||
|
saved.camera.pixelsPerTick == next.camera.pixelsPerTick &&
|
||||||
|
saved.camera.verticalOffset == next.camera.verticalOffset;
|
||||||
|
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
if (_closed) return;
|
if (_closed) return;
|
||||||
_closed = true;
|
_closed = true;
|
||||||
|
|||||||
@@ -12,11 +12,21 @@ part 'view_settings.g.dart';
|
|||||||
@Riverpod(keepAlive: true)
|
@Riverpod(keepAlive: true)
|
||||||
class WorkspaceViewSettings extends _$WorkspaceViewSettings {
|
class WorkspaceViewSettings extends _$WorkspaceViewSettings {
|
||||||
final _writes = SettingsWriteQueue();
|
final _writes = SettingsWriteQueue();
|
||||||
|
WorkspaceViewSettingsRepository? _savedRepository;
|
||||||
|
WorkspaceViewSettingsData? _savedValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<WorkspaceViewSettingsData> build() async {
|
Future<WorkspaceViewSettingsData> build() async {
|
||||||
|
_savedRepository = null;
|
||||||
|
_savedValue = null;
|
||||||
|
final repository = ref.watch(workspaceViewSettingsRepositoryProvider);
|
||||||
try {
|
try {
|
||||||
return await ref.watch(workspaceViewSettingsRepositoryProvider).load();
|
final value = await repository.load();
|
||||||
|
if (value.hasSavedState) {
|
||||||
|
_savedRepository = repository;
|
||||||
|
_savedValue = value;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
AppDiagnostics.failure(
|
AppDiagnostics.failure(
|
||||||
'settings',
|
'settings',
|
||||||
@@ -43,7 +53,14 @@ class WorkspaceViewSettings extends _$WorkspaceViewSettings {
|
|||||||
final value = state.requireValue.copyWith(activeProjectId: activeProjectId);
|
final value = state.requireValue.copyWith(activeProjectId: activeProjectId);
|
||||||
state = AsyncData(value);
|
state = AsyncData(value);
|
||||||
final repository = ref.read(workspaceViewSettingsRepositoryProvider);
|
final repository = ref.read(workspaceViewSettingsRepositoryProvider);
|
||||||
return _writes.run(() => repository.save(value));
|
return _writes.run(() async {
|
||||||
|
if (identical(repository, _savedRepository) && value == _savedValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await repository.save(value);
|
||||||
|
_savedRepository = repository;
|
||||||
|
_savedValue = value;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,13 +68,19 @@ class WorkspaceViewSettings extends _$WorkspaceViewSettings {
|
|||||||
@Riverpod(keepAlive: true)
|
@Riverpod(keepAlive: true)
|
||||||
class ProjectViewSettings extends _$ProjectViewSettings {
|
class ProjectViewSettings extends _$ProjectViewSettings {
|
||||||
final _writes = SettingsWriteQueue();
|
final _writes = SettingsWriteQueue();
|
||||||
|
ProjectViewSettingsRepository? _savedRepository;
|
||||||
|
ProjectViewSettingsData? _savedValue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ProjectViewSettingsData> build(String projectId) async {
|
Future<ProjectViewSettingsData> build(String projectId) async {
|
||||||
|
_savedRepository = null;
|
||||||
|
_savedValue = null;
|
||||||
|
final repository = ref.watch(projectViewSettingsRepositoryProvider);
|
||||||
try {
|
try {
|
||||||
return await ref
|
final value = await repository.load(projectId);
|
||||||
.watch(projectViewSettingsRepositoryProvider)
|
_savedRepository = repository;
|
||||||
.load(projectId);
|
_savedValue = value;
|
||||||
|
return value;
|
||||||
} catch (error, stackTrace) {
|
} catch (error, stackTrace) {
|
||||||
AppDiagnostics.failure('settings', 'loadProjectView', error, stackTrace);
|
AppDiagnostics.failure('settings', 'loadProjectView', error, stackTrace);
|
||||||
return const ProjectViewSettingsData();
|
return const ProjectViewSettingsData();
|
||||||
@@ -70,9 +93,19 @@ class ProjectViewSettings extends _$ProjectViewSettings {
|
|||||||
void setTimelineHeight(double? height) =>
|
void setTimelineHeight(double? height) =>
|
||||||
state = AsyncData(state.requireValue.copyWith(timelineHeight: height));
|
state = AsyncData(state.requireValue.copyWith(timelineHeight: height));
|
||||||
|
|
||||||
|
void setMediaWidth(double? width) =>
|
||||||
|
state = AsyncData(state.requireValue.copyWith(mediaWidth: width));
|
||||||
|
|
||||||
Future<void> save() {
|
Future<void> save() {
|
||||||
final value = state.requireValue;
|
final value = state.requireValue;
|
||||||
final repository = ref.read(projectViewSettingsRepositoryProvider);
|
final repository = ref.read(projectViewSettingsRepositoryProvider);
|
||||||
return _writes.run(() => repository.save(projectId, value));
|
return _writes.run(() async {
|
||||||
|
if (identical(repository, _savedRepository) && value == _savedValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await repository.save(projectId, value);
|
||||||
|
_savedRepository = repository;
|
||||||
|
_savedValue = value;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ final class WorkspaceViewSettingsProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$workspaceViewSettingsHash() =>
|
String _$workspaceViewSettingsHash() =>
|
||||||
r'35836b74a1bbd2718e9a381d5623255ff507c63a';
|
r'4b333ecfae5603a101b76117b44e008b389d0f27';
|
||||||
|
|
||||||
/// Persistent navigation preferences, shared by the application surface.
|
/// Persistent navigation preferences, shared by the application surface.
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ final class ProjectViewSettingsProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$projectViewSettingsHash() =>
|
String _$projectViewSettingsHash() =>
|
||||||
r'c036088de9f39789b8604c48000a63a52517c966';
|
r'e072707714bf53ba058f10482397572f50dfb75a';
|
||||||
|
|
||||||
/// Project preferences survive timeline switches and widget reconstruction.
|
/// Project preferences survive timeline switches and widget reconstruction.
|
||||||
|
|
||||||
|
|||||||
+175
-4
@@ -15,6 +15,61 @@ import 'package:path/path.dart' as p;
|
|||||||
import 'package:sqlite3/sqlite3.dart';
|
import 'package:sqlite3/sqlite3.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
for (final version in [2, 3, 4]) {
|
||||||
|
test(
|
||||||
|
'schema $version upgrades while preserving project preferences',
|
||||||
|
() async {
|
||||||
|
final directory = await Directory.systemTemp.createTemp(
|
||||||
|
'app-view-schema-',
|
||||||
|
);
|
||||||
|
addTearDown(() => directory.delete(recursive: true));
|
||||||
|
final file = File(p.join(directory.path, 'app.sqlite'));
|
||||||
|
final current = AppDatabase(NativeDatabase(file));
|
||||||
|
await DriftProjectViewSettingsRepository(current).save(
|
||||||
|
'project',
|
||||||
|
const ProjectViewSettingsData(
|
||||||
|
propertiesOpen: true,
|
||||||
|
timelineHeight: 280,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await current.close();
|
||||||
|
final old = sqlite3.open(file.path);
|
||||||
|
try {
|
||||||
|
old.execute(
|
||||||
|
'ALTER TABLE project_view_configurations DROP COLUMN media_width',
|
||||||
|
);
|
||||||
|
if (version < 4) {
|
||||||
|
old.execute(
|
||||||
|
'ALTER TABLE appearance_configurations DROP COLUMN timeline_ruler_layout',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (version == 2) {
|
||||||
|
old.execute(
|
||||||
|
'ALTER TABLE appearance_configurations DROP COLUMN palette',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
old.userVersion = version;
|
||||||
|
} finally {
|
||||||
|
old.close();
|
||||||
|
}
|
||||||
|
final reopened = AppDatabase(NativeDatabase(file));
|
||||||
|
addTearDown(reopened.close);
|
||||||
|
final repository = DriftProjectViewSettingsRepository(reopened);
|
||||||
|
final restored = await repository.load('project');
|
||||||
|
expect(restored.propertiesOpen, isTrue);
|
||||||
|
expect(restored.timelineHeight, 280);
|
||||||
|
expect(restored.mediaWidth, isNull);
|
||||||
|
await repository.save('project', restored.copyWith(mediaWidth: 380));
|
||||||
|
expect((await repository.load('project')).mediaWidth, 380);
|
||||||
|
expect(
|
||||||
|
(await reopened.customSelect('PRAGMA user_version').getSingle())
|
||||||
|
.read<int>('user_version'),
|
||||||
|
5,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'old app settings schema is rejected without changing its data',
|
'old app settings schema is rejected without changing its data',
|
||||||
() async {
|
() async {
|
||||||
@@ -85,13 +140,117 @@ void main() {
|
|||||||
expect(loaded.providers.single.models.single.id, 'model');
|
expect(loaded.providers.single.models.single.id, 'model');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'batched agent settings replace providers and all their models',
|
||||||
|
() async {
|
||||||
|
final database = AppDatabase(NativeDatabase.memory());
|
||||||
|
addTearDown(database.close);
|
||||||
|
final repository = DriftAgentSettingsRepository(database);
|
||||||
|
await repository.save(
|
||||||
|
AgentSettingsState(
|
||||||
|
enabled: true,
|
||||||
|
selectedProviderId: 'one',
|
||||||
|
selectedModelId: 'model-0',
|
||||||
|
revision: 1,
|
||||||
|
providers: [
|
||||||
|
for (final id in ['one', 'two'])
|
||||||
|
AgentProviderSettings(
|
||||||
|
id: id,
|
||||||
|
name: id,
|
||||||
|
apiType: 'openAiChatCompletions',
|
||||||
|
baseUrl: 'https://example.com/v1',
|
||||||
|
credentialId: 'credential-$id',
|
||||||
|
models: [
|
||||||
|
for (var index = 0; index < 50; index++)
|
||||||
|
AgentModelSettings(
|
||||||
|
id: 'model-$index',
|
||||||
|
contextWindow: 32000 + index,
|
||||||
|
maxOutputTokens: 4096,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final saved = await repository.load();
|
||||||
|
expect(saved.providers, hasLength(2));
|
||||||
|
for (final provider in saved.providers) {
|
||||||
|
expect(provider.models, hasLength(50));
|
||||||
|
expect(
|
||||||
|
provider.models.singleWhere((m) => m.id == 'model-49').contextWindow,
|
||||||
|
32049,
|
||||||
|
);
|
||||||
|
expect(provider.credentialId, 'credential-${provider.id}');
|
||||||
|
}
|
||||||
|
final replacement = saved.copyWith(
|
||||||
|
revision: 2,
|
||||||
|
selectedModelId: 'replacement',
|
||||||
|
providers: [
|
||||||
|
saved.providers.first.copyWith(
|
||||||
|
models: const [AgentModelSettings(id: 'replacement')],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
await repository.save(replacement);
|
||||||
|
expect(await repository.load(), replacement);
|
||||||
|
await repository.save(const AgentSettingsState(revision: 3));
|
||||||
|
expect(await repository.load(), const AgentSettingsState(revision: 3));
|
||||||
|
expect(await database.select(database.agentModels).get(), isEmpty);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'a failed agent model batch rolls back the whole configuration',
|
||||||
|
() async {
|
||||||
|
final database = AppDatabase(NativeDatabase.memory());
|
||||||
|
addTearDown(database.close);
|
||||||
|
final repository = DriftAgentSettingsRepository(database);
|
||||||
|
const saved = AgentSettingsState(
|
||||||
|
enabled: true,
|
||||||
|
selectedProviderId: 'provider',
|
||||||
|
selectedModelId: 'model',
|
||||||
|
revision: 1,
|
||||||
|
providers: [
|
||||||
|
AgentProviderSettings(
|
||||||
|
id: 'provider',
|
||||||
|
name: 'Provider',
|
||||||
|
apiType: 'openAiChatCompletions',
|
||||||
|
baseUrl: 'https://example.com/v1',
|
||||||
|
models: [AgentModelSettings(id: 'model')],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
await repository.save(saved);
|
||||||
|
final invalid = saved.copyWith(
|
||||||
|
enabled: false,
|
||||||
|
revision: 2,
|
||||||
|
providers: [
|
||||||
|
saved.providers.single.copyWith(
|
||||||
|
models: const [
|
||||||
|
AgentModelSettings(id: 'duplicate'),
|
||||||
|
AgentModelSettings(id: 'duplicate'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
await expectLater(
|
||||||
|
repository.save(invalid),
|
||||||
|
throwsA(isA<SqliteException>()),
|
||||||
|
);
|
||||||
|
expect(await repository.load(), saved);
|
||||||
|
final retry = saved.copyWith(enabled: false, revision: 2);
|
||||||
|
await repository.save(retry);
|
||||||
|
expect(await repository.load(), retry);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('typed app repositories share one Drift database', () async {
|
test('typed app repositories share one Drift database', () async {
|
||||||
final database = AppDatabase(NativeDatabase.memory());
|
final database = AppDatabase(NativeDatabase.memory());
|
||||||
addTearDown(database.close);
|
addTearDown(database.close);
|
||||||
expect(
|
expect(
|
||||||
(await database.customSelect('PRAGMA user_version').getSingle())
|
(await database.customSelect('PRAGMA user_version').getSingle())
|
||||||
.read<int>('user_version'),
|
.read<int>('user_version'),
|
||||||
4,
|
5,
|
||||||
);
|
);
|
||||||
|
|
||||||
final appearance = DriftAppearanceSettingsRepository(database);
|
final appearance = DriftAppearanceSettingsRepository(database);
|
||||||
@@ -194,11 +353,16 @@ void main() {
|
|||||||
final projectView = DriftProjectViewSettingsRepository(database);
|
final projectView = DriftProjectViewSettingsRepository(database);
|
||||||
await projectView.save(
|
await projectView.save(
|
||||||
'two',
|
'two',
|
||||||
const ProjectViewSettingsData(propertiesOpen: true, timelineHeight: 280),
|
const ProjectViewSettingsData(
|
||||||
|
propertiesOpen: true,
|
||||||
|
timelineHeight: 280,
|
||||||
|
mediaWidth: 360,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
final projectValue = await projectView.load('two');
|
final projectValue = await projectView.load('two');
|
||||||
expect(projectValue.propertiesOpen, isTrue);
|
expect(projectValue.propertiesOpen, isTrue);
|
||||||
expect(projectValue.timelineHeight, 280);
|
expect(projectValue.timelineHeight, 280);
|
||||||
|
expect(projectValue.mediaWidth, 360);
|
||||||
|
|
||||||
final timelineView = DriftTimelineViewSettingsRepository(database);
|
final timelineView = DriftTimelineViewSettingsRepository(database);
|
||||||
await timelineView.save(
|
await timelineView.save(
|
||||||
@@ -343,8 +507,10 @@ void main() {
|
|||||||
sidebarWidth: 300,
|
sidebarWidth: 300,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await DriftProjectViewSettingsRepository(first)
|
await DriftProjectViewSettingsRepository(first).save(
|
||||||
.save('project', const ProjectViewSettingsData(propertiesOpen: true));
|
'project',
|
||||||
|
const ProjectViewSettingsData(propertiesOpen: true, mediaWidth: 380),
|
||||||
|
);
|
||||||
await DriftTimelineViewSettingsRepository(first).save(
|
await DriftTimelineViewSettingsRepository(first).save(
|
||||||
'project',
|
'project',
|
||||||
'timeline',
|
'timeline',
|
||||||
@@ -392,6 +558,11 @@ void main() {
|
|||||||
.propertiesOpen,
|
.propertiesOpen,
|
||||||
isTrue,
|
isTrue,
|
||||||
);
|
);
|
||||||
|
expect(
|
||||||
|
(await DriftProjectViewSettingsRepository(reopened).load('project'))
|
||||||
|
.mediaWidth,
|
||||||
|
380,
|
||||||
|
);
|
||||||
final timeline = await DriftTimelineViewSettingsRepository(reopened)
|
final timeline = await DriftTimelineViewSettingsRepository(reopened)
|
||||||
.load('project', 'timeline');
|
.load('project', 'timeline');
|
||||||
expect(timeline.activeSequenceId, SequenceId('sequence'));
|
expect(timeline.activeSequenceId, SequenceId('sequence'));
|
||||||
|
|||||||
@@ -12,6 +12,39 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'support/memory_app_settings.dart';
|
import 'support/memory_app_settings.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
test(
|
||||||
|
'MCP persists its initial token once and skips unchanged updates',
|
||||||
|
() async {
|
||||||
|
final repository = _CountingMcpRepository();
|
||||||
|
final container = ProviderContainer.test(
|
||||||
|
overrides: [
|
||||||
|
mcpSettingsRepositoryProvider.overrideWithValue(repository),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final initial = await container.read(mcpSettingsProvider.future);
|
||||||
|
expect(repository.writes, hasLength(1));
|
||||||
|
final controller = container.read(mcpSettingsProvider.notifier);
|
||||||
|
await controller.saveSettings(
|
||||||
|
enabled: initial.enabled,
|
||||||
|
port: initial.port,
|
||||||
|
);
|
||||||
|
await Future.wait(
|
||||||
|
List.generate(5, (_) => controller.saveSettings(enabled: true)),
|
||||||
|
);
|
||||||
|
expect(repository.writes, hasLength(2));
|
||||||
|
expect(repository.value!.token, initial.token);
|
||||||
|
repository.failWrites = true;
|
||||||
|
await expectLater(
|
||||||
|
controller.saveSettings(enabled: false),
|
||||||
|
throwsStateError,
|
||||||
|
);
|
||||||
|
repository.failWrites = false;
|
||||||
|
await controller.saveSettings(enabled: false);
|
||||||
|
expect(repository.writes, hasLength(4));
|
||||||
|
expect(repository.value!.enabled, false);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('overlapping MCP updates retain enablement and port', () async {
|
test('overlapping MCP updates retain enablement and port', () async {
|
||||||
final repository = MemoryMcpSettingsRepository();
|
final repository = MemoryMcpSettingsRepository();
|
||||||
final container = ProviderContainer(
|
final container = ProviderContainer(
|
||||||
@@ -182,3 +215,13 @@ void main() {
|
|||||||
expect(find.text('已停用'), findsOneWidget);
|
expect(find.text('已停用'), findsOneWidget);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _CountingMcpRepository extends MemoryMcpSettingsRepository {
|
||||||
|
final writes = <McpSettingsValue>[];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> save(McpSettingsValue configuration) {
|
||||||
|
writes.add(configuration);
|
||||||
|
return super.save(configuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,6 +80,9 @@ void main() {
|
|||||||
await initial.close();
|
await initial.close();
|
||||||
final old = sqlite3.open(file.path);
|
final old = sqlite3.open(file.path);
|
||||||
try {
|
try {
|
||||||
|
old.execute(
|
||||||
|
'ALTER TABLE project_view_configurations DROP COLUMN media_width',
|
||||||
|
);
|
||||||
old.execute(
|
old.execute(
|
||||||
'ALTER TABLE appearance_configurations DROP COLUMN timeline_ruler_layout',
|
'ALTER TABLE appearance_configurations DROP COLUMN timeline_ruler_layout',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -90,6 +90,55 @@ void _testSettings<T>({
|
|||||||
required T Function(ProviderContainer) value,
|
required T Function(ProviderContainer) value,
|
||||||
required Future<void> Function(ProviderContainer, T) save,
|
required Future<void> Function(ProviderContainer, T) save,
|
||||||
}) {
|
}) {
|
||||||
|
test('$name skips an unchanged loaded value', () async {
|
||||||
|
final store = _Store(initial);
|
||||||
|
final scope = container(store);
|
||||||
|
addTearDown(scope.dispose);
|
||||||
|
await load(scope);
|
||||||
|
await save(scope, initial);
|
||||||
|
expect(store.writes, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('$name skips duplicate values queued during a write', () async {
|
||||||
|
final store = _Store(initial)..writeGate = Completer<void>();
|
||||||
|
final scope = container(store);
|
||||||
|
addTearDown(scope.dispose);
|
||||||
|
await load(scope);
|
||||||
|
final firstSave = save(scope, first);
|
||||||
|
await store.started.future;
|
||||||
|
final duplicates = List.generate(5, (_) => save(scope, first));
|
||||||
|
store.writeGate!.complete();
|
||||||
|
await Future.wait([firstSave, ...duplicates]);
|
||||||
|
expect(store.writes, [first]);
|
||||||
|
expect(value(scope), first);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('$name preserves changes back to a previously saved value', () async {
|
||||||
|
final store = _Store(initial);
|
||||||
|
final scope = container(store);
|
||||||
|
addTearDown(scope.dispose);
|
||||||
|
await load(scope);
|
||||||
|
await Future.wait([
|
||||||
|
save(scope, first),
|
||||||
|
save(scope, second),
|
||||||
|
save(scope, first),
|
||||||
|
]);
|
||||||
|
expect(store.writes, [first, second, first]);
|
||||||
|
expect(store.value, first);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('$name retries the same value after a failed write', () async {
|
||||||
|
final store = _Store(initial)..failWrites = true;
|
||||||
|
final scope = container(store);
|
||||||
|
addTearDown(scope.dispose);
|
||||||
|
await load(scope);
|
||||||
|
await expectLater(save(scope, first), throwsStateError);
|
||||||
|
store.failWrites = false;
|
||||||
|
await save(scope, first);
|
||||||
|
expect(store.writes, [first, first]);
|
||||||
|
expect(store.value, first);
|
||||||
|
});
|
||||||
|
|
||||||
test('$name saves in order and publishes only committed values', () async {
|
test('$name saves in order and publishes only committed values', () async {
|
||||||
final store = _Store(initial)..writeGate = Completer<void>();
|
final store = _Store(initial)..writeGate = Completer<void>();
|
||||||
final scope = container(store);
|
final scope = container(store);
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ void main() {
|
|||||||
await initial.close();
|
await initial.close();
|
||||||
final old = sqlite3.open(file.path);
|
final old = sqlite3.open(file.path);
|
||||||
try {
|
try {
|
||||||
|
old.execute(
|
||||||
|
'ALTER TABLE project_view_configurations DROP COLUMN media_width',
|
||||||
|
);
|
||||||
old.execute(
|
old.execute(
|
||||||
'ALTER TABLE appearance_configurations DROP COLUMN timeline_ruler_layout',
|
'ALTER TABLE appearance_configurations DROP COLUMN timeline_ruler_layout',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,210 @@
|
|||||||
|
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
||||||
|
import 'package:cutdex/workspace/timeline_view_state.dart';
|
||||||
|
import 'package:cutdex_sdk/timeline/layout.dart';
|
||||||
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
import 'support/preview_fixture.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
test('selection and close skip an already persisted timeline view', () async {
|
||||||
|
final fixture = await createPreviewFixture(Uri.file('/test.mp4'));
|
||||||
|
addTearDown(() async {
|
||||||
|
await fixture.workspace.close();
|
||||||
|
await fixture.directory.delete(recursive: true);
|
||||||
|
});
|
||||||
|
final session = fixture.timeline;
|
||||||
|
final id = session.activeSequenceId!;
|
||||||
|
final view = session.view(id);
|
||||||
|
final repository = _Repository()
|
||||||
|
..value = TimelineViewState(
|
||||||
|
activeSequenceId: id,
|
||||||
|
sequences: {
|
||||||
|
id: TimelineSequenceViewState(
|
||||||
|
playheadTick: view.playheadTick,
|
||||||
|
camera: view.camera,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final binding = await TimelineViewStateBinding.attach(
|
||||||
|
projectId: 'project',
|
||||||
|
timelineId: 'timeline',
|
||||||
|
session: session,
|
||||||
|
repository: repository,
|
||||||
|
);
|
||||||
|
addTearDown(binding.close);
|
||||||
|
// A new camera object with the same fields is also an unchanged view.
|
||||||
|
final camera = view.camera;
|
||||||
|
view.restoreViewState(
|
||||||
|
playheadTick: view.playheadTick,
|
||||||
|
camera: TimelineCamera(
|
||||||
|
baseTick: camera.baseTick,
|
||||||
|
fractionalTick: camera.fractionalTick,
|
||||||
|
pixelsPerTick: camera.pixelsPerTick,
|
||||||
|
verticalOffset: camera.verticalOffset,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
view.setSelection([ElementId('clip')]);
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 550));
|
||||||
|
await binding.close();
|
||||||
|
expect(repository.writes, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('navigation is debounced and close skips the committed view', () async {
|
||||||
|
final fixture = await createPreviewFixture(Uri.file('/test.mp4'));
|
||||||
|
addTearDown(() async {
|
||||||
|
await fixture.workspace.close();
|
||||||
|
await fixture.directory.delete(recursive: true);
|
||||||
|
});
|
||||||
|
final session = fixture.timeline;
|
||||||
|
final id = session.activeSequenceId!;
|
||||||
|
final view = session.view(id);
|
||||||
|
final repository = _Repository();
|
||||||
|
final binding = await TimelineViewStateBinding.attach(
|
||||||
|
projectId: 'project',
|
||||||
|
timelineId: 'timeline',
|
||||||
|
session: session,
|
||||||
|
repository: repository,
|
||||||
|
);
|
||||||
|
addTearDown(binding.close);
|
||||||
|
for (var tick = 1; tick <= 20; tick++) {
|
||||||
|
view.seekTo(tick);
|
||||||
|
view.setCamera(
|
||||||
|
TimelineCamera(
|
||||||
|
baseTick: tick,
|
||||||
|
fractionalTick: .5,
|
||||||
|
pixelsPerTick: .25,
|
||||||
|
verticalOffset: tick.toDouble(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect(repository.writes, isEmpty);
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 550));
|
||||||
|
expect(repository.writes, [id]);
|
||||||
|
expect(repository.value.sequences[id]!.playheadTick, 20);
|
||||||
|
expect(
|
||||||
|
repository.value.sequences[id]!.camera.baseTick,
|
||||||
|
view.camera.baseTick,
|
||||||
|
);
|
||||||
|
view.setSelection([ElementId('clip')]);
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 550));
|
||||||
|
await binding.close();
|
||||||
|
expect(repository.writes, [id]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'switching unchanged sequences still persists the active sequence',
|
||||||
|
() async {
|
||||||
|
final fixture = await createPreviewFixture(Uri.file('/test.mp4'));
|
||||||
|
addTearDown(() async {
|
||||||
|
await fixture.workspace.close();
|
||||||
|
await fixture.directory.delete(recursive: true);
|
||||||
|
});
|
||||||
|
final session = fixture.timeline;
|
||||||
|
final first = session.activeSequenceId!;
|
||||||
|
final second = SequenceId('empty');
|
||||||
|
final repository = _Repository()
|
||||||
|
..value = TimelineViewState(
|
||||||
|
activeSequenceId: first,
|
||||||
|
sequences: {
|
||||||
|
for (final id in [first, second])
|
||||||
|
id: TimelineSequenceViewState(
|
||||||
|
playheadTick: session.view(id).playheadTick,
|
||||||
|
camera: session.view(id).camera,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final binding = await TimelineViewStateBinding.attach(
|
||||||
|
projectId: 'project',
|
||||||
|
timelineId: 'timeline',
|
||||||
|
session: session,
|
||||||
|
repository: repository,
|
||||||
|
);
|
||||||
|
addTearDown(binding.close);
|
||||||
|
session.selectSequence(second);
|
||||||
|
await Future<void>.delayed(Duration.zero);
|
||||||
|
expect(repository.writes, [second]);
|
||||||
|
expect(repository.value.activeSequenceId, second);
|
||||||
|
session.selectSequence(first);
|
||||||
|
await binding.close();
|
||||||
|
expect(repository.writes, [second, first]);
|
||||||
|
expect(repository.value.activeSequenceId, first);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
'close retries an unchanged snapshot after a failed timer save',
|
||||||
|
() async {
|
||||||
|
final fixture = await createPreviewFixture(Uri.file('/test.mp4'));
|
||||||
|
addTearDown(() async {
|
||||||
|
await fixture.workspace.close();
|
||||||
|
await fixture.directory.delete(recursive: true);
|
||||||
|
});
|
||||||
|
final session = fixture.timeline;
|
||||||
|
final id = session.activeSequenceId!;
|
||||||
|
final repository = _Repository()..failWrites = true;
|
||||||
|
final binding = await TimelineViewStateBinding.attach(
|
||||||
|
projectId: 'project',
|
||||||
|
timelineId: 'timeline',
|
||||||
|
session: session,
|
||||||
|
repository: repository,
|
||||||
|
);
|
||||||
|
addTearDown(binding.close);
|
||||||
|
session.view(id).seekTo(20);
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 550));
|
||||||
|
expect(repository.writes, [id]);
|
||||||
|
expect(repository.value.sequences, isEmpty);
|
||||||
|
repository.failWrites = false;
|
||||||
|
await binding.close();
|
||||||
|
expect(repository.writes, [id, id]);
|
||||||
|
expect(repository.value.sequences[id]!.playheadTick, 20);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('a failed load does not suppress saving defaults', () async {
|
||||||
|
final fixture = await createPreviewFixture(Uri.file('/test.mp4'));
|
||||||
|
addTearDown(() async {
|
||||||
|
await fixture.workspace.close();
|
||||||
|
await fixture.directory.delete(recursive: true);
|
||||||
|
});
|
||||||
|
final repository = _Repository()..failLoads = true;
|
||||||
|
final binding = await TimelineViewStateBinding.attach(
|
||||||
|
projectId: 'project',
|
||||||
|
timelineId: 'timeline',
|
||||||
|
session: fixture.timeline,
|
||||||
|
repository: repository,
|
||||||
|
);
|
||||||
|
await binding.close();
|
||||||
|
expect(repository.writes, [fixture.timeline.activeSequenceId]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Repository implements TimelineViewSettingsRepository {
|
||||||
|
TimelineViewState value = const TimelineViewState();
|
||||||
|
final writes = <SequenceId>[];
|
||||||
|
bool failLoads = false;
|
||||||
|
bool failWrites = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<TimelineViewState> load(String projectId, String timelineId) async {
|
||||||
|
if (failLoads) throw StateError('load failed');
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> save(
|
||||||
|
String projectId,
|
||||||
|
String timelineId,
|
||||||
|
SequenceId sequenceId,
|
||||||
|
TimelineSequenceViewState state,
|
||||||
|
) async {
|
||||||
|
writes.add(sequenceId);
|
||||||
|
if (failWrites) throw StateError('save failed');
|
||||||
|
value = value.copyWith(
|
||||||
|
activeSequenceId: sequenceId,
|
||||||
|
sequences: {...value.sequences, sequenceId: state},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,10 +9,14 @@ class _WorkspaceRepository implements WorkspaceViewSettingsRepository {
|
|||||||
WorkspaceViewSettingsData value = const WorkspaceViewSettingsData();
|
WorkspaceViewSettingsData value = const WorkspaceViewSettingsData();
|
||||||
final writes = <WorkspaceViewSettingsData>[];
|
final writes = <WorkspaceViewSettingsData>[];
|
||||||
Completer<void>? gate;
|
Completer<void>? gate;
|
||||||
|
bool failLoads = false;
|
||||||
bool failWrites = false;
|
bool failWrites = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<WorkspaceViewSettingsData> load() async => value;
|
Future<WorkspaceViewSettingsData> load() async {
|
||||||
|
if (failLoads) throw StateError('unavailable');
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> save(WorkspaceViewSettingsData settings) async {
|
Future<void> save(WorkspaceViewSettingsData settings) async {
|
||||||
@@ -27,6 +31,8 @@ class _ProjectRepository implements ProjectViewSettingsRepository {
|
|||||||
final values = <String, ProjectViewSettingsData>{};
|
final values = <String, ProjectViewSettingsData>{};
|
||||||
final writes = <String>[];
|
final writes = <String>[];
|
||||||
bool failLoads = false;
|
bool failLoads = false;
|
||||||
|
bool failWrites = false;
|
||||||
|
Completer<void>? gate;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ProjectViewSettingsData> load(String projectId) async {
|
Future<ProjectViewSettingsData> load(String projectId) async {
|
||||||
@@ -37,11 +43,122 @@ class _ProjectRepository implements ProjectViewSettingsRepository {
|
|||||||
@override
|
@override
|
||||||
Future<void> save(String projectId, ProjectViewSettingsData settings) async {
|
Future<void> save(String projectId, ProjectViewSettingsData settings) async {
|
||||||
writes.add(projectId);
|
writes.add(projectId);
|
||||||
|
await gate?.future;
|
||||||
|
if (failWrites) throw StateError('write failed');
|
||||||
values[projectId] = settings;
|
values[projectId] = settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
test(
|
||||||
|
'workspace duplicate requests wait for one committed snapshot',
|
||||||
|
() async {
|
||||||
|
final repository = _WorkspaceRepository()..gate = Completer<void>();
|
||||||
|
final container = ProviderContainer.test(
|
||||||
|
overrides: [
|
||||||
|
workspaceViewSettingsRepositoryProvider.overrideWithValue(repository),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
await container.read(workspaceViewSettingsProvider.future);
|
||||||
|
final controller = container.read(workspaceViewSettingsProvider.notifier);
|
||||||
|
final pending = List.generate(
|
||||||
|
5,
|
||||||
|
(_) => controller.save(activeProjectId: 'project'),
|
||||||
|
);
|
||||||
|
await Future<void>.delayed(Duration.zero);
|
||||||
|
expect(repository.writes, hasLength(1));
|
||||||
|
repository.gate!.complete();
|
||||||
|
await Future.wait(pending);
|
||||||
|
await controller.save(activeProjectId: 'project');
|
||||||
|
expect(repository.writes, hasLength(1));
|
||||||
|
await controller.save(activeProjectId: 'other');
|
||||||
|
await controller.save(activeProjectId: 'project');
|
||||||
|
expect(repository.writes.map((value) => value.activeProjectId), [
|
||||||
|
'project',
|
||||||
|
'other',
|
||||||
|
'project',
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test('workspace skips a snapshot already loaded from storage', () async {
|
||||||
|
final repository = _WorkspaceRepository()
|
||||||
|
..value = const WorkspaceViewSettingsData(
|
||||||
|
hasSavedState: true,
|
||||||
|
activeProjectId: 'project',
|
||||||
|
sidebarWidth: 320,
|
||||||
|
);
|
||||||
|
final container = ProviderContainer.test(
|
||||||
|
overrides: [
|
||||||
|
workspaceViewSettingsRepositoryProvider.overrideWithValue(repository),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
await container.read(workspaceViewSettingsProvider.future);
|
||||||
|
final controller = container.read(workspaceViewSettingsProvider.notifier);
|
||||||
|
await controller.save(activeProjectId: 'project');
|
||||||
|
expect(repository.writes, isEmpty);
|
||||||
|
controller.setSidebarWidth(340);
|
||||||
|
await controller.save(activeProjectId: 'project');
|
||||||
|
expect(repository.value.sidebarWidth, 340);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('workspace persists defaults when no state was loaded', () async {
|
||||||
|
for (final loadFails in [false, true]) {
|
||||||
|
final repository = _WorkspaceRepository()..failLoads = loadFails;
|
||||||
|
final container = ProviderContainer.test(
|
||||||
|
overrides: [
|
||||||
|
workspaceViewSettingsRepositoryProvider.overrideWithValue(repository),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
await container.read(workspaceViewSettingsProvider.future);
|
||||||
|
final controller = container.read(workspaceViewSettingsProvider.notifier);
|
||||||
|
await controller.save(activeProjectId: null);
|
||||||
|
await controller.save(activeProjectId: null);
|
||||||
|
expect(repository.writes, hasLength(1));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('project skips repeated pending and committed snapshots', () async {
|
||||||
|
final repository = _ProjectRepository()..gate = Completer<void>();
|
||||||
|
final container = ProviderContainer.test(
|
||||||
|
overrides: [
|
||||||
|
projectViewSettingsRepositoryProvider.overrideWithValue(repository),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final provider = projectViewSettingsProvider('project');
|
||||||
|
await container.read(provider.future);
|
||||||
|
final controller = container.read(provider.notifier);
|
||||||
|
await controller.save();
|
||||||
|
expect(repository.writes, isEmpty);
|
||||||
|
controller.setMediaWidth(320);
|
||||||
|
final pending = List.generate(5, (_) => controller.save());
|
||||||
|
await Future<void>.delayed(Duration.zero);
|
||||||
|
expect(repository.writes, ['project']);
|
||||||
|
repository.gate!.complete();
|
||||||
|
await Future.wait(pending);
|
||||||
|
await controller.save();
|
||||||
|
expect(repository.writes, ['project']);
|
||||||
|
expect(repository.values['project']!.mediaWidth, 320);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('project retries an identical snapshot after storage failure', () async {
|
||||||
|
final repository = _ProjectRepository()..failWrites = true;
|
||||||
|
final container = ProviderContainer.test(
|
||||||
|
overrides: [
|
||||||
|
projectViewSettingsRepositoryProvider.overrideWithValue(repository),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final provider = projectViewSettingsProvider('project');
|
||||||
|
await container.read(provider.future);
|
||||||
|
final controller = container.read(provider.notifier);
|
||||||
|
controller.setMediaWidth(320);
|
||||||
|
await expectLater(controller.save(), throwsStateError);
|
||||||
|
repository.failWrites = false;
|
||||||
|
await controller.save();
|
||||||
|
expect(repository.writes, ['project', 'project']);
|
||||||
|
expect(repository.values['project']!.mediaWidth, 320);
|
||||||
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'workspace saves remain ordered while a previous write is pending',
|
'workspace saves remain ordered while a previous write is pending',
|
||||||
() async {
|
() async {
|
||||||
@@ -112,6 +229,7 @@ void main() {
|
|||||||
final first = container.read(firstProvider.notifier);
|
final first = container.read(firstProvider.notifier);
|
||||||
first.setPropertiesOpen(true);
|
first.setPropertiesOpen(true);
|
||||||
first.setTimelineHeight(240);
|
first.setTimelineHeight(240);
|
||||||
|
first.setMediaWidth(360);
|
||||||
await first.save();
|
await first.save();
|
||||||
subscription.close();
|
subscription.close();
|
||||||
await container.pump();
|
await container.pump();
|
||||||
@@ -126,6 +244,7 @@ void main() {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
expect((await restored.read(firstProvider.future)).timelineHeight, 240);
|
expect((await restored.read(firstProvider.future)).timelineHeight, 240);
|
||||||
|
expect((await restored.read(firstProvider.future)).mediaWidth, 360);
|
||||||
expect(repository.writes, ['first']);
|
expect(repository.writes, ['first']);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user