feat(trash): v0.3.7.0 — Trash / soft delete + release docs backfill
- Deleting a note now soft-deletes it (trashed flag on NoteEntity, additive schema, auto-migrated); trashed notes are hidden from Home, Favorites, Untagged, tag views, and ordinary search. - New Trash drawer entry lists soft-deleted notes; each Trash card's overflow menu exposes Restore and Delete permanently. - NoteFilter gains a Trash case; repository gains moveToTrash / restoreFromTrash / deletePermanently; backups round-trip the trashed state. - Version bump (lockstep): versionCode 30->31, versionName 0.3.6.3->0.3.7.0, SettingsViewModel.APP_VERSION, README intro + changelog, ReleaseNotes.kt 5-most-recent window. - Development Plan §10: fix the merged 0.3.4.0/0.3.3.8 table row and backfill the missing 0.3.6.2/0.3.6.3 rows; add the 0.3.7.0 row. - README changelog: backfill the missing 0.3.6.2 row; promote the Unreleased Trash row to 0.3.7.0.
This commit is contained in:
1 parent
4bbe29851a
commit
a39c52cf89
17 files changed
+386
-165
No files matched your search
@@ -33,6 +33,8 @@ data class NoteEntity(
|
||||
var cipherVersion: Int = 0,
|
||||
/** Encrypted payload: `nonce (12) | ciphertext + GCM tag`. Empty when plaintext. */
|
||||
var contentBlob: ByteArray = ByteArray(0),
|
||||
/** True only for notes moved to the Trash view; active-note queries exclude these rows. */
|
||||
@Index var isTrashed: Boolean = false,
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
@@ -43,6 +45,7 @@ data class NoteEntity(
|
||||
if (updatedAt != other.updatedAt) return false
|
||||
if (isFavorite != other.isFavorite) return false
|
||||
if (colorKey != other.colorKey) return false
|
||||
if (isTrashed != other.isTrashed) return false
|
||||
if (cipherVersion != other.cipherVersion) return false
|
||||
if (!contentBlob.contentEquals(other.contentBlob)) return false
|
||||
return true
|
||||
@@ -55,6 +58,7 @@ data class NoteEntity(
|
||||
result = 31 * result + updatedAt.hashCode()
|
||||
result = 31 * result + isFavorite.hashCode()
|
||||
result = 31 * result + colorKey.hashCode()
|
||||
result = 31 * result + isTrashed.hashCode()
|
||||
result = 31 * result + cipherVersion.hashCode()
|
||||
result = 31 * result + contentBlob.contentHashCode()
|
||||
return result
|
||||
@@ -68,6 +72,7 @@ internal fun NoteEntity.toDomain(): Note = Note(
|
||||
updatedAt = updatedAt,
|
||||
isFavorite = isFavorite,
|
||||
color = NoteColor.fromStorageKey(colorKey),
|
||||
isTrashed = isTrashed,
|
||||
)
|
||||
|
||||
internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
@@ -77,4 +82,5 @@ internal fun Note.toEntity(): NoteEntity = NoteEntity(
|
||||
updatedAt = updatedAt,
|
||||
isFavorite = isFavorite,
|
||||
colorKey = color.storageKey,
|
||||
isTrashed = isTrashed,
|
||||
)
|
||||
@@ -82,6 +82,14 @@ class NoteRepositoryImpl(
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeAllIncludingTrashed(): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotAllIncludingTrashed())
|
||||
val sub = noteBox.query().build().subscribe().observer {
|
||||
trySend(snapshotAllIncludingTrashed())
|
||||
}
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun search(query: String): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotSearch(query))
|
||||
val sub = noteBox.query().build().subscribe().observer { trySend(snapshotSearch(query)) }
|
||||
@@ -100,6 +108,16 @@ class NoteRepositoryImpl(
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeTrashed(): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotTrashed())
|
||||
val sub = noteBox.query()
|
||||
.equal(NoteEntity_.isTrashed, true)
|
||||
.build()
|
||||
.subscribe()
|
||||
.observer { trySend(snapshotTrashed()) }
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeNotesForHashtag(name: String): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotForHashtag(name))
|
||||
val sub = noteBox.query().build().subscribe().observer { trySend(snapshotForHashtag(name)) }
|
||||
@@ -118,6 +136,12 @@ class NoteRepositoryImpl(
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun searchTrashed(query: String): Flow<List<Note>> = callbackFlow {
|
||||
trySend(snapshotTrashSearch(query))
|
||||
val sub = noteBox.query().build().subscribe().observer { trySend(snapshotTrashSearch(query)) }
|
||||
awaitClose { sub.cancel() }
|
||||
}.flowOn(Dispatchers.Default)
|
||||
|
||||
override fun observeHashtagsByRecentUse(): Flow<List<HashtagUsage>> = callbackFlow {
|
||||
// The snapshot reads from noteBox + xrefBox + tagBox, so we must
|
||||
// subscribe to ALL three — otherwise a change that only touches
|
||||
@@ -285,19 +309,75 @@ class NoteRepositoryImpl(
|
||||
* query cannot see ciphertext, so when encryption is active we
|
||||
* decrypt and filter in-memory (fine at notes-app scale). Hashtag
|
||||
* matching is unaffected — tag names stay plaintext.
|
||||
*
|
||||
* [includeTrashed] is deliberately explicit: normal searches must
|
||||
* never leak a trashed row, while Trash search must never return an
|
||||
* active row.
|
||||
*/
|
||||
private fun contentMatchingNoteIds(query: String): List<Long> {
|
||||
if (fieldCipher == null) {
|
||||
return noteBox.query()
|
||||
.contains(NoteEntity_.content, query, QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
private fun contentMatchingNoteIds(
|
||||
query: String,
|
||||
includeTrashed: Boolean = false,
|
||||
): List<Long> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return emptyList()
|
||||
|
||||
val candidates = if (fieldCipher == null) {
|
||||
noteBox.query()
|
||||
.contains(NoteEntity_.content, q, QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
.build()
|
||||
.find()
|
||||
} else {
|
||||
val needle = q.lowercase()
|
||||
noteBox.all.filter { toReadable(it).content.lowercase().contains(needle) }
|
||||
}
|
||||
return candidates
|
||||
.filter { it.isTrashed == includeTrashed }
|
||||
.map { it.id }
|
||||
}
|
||||
|
||||
/** IDs of rows eligible for all active-note queries. */
|
||||
private fun activeNoteIds(): Set<Long> =
|
||||
noteBox.all.filter { !it.isTrashed }.mapTo(HashSet()) { it.id }
|
||||
|
||||
/** IDs of tags currently used by at least one active note. */
|
||||
private fun activeTagIds(): Set<Long> {
|
||||
val activeIds = activeNoteIds()
|
||||
return xrefBox.all
|
||||
.asSequence()
|
||||
.filter { it.noteId in activeIds }
|
||||
.mapTo(HashSet()) { it.hashtagId }
|
||||
}
|
||||
|
||||
/**
|
||||
* Return content and exact-hashtag matches for either the active
|
||||
* note set or the Trash set, never a mixture of the two.
|
||||
*/
|
||||
private fun matchingNoteIds(
|
||||
query: String,
|
||||
includeTrashed: Boolean,
|
||||
): Set<Long> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return emptySet()
|
||||
|
||||
val contentMatches = contentMatchingNoteIds(q, includeTrashed)
|
||||
|
||||
val matchingTag: HashtagEntity? = tagBox.query()
|
||||
.equal(HashtagEntity_.name, q, QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
.build()
|
||||
.findFirst()
|
||||
val tagMatches: List<Long> = if (matchingTag == null) {
|
||||
emptyList()
|
||||
} else {
|
||||
xrefBox.query()
|
||||
.equal(NoteHashtagCrossRef_.hashtagId, matchingTag.id)
|
||||
.build()
|
||||
.find()
|
||||
.mapNotNull { ref -> noteBox.get(ref.noteId) }
|
||||
.filter { it.isTrashed == includeTrashed }
|
||||
.map { it.id }
|
||||
}
|
||||
val needle = query.lowercase()
|
||||
return noteBox.all
|
||||
.filter { toReadable(it).content.lowercase().contains(needle) }
|
||||
.map { it.id }
|
||||
|
||||
return (contentMatches + tagMatches).toSet()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,6 +452,25 @@ class NoteRepositoryImpl(
|
||||
}
|
||||
}
|
||||
|
||||
/** Soft-delete only changes state; the row, links, and blobs remain intact. */
|
||||
override suspend fun softDelete(id: Long) {
|
||||
val entity = noteBox.get(id) ?: return
|
||||
if (entity.isTrashed) return
|
||||
entity.isTrashed = true
|
||||
// `put` is intentional here: content may be ciphertext already,
|
||||
// so do not pass it through toWritable and encrypt the ciphertext a
|
||||
// second time. Only the additive flag is changing.
|
||||
noteBox.put(entity)
|
||||
}
|
||||
|
||||
/** Clear the additive flag and make the note active again. */
|
||||
override suspend fun restore(id: Long) {
|
||||
val entity = noteBox.get(id) ?: return
|
||||
if (!entity.isTrashed) return
|
||||
entity.isTrashed = false
|
||||
noteBox.put(entity)
|
||||
}
|
||||
|
||||
override suspend fun setFavorite(id: Long, isFavorite: Boolean) {
|
||||
val entity = noteBox.get(id) ?: return
|
||||
if (entity.isFavorite == isFavorite) return
|
||||
@@ -500,13 +599,18 @@ class NoteRepositoryImpl(
|
||||
.mapValues { (_, rows) -> rows.sortedBy { it.createdAt } }
|
||||
}
|
||||
|
||||
private fun decorate(entities: List<NoteEntity>): List<Note> {
|
||||
private fun decorate(
|
||||
entities: List<NoteEntity>,
|
||||
includeTrashed: Boolean? = false,
|
||||
): List<Note> {
|
||||
val tags = hashtagsByNoteId()
|
||||
val attachments = attachmentsByNoteId()
|
||||
return entities.sortedWith(
|
||||
compareByDescending<NoteEntity> { it.isFavorite }
|
||||
.thenByDescending { it.updatedAt }
|
||||
).map { e ->
|
||||
return entities
|
||||
.filter { includeTrashed == null || it.isTrashed == includeTrashed }
|
||||
.sortedWith(
|
||||
compareByDescending<NoteEntity> { it.isFavorite }
|
||||
.thenByDescending { it.updatedAt },
|
||||
).map { e ->
|
||||
val base = toReadable(e).toDomain()
|
||||
base.copy(
|
||||
hashtags = tags[e.id].orEmpty(),
|
||||
@@ -517,29 +621,10 @@ class NoteRepositoryImpl(
|
||||
|
||||
private fun snapshotAll(): List<Note> = decorate(noteBox.all)
|
||||
|
||||
private fun snapshotAllIncludingTrashed(): List<Note> = decorate(noteBox.all, includeTrashed = null)
|
||||
|
||||
private fun snapshotSearch(query: String): List<Note> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return snapshotAll()
|
||||
|
||||
// Match against content (contains, case-insensitive).
|
||||
// v0.3.5.0: cipher-aware — ObjectBox `contains()` can't see
|
||||
// ciphertext, so encrypted stores match in-memory.
|
||||
val contentMatches: List<Long> = contentMatchingNoteIds(q)
|
||||
|
||||
// Match against hashtag names (case-insensitive exact equality).
|
||||
val matchingTag: HashtagEntity? = tagBox.query()
|
||||
.equal(HashtagEntity_.name, q, QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
.build()
|
||||
.findFirst()
|
||||
val tagMatches: List<Long> = if (matchingTag == null) emptyList() else {
|
||||
xrefBox.query()
|
||||
.equal(NoteHashtagCrossRef_.hashtagId, matchingTag.id)
|
||||
.build()
|
||||
.find()
|
||||
.map { it.noteId }
|
||||
}
|
||||
|
||||
val allIds: Set<Long> = (contentMatches + tagMatches).toSet()
|
||||
val allIds = matchingNoteIds(query, includeTrashed = false)
|
||||
if (allIds.isEmpty()) return emptyList()
|
||||
val entities: List<NoteEntity> = allIds.mapNotNull { noteBox.get(it) }
|
||||
return decorate(entities)
|
||||
@@ -553,9 +638,23 @@ class NoteRepositoryImpl(
|
||||
return decorate(favEntities)
|
||||
}
|
||||
|
||||
private fun snapshotTrashed(): List<Note> {
|
||||
val trashedEntities: List<NoteEntity> = noteBox.query()
|
||||
.equal(NoteEntity_.isTrashed, true)
|
||||
.build()
|
||||
.find()
|
||||
return decorate(trashedEntities, includeTrashed = true)
|
||||
}
|
||||
|
||||
private fun snapshotUntagged(): List<Note> {
|
||||
val noteIdsWithTags: Set<Long> = xrefBox.all.map { it.noteId }.toSet()
|
||||
val untaggedEntities: List<NoteEntity> = noteBox.all.filter { it.id !in noteIdsWithTags }
|
||||
val activeIds = activeNoteIds()
|
||||
val noteIdsWithTags: Set<Long> = xrefBox.all
|
||||
.asSequence()
|
||||
.filter { it.noteId in activeIds }
|
||||
.mapTo(HashSet()) { it.noteId }
|
||||
val untaggedEntities: List<NoteEntity> = noteBox.all.filter {
|
||||
it.id in activeIds && it.id !in noteIdsWithTags
|
||||
}
|
||||
return decorate(untaggedEntities)
|
||||
}
|
||||
|
||||
@@ -568,13 +667,23 @@ class NoteRepositoryImpl(
|
||||
private fun snapshotFavoritesSearch(query: String): List<Note> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return snapshotFavorites()
|
||||
val allIds: Set<Long> = snapshotSearchMatchingNoteIds(q)
|
||||
val allIds: Set<Long> = matchingNoteIds(q, includeTrashed = false)
|
||||
if (allIds.isEmpty()) return emptyList()
|
||||
val entities: List<NoteEntity> = allIds.mapNotNull { id -> noteBox.get(id) }
|
||||
.filter { it.isFavorite }
|
||||
return decorate(entities)
|
||||
}
|
||||
|
||||
/** Search only the Trash view, including content and hashtag matches. */
|
||||
private fun snapshotTrashSearch(query: String): List<Note> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return snapshotTrashed()
|
||||
val allIds: Set<Long> = matchingNoteIds(q, includeTrashed = true)
|
||||
if (allIds.isEmpty()) return emptyList()
|
||||
val entities: List<NoteEntity> = allIds.mapNotNull { id -> noteBox.get(id) }
|
||||
return decorate(entities, includeTrashed = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Context-aware search across untagged notes only. Blank [query]
|
||||
* degrades to [snapshotUntagged]. Otherwise runs the content
|
||||
@@ -584,38 +693,18 @@ class NoteRepositoryImpl(
|
||||
private fun snapshotUntaggedSearch(query: String): List<Note> {
|
||||
val q = query.trim()
|
||||
if (q.isEmpty()) return snapshotUntagged()
|
||||
val noteIdsWithTags: Set<Long> = xrefBox.all.mapTo(HashSet(xrefBox.all.size)) { it.noteId }
|
||||
val contentMatches: List<Long> = contentMatchingNoteIds(q)
|
||||
val activeIds = activeNoteIds()
|
||||
val noteIdsWithTags: Set<Long> = xrefBox.all
|
||||
.asSequence()
|
||||
.filter { it.noteId in activeIds }
|
||||
.mapTo(HashSet()) { it.noteId }
|
||||
val contentMatches: List<Long> = contentMatchingNoteIds(q, includeTrashed = false)
|
||||
val matching: List<NoteEntity> = contentMatches
|
||||
.mapNotNull { id -> noteBox.get(id) }
|
||||
.filter { it.id !in noteIdsWithTags }
|
||||
.filter { it.id in activeIds && it.id !in noteIdsWithTags }
|
||||
return decorate(matching)
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared content + tag-name matcher used by [snapshotSearch] and
|
||||
* [snapshotFavoritesSearch]. Returns the set of matching note ids.
|
||||
*/
|
||||
private fun snapshotSearchMatchingNoteIds(query: String): Set<Long> {
|
||||
// Match against content (contains, case-insensitive).
|
||||
val contentMatches: List<Long> = contentMatchingNoteIds(query)
|
||||
|
||||
// Match against hashtag names (case-insensitive exact equality).
|
||||
val matchingTag: HashtagEntity? = tagBox.query()
|
||||
.equal(HashtagEntity_.name, query, QueryBuilder.StringOrder.CASE_INSENSITIVE)
|
||||
.build()
|
||||
.findFirst()
|
||||
val tagMatches: List<Long> = if (matchingTag == null) emptyList() else {
|
||||
xrefBox.query()
|
||||
.equal(NoteHashtagCrossRef_.hashtagId, matchingTag.id)
|
||||
.build()
|
||||
.find()
|
||||
.map { it.noteId }
|
||||
}
|
||||
|
||||
return (contentMatches + tagMatches).toSet()
|
||||
}
|
||||
|
||||
private fun snapshotForHashtag(name: String): List<Note> {
|
||||
val normalised = Hashtag.normalise(name)
|
||||
val tag: HashtagEntity = tagBox.query()
|
||||
@@ -626,7 +715,10 @@ class NoteRepositoryImpl(
|
||||
.equal(NoteHashtagCrossRef_.hashtagId, tag.id)
|
||||
.build()
|
||||
.find()
|
||||
val noteIds: Set<Long> = xrefs.map { it.id }.let { _ -> xrefs.map { it.noteId }.toSet() }
|
||||
val activeIds = activeNoteIds()
|
||||
val noteIds: Set<Long> = xrefs.map { it.noteId }
|
||||
.filter { it in activeIds }
|
||||
.toSet()
|
||||
if (noteIds.isEmpty()) return emptyList()
|
||||
val entities: List<NoteEntity> = noteIds.mapNotNull { noteBox.get(it) }
|
||||
return decorate(entities)
|
||||
@@ -644,7 +736,9 @@ class NoteRepositoryImpl(
|
||||
|
||||
/** Build [HashtagUsage] for every distinct tag, sorted by lastUsedAt DESC. */
|
||||
private fun hashtagUsageSnapshot(): List<HashtagUsage> {
|
||||
val activeIds = activeNoteIds()
|
||||
val xrefs: List<NoteHashtagCrossRef> = xrefBox.all
|
||||
.filter { it.noteId in activeIds }
|
||||
if (xrefs.isEmpty()) return emptyList()
|
||||
|
||||
// 1) Batch-load each unique noteId once (was once per xref, which
|
||||
@@ -687,8 +781,12 @@ class NoteRepositoryImpl(
|
||||
)
|
||||
}
|
||||
|
||||
private fun allHashtagsSnapshot(): List<String> =
|
||||
tagBox.all.map { it.name }
|
||||
private fun allHashtagsSnapshot(): List<String> {
|
||||
val activeTagIds = activeTagIds()
|
||||
return tagBox.all
|
||||
.filter { it.id in activeTagIds }
|
||||
.map { it.name }
|
||||
}
|
||||
|
||||
private fun searchHashtagsSnapshot(prefix: String): List<String> {
|
||||
val p = prefix.trim()
|
||||
@@ -699,9 +797,17 @@ class NoteRepositoryImpl(
|
||||
.build()
|
||||
.find()
|
||||
|
||||
// Sort by usage count (most-used first), then name.
|
||||
val usageById: Map<Long, Int> = xrefBox.all.groupingBy { it.hashtagId }.eachCount()
|
||||
return byPrefix
|
||||
// Trashed notes must not contribute to autocomplete suggestions.
|
||||
val activeTagIds = activeTagIds()
|
||||
val activeByPrefix = byPrefix.filter { it.id in activeTagIds }
|
||||
|
||||
// Sort by active-note usage count (most-used first), then name.
|
||||
val usageById: Map<Long, Int> = xrefBox.all
|
||||
.asSequence()
|
||||
.filter { it.noteId in activeTagIds }
|
||||
.groupingBy { it.hashtagId }
|
||||
.eachCount()
|
||||
return activeByPrefix
|
||||
.sortedWith(
|
||||
compareByDescending<HashtagEntity> { usageById[it.id] ?: 0 }
|
||||
.thenBy { it.name }
|
||||
|
||||
@@ -22,6 +22,8 @@ data class Note(
|
||||
* so the UI can render them in stable order.
|
||||
*/
|
||||
val attachments: List<NoteAttachment> = emptyList(),
|
||||
/** True only for notes moved to the Trash view; active-note queries exclude these rows. */
|
||||
val isTrashed: Boolean = false,
|
||||
) {
|
||||
/** Convenience: the first image attachment, or `null` if none. */
|
||||
val firstImageAttachment: NoteAttachment?
|
||||
|
||||
@@ -5,15 +5,17 @@ package org.incido.domain.model
|
||||
* `NoteListScreen` body and the selected entry in the navigation
|
||||
* drawer.
|
||||
*
|
||||
* - [Home] — every note (the default). The search bar is enabled.
|
||||
* - [Favorites] — only notes with `isFavorite = true`. No search.
|
||||
* - [Untagged] — only notes that have zero hashtags. No search.
|
||||
* - [ByTag] — only notes tagged with [hashtag]. No search.
|
||||
* - [Home] — every active note (the default). The search bar is enabled.
|
||||
* - [Favorites] — only notes with `isFavorite = true`; ordinary search is enabled.
|
||||
* - [Untagged] — only notes that have zero hashtags; ordinary search is enabled.
|
||||
* - [ByTag] — only notes tagged with [hashtag]; text search is not offered.
|
||||
* - [Trash] — only notes moved out of the active list; no edit actions.
|
||||
*/
|
||||
sealed class NoteFilter {
|
||||
object Home : NoteFilter()
|
||||
object Favorites : NoteFilter()
|
||||
object Untagged : NoteFilter()
|
||||
object Trash : NoteFilter()
|
||||
data class ByTag(val hashtag: String) : NoteFilter()
|
||||
|
||||
/** Stable identifier used by the drawer for `selected` matching. */
|
||||
@@ -21,6 +23,7 @@ sealed class NoteFilter {
|
||||
Home -> "home"
|
||||
Favorites -> "favorites"
|
||||
Untagged -> "untagged"
|
||||
Trash -> "trash"
|
||||
is ByTag -> "tag:$hashtag"
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,12 @@ import org.incido.domain.model.NoteAttachment
|
||||
* (case-insensitive equality).
|
||||
*/
|
||||
interface NoteRepository {
|
||||
/** Stream of all notes, newest-first, favourites pinned to the top. */
|
||||
/** Stream of all active notes, newest-first, favourites pinned to the top. */
|
||||
fun observeAll(): Flow<List<Note>>
|
||||
|
||||
/** Stream of every note, including trashed notes, for maintenance/backup flows. */
|
||||
fun observeAllIncludingTrashed(): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Stream of notes whose [Note.content] contains [query] (case-insensitive)
|
||||
* OR whose hashtags contain [query] as one of the names. Favourites
|
||||
@@ -31,9 +34,15 @@ interface NoteRepository {
|
||||
/** Persist a new note or update an existing one. Returns the persisted [Note]. */
|
||||
suspend fun upsert(note: Note): Note
|
||||
|
||||
/** Delete a note by id. No-op if it doesn't exist. */
|
||||
/** Permanently delete a note by id. No-op if it doesn't exist. */
|
||||
suspend fun delete(id: Long)
|
||||
|
||||
/** Move a note to Trash without removing its row, tags, or attachments. */
|
||||
suspend fun softDelete(id: Long)
|
||||
|
||||
/** Restore a trashed note to the active list. */
|
||||
suspend fun restore(id: Long)
|
||||
|
||||
/** Toggle the favourite flag on a single note. */
|
||||
suspend fun setFavorite(id: Long, isFavorite: Boolean)
|
||||
|
||||
@@ -44,6 +53,9 @@ interface NoteRepository {
|
||||
/** Only notes that have zero hashtags, sorted by updatedAt DESC. */
|
||||
fun observeUntagged(): Flow<List<Note>>
|
||||
|
||||
/** Only notes in Trash, sorted by updatedAt DESC. */
|
||||
fun observeTrashed(): Flow<List<Note>>
|
||||
|
||||
/**
|
||||
* Context-aware search across **favourites only** — matches
|
||||
* [Note.content] (contains, case-insensitive) AND any of the note's
|
||||
@@ -60,6 +72,9 @@ interface NoteRepository {
|
||||
*/
|
||||
fun searchUntagged(query: String): Flow<List<Note>>
|
||||
|
||||
/** Search only trashed notes by content or hashtag. */
|
||||
fun searchTrashed(query: String): Flow<List<Note>>
|
||||
|
||||
/** Only notes tagged with [name] (normalised form), sorted by updatedAt DESC. */
|
||||
fun observeNotesForHashtag(name: String): Flow<List<Note>>
|
||||
|
||||
|
||||
Reference in new issue
Block a user