style: Format code for consistency and readability across database and note positioning files

This commit is contained in:
2026-05-22 17:31:49 +02:00
parent 729e575a60
commit 814f8f7c04
4 changed files with 62 additions and 58 deletions
+16 -9
View File
@@ -18,7 +18,8 @@ class Categories extends Table {
BoolColumn get isDeleted =>
boolean().named('is_deleted').withDefault(const Constant(false))();
IntColumn get colorValue => integer().nullable().named('color_value')();
IntColumn get iconCodePoint => integer().nullable().named('icon_code_point')();
IntColumn get iconCodePoint =>
integer().nullable().named('icon_code_point')();
BoolColumn get isDirty =>
boolean().named('is_dirty').withDefault(const Constant(true))();
DateTimeColumn get updatedAt => dateTime().named('updated_at')();
@@ -72,7 +73,8 @@ class AppDatabase extends _$AppDatabase {
await customStatement('UPDATE categories SET icon_code_point = NULL');
}
if (from < 4) {
final List<DbNote> activeNotes = await (select(notes)
final List<DbNote> activeNotes =
await (select(notes)
..where((n) => n.isDeleted.equals(false))
..orderBy([
(note) => OrderingTerm(expression: note.sortIndex),
@@ -134,7 +136,8 @@ class AppDatabase extends _$AppDatabase {
Future<int> insertNoteAtTop(NotesCompanion note) {
return transaction(() async {
final DbNote? topNote = await (select(notes)
final DbNote? topNote =
await (select(notes)
..where((n) => n.isDeleted.equals(false))
..orderBy([
(note) => OrderingTerm(
@@ -149,9 +152,9 @@ class AppDatabase extends _$AppDatabase {
? 0
: topNote.sortIndex + notePositionStep;
await into(notes).insert(
note.copyWith(sortIndex: Value<int>(nextSortIndex)),
);
await into(
notes,
).insert(note.copyWith(sortIndex: Value<int>(nextSortIndex)));
return nextSortIndex;
});
}
@@ -206,7 +209,8 @@ class AppDatabase extends _$AppDatabase {
required int newIndex,
}) {
return transaction(() async {
final List<DbNote> orderedNotes = await (select(notes)
final List<DbNote> orderedNotes =
await (select(notes)
..where((n) => n.isDeleted.equals(false))
..orderBy([
(note) => OrderingTerm(
@@ -216,7 +220,9 @@ class AppDatabase extends _$AppDatabase {
]))
.get();
final int currentIndex = orderedNotes.indexWhere((DbNote row) => row.id == id);
final int currentIndex = orderedNotes.indexWhere(
(DbNote row) => row.id == id,
);
if (currentIndex == -1) {
return;
}
@@ -283,7 +289,8 @@ class AppDatabase extends _$AppDatabase {
// notes that had an empty body (common) from appearing in the trash.
return (select(notes)
..where(
(n) => n.isDeleted.equals(true) &
(n) =>
n.isDeleted.equals(true) &
(n.title.isNotValue('') | n.body.isNotValue('')),
)
..orderBy([
+3 -3
View File
@@ -59,9 +59,9 @@ class NoteRepository {
Future<void> createCategory(Category category) async {
debugPrint('createCategory called with: ${category.name}');
final DbCategory? existingCategory = await (
_database.select(_database.categories)..where((c) => c.id.equals(category.id))
).getSingleOrNull();
final DbCategory? existingCategory = await (_database.select(
_database.categories,
)..where((c) => c.id.equals(category.id))).getSingleOrNull();
final int effectiveServerVersion = math.max(
category.serverVersion,
existingCategory?.serverVersion ?? category.serverVersion,
+1 -4
View File
@@ -14,10 +14,7 @@ void main() {
midpointNotePosition(higherPosition: 20000, lowerPosition: 10000),
15000,
);
expect(
midpointNotePosition(higherPosition: 2, lowerPosition: 1),
isNull,
);
expect(midpointNotePosition(higherPosition: 2, lowerPosition: 1), isNull);
expect(rebalanceNotePositions(3), <int>[20000, 10000, 0]);
});
}