Skip to content

Commit e8be228

Browse files
committed
fix: remove mimir
1 parent 37d9c49 commit e8be228

14 files changed

Lines changed: 99 additions & 222 deletions

.run/Generate files.run.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Generate files" type="ShConfigurationType">
3-
<option name="SCRIPT_TEXT"
4-
value="fvm dart run build_runner build --delete-conflicting-outputs" />
3+
<option name="SCRIPT_TEXT" value="fvm dart run build_runner build" />
54
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
65
<option name="SCRIPT_PATH" value="" />
76
<option name="SCRIPT_OPTIONS" value="" />

lib/common/actions/backup.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter/material.dart';
23

34
import '../../services/backup/auto_backup_service.dart';
@@ -7,6 +8,10 @@ import '../preferences/preference_key.dart';
78

89
/// Requires the user to select a backup directory.
910
Future<void> requireBackupDirectory(BuildContext context) async {
11+
if (!kReleaseMode) {
12+
return;
13+
}
14+
1015
final select = await showAdaptiveDialog<bool>(
1116
context: context,
1217
useRootNavigator: false,

lib/models/note/index/note_index.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class NoteIndex {
4242
deleted: note.deleted,
4343
archived: note.archived,
4444
title: note.title,
45-
content: note.plainText,
45+
content: note.contentAsText,
4646
labels: note.labelsNamesVisibleSorted,
4747
);
4848

lib/models/note/note.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ sealed class Note implements Comparable<Note> {
115115

116116
/// The content as plain text.
117117
@ignore
118-
String get plainText;
118+
String get contentAsText;
119119

120120
/// The content as markdown.
121121
@ignore
@@ -131,11 +131,11 @@ sealed class Note implements Comparable<Note> {
131131

132132
/// The number of words in the content.
133133
@ignore
134-
int get wordsCount => _wordsCountRegex.allMatches(plainText).length;
134+
int get wordsCount => _wordsCountRegex.allMatches(contentAsText).length;
135135

136136
/// The number of characters in the content.
137137
@ignore
138-
int get charactersCount => plainText.length;
138+
int get charactersCount => contentAsText.length;
139139

140140
/// Whether the title is empty.
141141
@ignore
@@ -185,6 +185,14 @@ sealed class Note implements Comparable<Note> {
185185
@ignore
186186
String get labelsAsMarkdown => '> ${labelsNamesVisibleSorted.join(', ')}';
187187

188+
/// The [title] indexed for full-text search.
189+
@Index(type: IndexType.value, caseSensitive: false)
190+
List<String> get titleIndexed => Isar.splitWords(title.toLowerCase());
191+
192+
/// The [contentAsText] indexed for full-text search.
193+
@Index(type: IndexType.value, caseSensitive: false)
194+
List<String> get contentIndexed => Isar.splitWords(contentAsText.toLowerCase());
195+
188196
/// Notes are sorted according to:
189197
/// 1. Their pin state.
190198
/// 2. The sort method chosen by the user.

lib/models/note/types/checklist_note.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ChecklistNote extends Note {
7979

8080
@ignore
8181
@override
82-
String get plainText {
82+
String get contentAsText {
8383
StringBuffer plainText = StringBuffer();
8484

8585
for (int index = 0; index < checkboxes.length; index++) {
@@ -109,7 +109,7 @@ class ChecklistNote extends Note {
109109

110110
@ignore
111111
@override
112-
String get contentPreview => plainText.trim();
112+
String get contentPreview => contentAsText.trim();
113113

114114
@ignore
115115
@override

lib/models/note/types/markdown_note.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ class MarkdownNote extends Note {
6262

6363
@ignore
6464
@override
65-
String get plainText => content.removeMarkdown();
65+
String get contentAsText => content.removeMarkdown();
6666

6767
@ignore
6868
@override
6969
String get contentAsMarkdown => content;
7070

7171
@ignore
7272
@override
73-
String get contentPreview => plainText.trim();
73+
String get contentPreview => contentAsText.trim();
7474

7575
@ignore
7676
@override

lib/models/note/types/plain_text_note.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ class PlainTextNote extends Note {
6262

6363
@ignore
6464
@override
65-
String get plainText => content;
65+
String get contentAsText => content;
6666

6767
@ignore
6868
@override
6969
String get contentAsMarkdown => content;
7070

7171
@ignore
7272
@override
73-
String get contentPreview => plainText.trim();
73+
String get contentPreview => contentAsText.trim();
7474

7575
@ignore
7676
@override

lib/models/note/types/rich_text_note.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class RichTextNote extends Note {
9595

9696
@ignore
9797
@override
98-
String get plainText => document.toPlainText();
98+
String get contentAsText => document.toPlainText();
9999

100100
@ignore
101101
@override

lib/services/database_service.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import 'package:flutter_mimir/flutter_mimir.dart';
21
import 'package:isar_community/isar.dart';
3-
import 'package:mimir/mimir.dart';
42
import 'package:path_provider/path_provider.dart';
53

64
import '../models/deprecated/note.dart';
@@ -9,7 +7,6 @@ import '../models/note/note.dart';
97
import 'bin/bin_service.dart';
108
import 'labels/labels_service.dart';
119
import 'migration/migration_service.dart';
12-
import 'notes/notes_index_service.dart';
1310
import 'notes/notes_service.dart';
1411

1512
/// Abstract service for the database.
@@ -26,9 +23,6 @@ class DatabaseService {
2623
/// Isar database instance.
2724
late final Isar database;
2825

29-
/// Mimir index instance.
30-
late final MimirInstance mimir;
31-
3226
/// Ensures the service is initialized.
3327
Future<void> ensureInitialized() async {
3428
final databaseName = 'materialnotes';
@@ -41,12 +35,6 @@ class DatabaseService {
4135
directory: databaseDirectory,
4236
);
4337

44-
// Initialize mimir
45-
mimir = await Mimir.defaultInstance;
46-
47-
// Initialize the indexes service
48-
await NotesIndexService().ensureInitialized();
49-
5038
// Initialize the models services
5139
await LabelsService().ensureInitialized();
5240
await NotesService().ensureInitialized();

lib/services/migration/migration_service.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import '../../common/preferences/preference_key.dart';
55
import '../../models/deprecated/note.dart';
66
import '../../models/note/note.dart';
77
import '../database_service.dart';
8-
import '../notes/notes_index_service.dart';
98
import '../notes/notes_service.dart';
109

1110
/// Database migration service.
1211
class MigrationService {
1312
final _databaseService = DatabaseService();
14-
final _indexesService = NotesIndexService();
1513
final _notesService = NotesService();
1614

1715
/// Migrates the database to the latest version if needed.
@@ -69,9 +67,6 @@ class MigrationService {
6967
///
7068
/// Sets the new `id`, `archived` and `deletedTime` fields of each rich text note.
7169
Future<void> _migrateToV3() async {
72-
// Clear the indexes to ensure their are rebuilt correctly
73-
await _indexesService.clearIndexes();
74-
7570
// Get the rich text notes
7671
final richTextNotes = await _databaseService.database.richTextNotes.where().findAll();
7772

0 commit comments

Comments
 (0)