Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
run: |
export PUB_CACHE=$HOME/.pub-cache
flutter pub get
sed -i -e 's/-Wl,/-Wl,--build-id=none,/' ${PUB_CACHE}/hosted/*/jni-*/src/CMakeLists.txt
- name: Setup Isar
run: |
sudo apt-get install -y tofrodos
Expand Down
3 changes: 1 addition & 2 deletions .run/Generate files.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate files" type="ShConfigurationType">
<option name="SCRIPT_TEXT"
value="fvm dart run build_runner build --delete-conflicting-outputs" />
<option name="SCRIPT_TEXT" value="fvm dart run build_runner build" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
Expand Down
5 changes: 5 additions & 0 deletions lib/common/actions/backup.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

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

/// Requires the user to select a backup directory.
Future<void> requireBackupDirectory(BuildContext context) async {
if (!kReleaseMode) {
return;
}

final select = await showAdaptiveDialog<bool>(
context: context,
useRootNavigator: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/models/note/index/note_index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NoteIndex {
deleted: note.deleted,
archived: note.archived,
title: note.title,
content: note.plainText,
content: note.contentAsText,
labels: note.labelsNamesVisibleSorted,
);

Expand Down
14 changes: 11 additions & 3 deletions lib/models/note/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sealed class Note implements Comparable<Note> {

/// The content as plain text.
@ignore
String get plainText;
String get contentAsText;

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

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

/// The number of characters in the content.
@ignore
int get charactersCount => plainText.length;
int get charactersCount => contentAsText.length;

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

/// The [title] indexed for full-text search.
@Index(type: IndexType.value, caseSensitive: false)
List<String> get titleIndexed => Isar.splitWords(title.toLowerCase());

/// The [contentAsText] indexed for full-text search.
@Index(type: IndexType.value, caseSensitive: false)
List<String> get contentIndexed => Isar.splitWords(contentAsText.toLowerCase());

/// Notes are sorted according to:
/// 1. Their pin state.
/// 2. The sort method chosen by the user.
Expand Down
4 changes: 2 additions & 2 deletions lib/models/note/types/checklist_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ChecklistNote extends Note {

@ignore
@override
String get plainText {
String get contentAsText {
StringBuffer plainText = StringBuffer();

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

@ignore
@override
String get contentPreview => plainText.trim();
String get contentPreview => contentAsText.trim();

@ignore
@override
Expand Down
4 changes: 2 additions & 2 deletions lib/models/note/types/markdown_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class MarkdownNote extends Note {

@ignore
@override
String get plainText => content.removeMarkdown();
String get contentAsText => content.removeMarkdown();

@ignore
@override
String get contentAsMarkdown => content;

@ignore
@override
String get contentPreview => plainText.trim();
String get contentPreview => contentAsText.trim();

@ignore
@override
Expand Down
4 changes: 2 additions & 2 deletions lib/models/note/types/plain_text_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class PlainTextNote extends Note {

@ignore
@override
String get plainText => content;
String get contentAsText => content;

@ignore
@override
String get contentAsMarkdown => content;

@ignore
@override
String get contentPreview => plainText.trim();
String get contentPreview => contentAsText.trim();

@ignore
@override
Expand Down
2 changes: 1 addition & 1 deletion lib/models/note/types/rich_text_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RichTextNote extends Note {

@ignore
@override
String get plainText => document.toPlainText();
String get contentAsText => document.toPlainText();

@ignore
@override
Expand Down
12 changes: 0 additions & 12 deletions lib/services/database_service.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:flutter_mimir/flutter_mimir.dart';
import 'package:isar_community/isar.dart';
import 'package:mimir/mimir.dart';
import 'package:path_provider/path_provider.dart';

import '../models/deprecated/note.dart';
Expand All @@ -9,7 +7,6 @@ import '../models/note/note.dart';
import 'bin/bin_service.dart';
import 'labels/labels_service.dart';
import 'migration/migration_service.dart';
import 'notes/notes_index_service.dart';
import 'notes/notes_service.dart';

/// Abstract service for the database.
Expand All @@ -26,9 +23,6 @@ class DatabaseService {
/// Isar database instance.
late final Isar database;

/// Mimir index instance.
late final MimirInstance mimir;

/// Ensures the service is initialized.
Future<void> ensureInitialized() async {
final databaseName = 'materialnotes';
Expand All @@ -41,12 +35,6 @@ class DatabaseService {
directory: databaseDirectory,
);

// Initialize mimir
mimir = await Mimir.defaultInstance;

// Initialize the indexes service
await NotesIndexService().ensureInitialized();

// Initialize the models services
await LabelsService().ensureInitialized();
await NotesService().ensureInitialized();
Expand Down
5 changes: 0 additions & 5 deletions lib/services/migration/migration_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import '../../common/preferences/preference_key.dart';
import '../../models/deprecated/note.dart';
import '../../models/note/note.dart';
import '../database_service.dart';
import '../notes/notes_index_service.dart';
import '../notes/notes_service.dart';

/// Database migration service.
class MigrationService {
final _databaseService = DatabaseService();
final _indexesService = NotesIndexService();
final _notesService = NotesService();

/// Migrates the database to the latest version if needed.
Expand Down Expand Up @@ -69,9 +67,6 @@ class MigrationService {
///
/// Sets the new `id`, `archived` and `deletedTime` fields of each rich text note.
Future<void> _migrateToV3() async {
// Clear the indexes to ensure their are rebuilt correctly
await _indexesService.clearIndexes();

// Get the rich text notes
final richTextNotes = await _databaseService.database.richTextNotes.where().findAll();

Expand Down
66 changes: 0 additions & 66 deletions lib/services/notes/notes_index_service.dart

This file was deleted.

Loading
Loading