V3 S5 : graphe documentaire + doublons + collections
Backend : resource_links + scan_session_id (000021), réconciliation déterministe (same_scan outbox, doublons SHA-256 à l'upload + backfill, same_issuer/référence via faits effectifs, verdicts préservés, élagage auto), GET /files/:id/relations + verdict (owner-only), GET /duplicates (groupes + gain récupérable). Tests service + handlers + migrations. Mobile (Room v22) : links + collections, scanSessionId dans les creates de scan, LinksRepository (sync + verdicts REST), « Voir aussi » dans la fiche (verdict infirmer/re-confirmer), écran Doublons (garder le plus récent), collections locales (sauver/rejouer/supprimer). FR/EN. Contrat docs/api-v1.md (/relations, pas /links — pris par le partage), V3.md (S5 livré, version_of non matérialisé).
This commit is contained in:
@@ -5,6 +5,8 @@ import androidx.room.RoomDatabase
|
||||
import com.kazier.mobile.data.local.dao.FileDao
|
||||
import com.kazier.mobile.data.local.dao.FactsDao
|
||||
import com.kazier.mobile.data.local.dao.FolderDao
|
||||
import com.kazier.mobile.data.local.dao.LinksDao
|
||||
import com.kazier.mobile.data.local.dao.CollectionDao
|
||||
import com.kazier.mobile.data.local.dao.PendingOperationDao
|
||||
import com.kazier.mobile.data.local.dao.ResourcePermissionDao
|
||||
import com.kazier.mobile.data.local.dao.ScanDao
|
||||
@@ -12,8 +14,10 @@ import com.kazier.mobile.data.local.dao.UserPreferenceDao
|
||||
import com.kazier.mobile.data.local.entity.FileEntity
|
||||
import com.kazier.mobile.data.local.entity.FilesFts
|
||||
import com.kazier.mobile.data.local.entity.FolderEntity
|
||||
import com.kazier.mobile.data.local.entity.CollectionEntity
|
||||
import com.kazier.mobile.data.local.entity.PendingOperationEntity
|
||||
import com.kazier.mobile.data.local.entity.ResourceFact
|
||||
import com.kazier.mobile.data.local.entity.ResourceLink
|
||||
import com.kazier.mobile.data.local.entity.ResourcePermissionEntity
|
||||
import com.kazier.mobile.data.local.entity.ScanPageEntity
|
||||
import com.kazier.mobile.data.local.entity.ScanSessionEntity
|
||||
@@ -41,18 +45,20 @@ import com.kazier.mobile.data.local.entity.UserPreferenceEntity
|
||||
* restore exists=1, purge locale après 30j+).
|
||||
* v20: table resource_facts (faits génériques V3 — miroir GET /facts,
|
||||
* remplacement en bloc au sync, corrections `user` poussées en outbox).
|
||||
* v21: table virtuelle FTS4 `files_fts` (nom + corps ocr+faits) + triggers
|
||||
* de maintien (files insert/update/delete, facts insert/update/delete) —
|
||||
* recherche plein-texte offline S4. Pas d'entité Room (table virtuelle
|
||||
* maintenue en SQL migration uniquement, requêtes via `FileDao`).
|
||||
* v21: table virtuelle FTS4 `files_fts` (nom + corps ocr+faits, entité
|
||||
* `FilesFts` déclarée pour KSP) + triggers de maintien (`FtsTriggers` :
|
||||
* migration + callback fresh-install) — recherche plein-texte offline S4.
|
||||
* v22: `resource_links` (miroir `GET /relations`, remplacement en bloc) +
|
||||
* `collections` (requêtes sauvegardées locales, jamais syncées).
|
||||
*/
|
||||
@Database(
|
||||
entities = [
|
||||
FolderEntity::class, UserPreferenceEntity::class, FileEntity::class,
|
||||
PendingOperationEntity::class, ScanSessionEntity::class, ScanPageEntity::class,
|
||||
ResourcePermissionEntity::class, ResourceFact::class, FilesFts::class,
|
||||
ResourceLink::class, CollectionEntity::class,
|
||||
],
|
||||
version = 21,
|
||||
version = 22,
|
||||
// m19 : schéma exporté (`app/schemas/`) — toute dérive non migrée casse
|
||||
// la compilation au lieu de briqueter les utilisateurs au démarrage.
|
||||
exportSchema = true,
|
||||
@@ -61,6 +67,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun folderDao(): FolderDao
|
||||
abstract fun factsDao(): FactsDao
|
||||
abstract fun linksDao(): LinksDao
|
||||
abstract fun collectionDao(): CollectionDao
|
||||
abstract fun userPreferenceDao(): UserPreferenceDao
|
||||
abstract fun fileDao(): FileDao
|
||||
abstract fun pendingOperationDao(): PendingOperationDao
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.kazier.mobile.data.local.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import com.kazier.mobile.data.local.entity.CollectionEntity
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface CollectionDao {
|
||||
|
||||
@Query("SELECT * FROM collections ORDER BY created_at DESC")
|
||||
fun observeAll(): Flow<List<CollectionEntity>>
|
||||
|
||||
@Query("SELECT * FROM collections WHERE id = :id LIMIT 1")
|
||||
suspend fun getById(id: Long): CollectionEntity?
|
||||
|
||||
@Insert
|
||||
suspend fun insert(collection: CollectionEntity): Long
|
||||
|
||||
@Query("DELETE FROM collections WHERE id = :id")
|
||||
suspend fun deleteById(id: Long)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.kazier.mobile.data.local.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import com.kazier.mobile.data.local.entity.ResourceLink
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface LinksDao {
|
||||
|
||||
/** Arêtes touchant la ressource (les deux sens, confiance décroissante). */
|
||||
@Query("""
|
||||
SELECT * FROM resource_links
|
||||
WHERE from_id = :resourceId OR to_id = :resourceId
|
||||
ORDER BY confidence DESC
|
||||
""")
|
||||
fun observeForResource(resourceId: String): Flow<List<ResourceLink>>
|
||||
|
||||
@Query("""
|
||||
SELECT * FROM resource_links
|
||||
WHERE from_id = :resourceId OR to_id = :resourceId
|
||||
ORDER BY confidence DESC
|
||||
""")
|
||||
suspend fun getForResource(resourceId: String): List<ResourceLink>
|
||||
|
||||
@Insert
|
||||
suspend fun insertAll(links: List<ResourceLink>)
|
||||
|
||||
/** Remplacement en bloc (sync serveur, source de vérité) — voir repository. */
|
||||
@Query("DELETE FROM resource_links WHERE from_id = :resourceId OR to_id = :resourceId")
|
||||
suspend fun deleteForResource(resourceId: String)
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.kazier.mobile.data.local.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* Collection locale V3 (S5) : requête de recherche sauvegardée
|
||||
* (texte + facettes JSON) — pur local, jamais synchronisée (un device, pas
|
||||
* de conflit ; sync serveur = V4). Ex. « Impôts 2026 ».
|
||||
*/
|
||||
@Entity(
|
||||
tableName = "collections",
|
||||
indices = [
|
||||
Index(value = ["name"], unique = true),
|
||||
],
|
||||
)
|
||||
data class CollectionEntity(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
val id: Long = 0L,
|
||||
@ColumnInfo(name = "name")
|
||||
val name: String,
|
||||
/** Texte de recherche (peut être vide : facettes seules). */
|
||||
@ColumnInfo(name = "query")
|
||||
val query: String = "",
|
||||
/** Facettes sérialisées (`SearchFacets` JSON, Moshi Map). */
|
||||
@ColumnInfo(name = "facets_json")
|
||||
val facetsJson: String = "{}",
|
||||
@ColumnInfo(name = "category")
|
||||
val category: String? = null,
|
||||
@ColumnInfo(name = "created_at")
|
||||
val createdAt: Long,
|
||||
)
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.kazier.mobile.data.local.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
/**
|
||||
* Miroir local d'une arête `GET /files/:id/relations` (V3 S5).
|
||||
*
|
||||
* Stockée orientée (`fromId`/`toId` canoniques serveur) mais lue dans les
|
||||
* deux sens (`LinksRepository.observeRelations`). Remplacement en bloc au
|
||||
* sync par ressource (le serveur réconcilie à la lecture). Les verdicts
|
||||
* (`createdBy = user`) sont écrits d'abord en Room (optimiste) puis poussés
|
||||
* en REST direct (pas d'outbox — acte rare, en ligne uniquement, S5).
|
||||
*/
|
||||
@Entity(
|
||||
tableName = "resource_links",
|
||||
indices = [
|
||||
Index(value = ["from_id", "to_id", "link_type"], unique = true),
|
||||
Index(value = ["to_id"]),
|
||||
],
|
||||
)
|
||||
data class ResourceLink(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
val id: Long = 0L,
|
||||
@ColumnInfo(name = "from_id")
|
||||
val fromId: String,
|
||||
@ColumnInfo(name = "to_id")
|
||||
val toId: String,
|
||||
@ColumnInfo(name = "link_type")
|
||||
val linkType: String,
|
||||
@ColumnInfo(name = "confidence")
|
||||
val confidence: Double = 0.0,
|
||||
@ColumnInfo(name = "created_by")
|
||||
val createdBy: String = LinkOrigin.AUTO,
|
||||
@ColumnInfo(name = "updated_at")
|
||||
val updatedAt: Long,
|
||||
) {
|
||||
/** L'autre bout vu depuis [resourceId] (arête symétrique). */
|
||||
fun otherEnd(resourceId: String): String =
|
||||
if (fromId == resourceId) toId else fromId
|
||||
}
|
||||
|
||||
/** Origines d'une arête — miroir du CHECK serveur (migration 000021). */
|
||||
object LinkOrigin {
|
||||
const val AUTO = "auto"
|
||||
const val USER = "user"
|
||||
}
|
||||
|
||||
/** Types d'arêtes — miroir du CHECK serveur (pas de `version_of` : les
|
||||
* versions vivent DANS la ressource). */
|
||||
object LinkType {
|
||||
const val SAME_SCAN = "same_scan"
|
||||
const val DUPLICATE_OF = "duplicate_of"
|
||||
const val SAME_ISSUER = "same_issuer"
|
||||
const val SAME_REFERENCE = "same_reference"
|
||||
}
|
||||
+50
-1
@@ -389,7 +389,56 @@ object Migrations {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* V3 relations + collections (S5) : `resource_links` (miroir
|
||||
* `GET /relations`, remplacement en bloc) + `collections` (requêtes
|
||||
* sauvegardées locales). Schémas alignés sur les entités (exports
|
||||
* `app/schemas/22.json`).
|
||||
*/
|
||||
private val MIGRATION_21_22 = object : Migration(21, 22) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS `resource_links` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`from_id` TEXT NOT NULL,
|
||||
`to_id` TEXT NOT NULL,
|
||||
`link_type` TEXT NOT NULL,
|
||||
`confidence` REAL NOT NULL,
|
||||
`created_by` TEXT NOT NULL,
|
||||
`updated_at` INTEGER NOT NULL
|
||||
)
|
||||
""".trimIndent(),
|
||||
)
|
||||
db.execSQL(
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS `index_resource_links_from_id_to_id_link_type` " +
|
||||
"ON `resource_links` (`from_id`, `to_id`, `link_type`)",
|
||||
)
|
||||
db.execSQL(
|
||||
"CREATE INDEX IF NOT EXISTS `index_resource_links_to_id` " +
|
||||
"ON `resource_links` (`to_id`)",
|
||||
)
|
||||
db.execSQL(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS `collections` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
`query` TEXT NOT NULL,
|
||||
`facets_json` TEXT NOT NULL,
|
||||
`category` TEXT,
|
||||
`created_at` INTEGER NOT NULL
|
||||
)
|
||||
""".trimIndent(),
|
||||
)
|
||||
db.execSQL(
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS `index_collections_name` " +
|
||||
"ON `collections` (`name`)",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** En dernier : l'ordre d'init Kotlin exige les migrations avant. */
|
||||
val ALL: Array<Migration> = arrayOf(
|
||||
MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13, MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17, MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
|
||||
MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7, MIGRATION_7_8, MIGRATION_8_9, MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13, MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17, MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21, MIGRATION_21_22,
|
||||
)
|
||||
}
|
||||
@@ -30,7 +30,10 @@ import com.kazier.mobile.data.remote.dto.SyncOpDto
|
||||
import com.kazier.mobile.data.remote.dto.SyncOpsRequest
|
||||
import com.kazier.mobile.data.remote.dto.SyncOpsResult
|
||||
import com.kazier.mobile.data.remote.dto.CorrectFactsDto
|
||||
import com.kazier.mobile.data.remote.dto.DuplicateGroupDto
|
||||
import com.kazier.mobile.data.remote.dto.FactDto
|
||||
import com.kazier.mobile.data.remote.dto.RelationDto
|
||||
import com.kazier.mobile.data.remote.dto.RelationVerdictDto
|
||||
import com.kazier.mobile.data.remote.dto.TrashDto
|
||||
import com.kazier.mobile.data.remote.dto.VersionDto
|
||||
import kotlin.coroutines.cancellation.CancellationException
|
||||
@@ -175,6 +178,18 @@ class ApiClient @Inject constructor(
|
||||
suspend fun correctFacts(fileId: String, facts: List<FactDto>): List<FactDto> =
|
||||
unwrap({ apiService.correctFacts(fileId, CorrectFactsDto(facts)) })
|
||||
|
||||
/** Graphe documentaire V3 — `GET /files/:id/relations` (owner-only). */
|
||||
suspend fun listRelations(fileId: String): List<RelationDto> =
|
||||
unwrap({ apiService.listRelations(fileId) })
|
||||
|
||||
/** Verdict sur une arête — renvoie le jeu réconcilié. */
|
||||
suspend fun verdictRelation(fileId: String, otherId: String, linkType: String, confirmed: Boolean): List<RelationDto> =
|
||||
unwrap({ apiService.verdictRelation(fileId, RelationVerdictDto(otherId, linkType, confirmed)) })
|
||||
|
||||
/** Doublons d'octets — `GET /duplicates` (owner). */
|
||||
suspend fun listDuplicates(): List<DuplicateGroupDto> =
|
||||
unwrap({ apiService.listDuplicates() })
|
||||
|
||||
/** Recherche serveur paginée — `GET /files/search?q=…` (+ `meta`). */
|
||||
suspend fun searchFilesPaged(
|
||||
query: String,
|
||||
|
||||
@@ -23,7 +23,10 @@ import com.kazier.mobile.data.remote.dto.ShareLinkDto
|
||||
import com.kazier.mobile.data.remote.dto.SyncOpsRequest
|
||||
import com.kazier.mobile.data.remote.dto.SyncOpsResult
|
||||
import com.kazier.mobile.data.remote.dto.CorrectFactsDto
|
||||
import com.kazier.mobile.data.remote.dto.DuplicateGroupDto
|
||||
import com.kazier.mobile.data.remote.dto.FactDto
|
||||
import com.kazier.mobile.data.remote.dto.RelationDto
|
||||
import com.kazier.mobile.data.remote.dto.RelationVerdictDto
|
||||
import com.kazier.mobile.data.remote.dto.TrashDto
|
||||
import com.kazier.mobile.data.remote.dto.VersionDto
|
||||
import okhttp3.MultipartBody
|
||||
@@ -197,6 +200,29 @@ interface ApiService {
|
||||
@Body body: CorrectFactsDto,
|
||||
): Response<ApiEnvelope<List<FactDto>>>
|
||||
|
||||
/**
|
||||
* Graphe documentaire V3 (`GET /files/:id/relations`, owner-only) —
|
||||
* arêtes réconciliées à la lecture, autre bout vivant, confiance décroissante.
|
||||
*/
|
||||
@GET("files/{id}/relations")
|
||||
suspend fun listRelations(
|
||||
@Path("id") fileId: String,
|
||||
): Response<ApiEnvelope<List<RelationDto>>>
|
||||
|
||||
/** Verdict explicite sur une arête (confirmé → 1.0, infirmé → 0.0). */
|
||||
@POST("files/{id}/relations/verdict")
|
||||
suspend fun verdictRelation(
|
||||
@Path("id") fileId: String,
|
||||
@Body body: RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<RelationDto>>>
|
||||
|
||||
/**
|
||||
* Doublons d'octets du compte (`GET /duplicates`, owner) — groupes par
|
||||
* hash, plus gros d'abord, avec le gain récupérable (B2).
|
||||
*/
|
||||
@GET("duplicates")
|
||||
suspend fun listDuplicates(): Response<ApiEnvelope<List<DuplicateGroupDto>>>
|
||||
|
||||
/**
|
||||
* Recherche serveur (`GET /files/search?q=…`, paginé `meta`). Non consommée
|
||||
* en V1 (recherche 100 % locale via Room) — exposée pour parité contrat.
|
||||
|
||||
@@ -296,4 +296,43 @@ data class FactDto(
|
||||
/** Body `PATCH /files/{id}/facts` — jeu `user` complet (full-replace, S3). */
|
||||
data class CorrectFactsDto(
|
||||
@Json(name = "facts") val facts: List<FactDto>,
|
||||
)
|
||||
|
||||
/**
|
||||
* Arête `GET /files/{id}/relations` (V3 S5) — miroir de `RelationDTO` Go.
|
||||
* Graphe owner-only, réconcilié à la lecture côté serveur.
|
||||
*/
|
||||
data class RelationDto(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "otherId") val otherId: String,
|
||||
@Json(name = "type") val type: String,
|
||||
@Json(name = "confidence") val confidence: Double = 0.0,
|
||||
@Json(name = "createdBy") val createdBy: String = "auto",
|
||||
@Json(name = "otherName") val otherName: String = "",
|
||||
@Json(name = "otherType") val otherType: String = "file",
|
||||
@Json(name = "otherSize") val otherSize: Long = 0L,
|
||||
)
|
||||
|
||||
/** Body `POST /files/{id}/relations/verdict` — verdict explicite (S5). */
|
||||
data class RelationVerdictDto(
|
||||
@Json(name = "otherId") val otherId: String,
|
||||
@Json(name = "linkType") val linkType: String,
|
||||
@Json(name = "confirmed") val confirmed: Boolean,
|
||||
)
|
||||
|
||||
/** Membre d'un groupe de doublons `GET /duplicates` (S5 B2). */
|
||||
data class DuplicateFileDto(
|
||||
@Json(name = "id") val id: String,
|
||||
@Json(name = "name") val name: String,
|
||||
@Json(name = "size") val size: Long = 0L,
|
||||
@Json(name = "updatedAt") val updatedAt: Long = 0L,
|
||||
)
|
||||
|
||||
/** Groupe de fichiers aux octets identiques (S5 B2). */
|
||||
data class DuplicateGroupDto(
|
||||
@Json(name = "contentHash") val contentHash: String,
|
||||
@Json(name = "count") val count: Int = 0,
|
||||
@Json(name = "totalBytes") val totalBytes: Long = 0L,
|
||||
@Json(name = "reclaimableBytes") val reclaimableBytes: Long = 0L,
|
||||
@Json(name = "files") val files: List<DuplicateFileDto> = emptyList(),
|
||||
)
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.kazier.mobile.data.repository
|
||||
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.Types
|
||||
import com.kazier.mobile.data.local.dao.CollectionDao
|
||||
import com.kazier.mobile.data.local.entity.CollectionEntity
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Collections locales V3 (S5) : recherches sauvegardées (texte + facettes),
|
||||
* purement locales — jamais synchronisées (un device, pas de conflit).
|
||||
*/
|
||||
@Singleton
|
||||
class CollectionsRepository @Inject constructor(
|
||||
private val collectionDao: CollectionDao,
|
||||
moshi: Moshi,
|
||||
) {
|
||||
|
||||
private val facetsAdapter: JsonAdapter<Map<String, Any?>> = moshi.adapter(
|
||||
Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java),
|
||||
)
|
||||
|
||||
fun observeAll(): Flow<List<CollectionEntity>> = collectionDao.observeAll()
|
||||
|
||||
suspend fun save(name: String, query: String, category: String?, facets: SearchFacets): Long {
|
||||
val trimmed = name.trim()
|
||||
require(trimmed.isNotEmpty()) { "collection name required" }
|
||||
return collectionDao.insert(
|
||||
CollectionEntity(
|
||||
name = trimmed,
|
||||
query = query.trim(),
|
||||
facetsJson = facetsAdapter.toJson(facets.toMap()),
|
||||
category = category,
|
||||
createdAt = System.currentTimeMillis(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun delete(id: Long) = collectionDao.deleteById(id)
|
||||
|
||||
suspend fun get(id: Long): CollectionEntity? = collectionDao.getById(id)
|
||||
|
||||
/** Rejoue une collection : texte + facettes désérialisées (inconnues ignorées). */
|
||||
fun apply(collection: CollectionEntity): AppliedCollection {
|
||||
val map = runCatching {
|
||||
facetsAdapter.fromJson(collection.facetsJson)
|
||||
}.getOrNull() ?: emptyMap()
|
||||
return AppliedCollection(
|
||||
query = collection.query,
|
||||
category = collection.category,
|
||||
facets = SearchFacets(
|
||||
issuer = map["issuer"] as? String,
|
||||
docType = map["docType"] as? String,
|
||||
minAmount = (map["minAmount"] as? Number)?.toDouble(),
|
||||
maxAmount = (map["maxAmount"] as? Number)?.toDouble(),
|
||||
fromDate = map["fromDate"] as? String,
|
||||
toDate = map["toDate"] as? String,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun SearchFacets.toMap(): Map<String, Any?> = buildMap {
|
||||
issuer?.let { put("issuer", it) }
|
||||
docType?.let { put("docType", it) }
|
||||
minAmount?.let { put("minAmount", it) }
|
||||
maxAmount?.let { put("maxAmount", it) }
|
||||
fromDate?.let { put("fromDate", it) }
|
||||
toDate?.let { put("toDate", it) }
|
||||
}
|
||||
}
|
||||
|
||||
/** Collection rejouée : à appliquer à l'état de recherche. */
|
||||
data class AppliedCollection(
|
||||
val query: String,
|
||||
val category: String?,
|
||||
val facets: SearchFacets,
|
||||
)
|
||||
@@ -320,6 +320,7 @@ class FileRepository @Inject constructor(
|
||||
parentResourceId = entity.folderResourceId,
|
||||
mimeType = entity.mimeType,
|
||||
extension = entity.extension,
|
||||
scanSessionId = input.scanSessionId,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -506,6 +507,11 @@ data class SaveFileInput(
|
||||
val syncStatus: String? = null,
|
||||
/** Le fichier arrive déjà « traité » (ex. scan) ou à traiter dans la review. */
|
||||
val processed: Boolean = false,
|
||||
/**
|
||||
* V3 S5 : session de scan opaque (pages d'un même export) — propagée au
|
||||
* `create_resource` pour les arêtes `same_scan` serveur. NULL sinon.
|
||||
*/
|
||||
val scanSessionId: String? = null,
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.kazier.mobile.data.repository
|
||||
|
||||
import androidx.room.withTransaction
|
||||
import com.kazier.mobile.data.local.AppDatabase
|
||||
import com.kazier.mobile.data.local.dao.LinksDao
|
||||
import com.kazier.mobile.data.local.entity.LinkOrigin
|
||||
import com.kazier.mobile.data.local.entity.ResourceLink
|
||||
import com.kazier.mobile.data.remote.ApiClient
|
||||
import com.kazier.mobile.data.remote.dto.RelationDto
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
/**
|
||||
* Graphe documentaire V3 (S5) côté client.
|
||||
*
|
||||
* - [syncFromServer] : `GET /files/:id/relations` → remplacement en bloc
|
||||
* Room (le serveur réconcilie à la lecture — même pattern que les faits).
|
||||
* - [setVerdict] : verdict optimiste local + REST direct (**pas d'outbox** :
|
||||
* acte rare, en ligne uniquement — hors-ligne = erreur remontée, la fiche
|
||||
* garde l'état serveur). Le serveur renvoie le jeu réconcilié qui écrase
|
||||
* le miroir (convergence immédiate).
|
||||
*/
|
||||
@Singleton
|
||||
class LinksRepository @Inject constructor(
|
||||
private val appDatabase: AppDatabase,
|
||||
private val linksDao: LinksDao,
|
||||
private val apiClient: ApiClient,
|
||||
) {
|
||||
|
||||
fun observeRelations(resourceId: String): Flow<List<ResourceLink>> =
|
||||
linksDao.observeForResource(resourceId)
|
||||
|
||||
suspend fun getRelations(resourceId: String): List<ResourceLink> =
|
||||
linksDao.getForResource(resourceId)
|
||||
|
||||
/** Rapatrie le jeu serveur (auto + verdicts) et remplace le miroir local. */
|
||||
suspend fun syncFromServer(resourceId: String): List<ResourceLink> {
|
||||
val dtos = apiClient.listRelations(resourceId)
|
||||
val now = System.currentTimeMillis()
|
||||
val entities = dtos.map { it.toEntity(resourceId, now) }
|
||||
appDatabase.withTransaction {
|
||||
linksDao.deleteForResource(resourceId)
|
||||
if (entities.isNotEmpty()) linksDao.insertAll(entities)
|
||||
}
|
||||
return entities
|
||||
}
|
||||
|
||||
/**
|
||||
* Verdict explicite (confirmé → 1.0, infirmé → 0.0, origine `user`) :
|
||||
* écriture optimiste + REST. Le jeu renvoyé remplace le miroir.
|
||||
* Lève en hors-ligne (le verdict attendra un réseau — pas de file).
|
||||
*/
|
||||
suspend fun setVerdict(resourceId: String, otherId: String, linkType: String, confirmed: Boolean) {
|
||||
val now = System.currentTimeMillis()
|
||||
val optimistic = ResourceLink(
|
||||
fromId = minOf(resourceId, otherId),
|
||||
toId = maxOf(resourceId, otherId),
|
||||
linkType = linkType,
|
||||
confidence = if (confirmed) 1.0 else 0.0,
|
||||
createdBy = LinkOrigin.USER,
|
||||
updatedAt = now,
|
||||
)
|
||||
appDatabase.withTransaction {
|
||||
linksDao.deleteForResource(resourceId)
|
||||
val current = linksDao.getForResource(resourceId)
|
||||
.filterNot { it.otherEnd(resourceId) == otherId && it.linkType == linkType }
|
||||
linksDao.insertAll(current + optimistic)
|
||||
}
|
||||
val dtos = apiClient.verdictRelation(resourceId, otherId, linkType, confirmed)
|
||||
val entities = dtos.map { it.toEntity(resourceId, now) }
|
||||
appDatabase.withTransaction {
|
||||
linksDao.deleteForResource(resourceId)
|
||||
if (entities.isNotEmpty()) linksDao.insertAll(entities)
|
||||
}
|
||||
}
|
||||
|
||||
private fun RelationDto.toEntity(resourceId: String, now: Long): ResourceLink {
|
||||
// Ordre canonique serveur (from < to) — conservé tel quel.
|
||||
val (from, to) = if (resourceId <= otherId) resourceId to otherId else otherId to resourceId
|
||||
return ResourceLink(
|
||||
fromId = from,
|
||||
toId = to,
|
||||
linkType = type,
|
||||
confidence = confidence,
|
||||
createdBy = createdBy.ifBlank { LinkOrigin.AUTO },
|
||||
updatedAt = now,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,9 @@ class OutboxRepository @Inject constructor(
|
||||
parentResourceId: String? = null,
|
||||
mimeType: String? = null,
|
||||
extension: String? = null,
|
||||
// V3 S5 : session de scan opaque (même export multi-pages) — le
|
||||
// serveur en déduit les arêtes `same_scan`. NULL = ressource isolée.
|
||||
scanSessionId: String? = null,
|
||||
): String = enqueue(
|
||||
operation = PendingOperationType.CREATE_RESOURCE,
|
||||
resourceId = resourceId,
|
||||
@@ -86,6 +89,7 @@ class OutboxRepository @Inject constructor(
|
||||
parentResourceId?.let { put("parentResourceId", it) }
|
||||
mimeType?.let { put("mimeType", it) }
|
||||
extension?.let { put("extension", it) }
|
||||
scanSessionId?.let { put("scanSessionId", it) }
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.kazier.mobile.data.local.AppDatabase
|
||||
import com.kazier.mobile.data.local.dao.FileDao
|
||||
import com.kazier.mobile.data.local.dao.FactsDao
|
||||
import com.kazier.mobile.data.local.dao.FolderDao
|
||||
import com.kazier.mobile.data.local.dao.LinksDao
|
||||
import com.kazier.mobile.data.local.dao.CollectionDao
|
||||
import com.kazier.mobile.data.local.dao.PendingOperationDao
|
||||
import com.kazier.mobile.data.local.dao.ResourcePermissionDao
|
||||
import com.kazier.mobile.data.local.dao.ScanDao
|
||||
@@ -67,4 +69,10 @@ object DatabaseModule {
|
||||
|
||||
@Provides
|
||||
fun provideFactsDao(db: AppDatabase): FactsDao = db.factsDao()
|
||||
|
||||
@Provides
|
||||
fun provideLinksDao(db: AppDatabase): LinksDao = db.linksDao()
|
||||
|
||||
@Provides
|
||||
fun provideCollectionDao(db: AppDatabase): CollectionDao = db.collectionDao()
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.kazier.mobile.ui.duplicates
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.ContentCopy
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.kazier.mobile.R
|
||||
import com.kazier.mobile.data.remote.dto.DuplicateGroupDto
|
||||
import com.kazier.mobile.ui.components.formatFileSize
|
||||
|
||||
/**
|
||||
* Doublons V3 (S5 B2) : groupes identiques avec gain récupérable + action
|
||||
* « garder le plus récent » (trash FULL du reste). Point d'entrée :
|
||||
* Réglages → Doublons.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DuplicatesScreen(
|
||||
onBack: () -> Unit,
|
||||
viewModel: DuplicatesViewModel = hiltViewModel(),
|
||||
) {
|
||||
val state by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
LaunchedEffect(state.error) {
|
||||
state.error?.let {
|
||||
snackbarHostState.showSnackbar(it)
|
||||
viewModel.clearError()
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.duplicates_title)) },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(R.string.back),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
},
|
||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||
) { padding ->
|
||||
if (state.isLoading && state.groups.isEmpty()) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(padding),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
} else if (state.groups.isEmpty()) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().padding(padding).padding(32.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.duplicates_empty),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize().padding(padding),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
item(key = "hint") {
|
||||
Text(
|
||||
text = stringResource(R.string.duplicates_hint),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
items(state.groups, key = { it.contentHash }) { group ->
|
||||
DuplicateGroupCard(
|
||||
group = group,
|
||||
busy = state.busyGroup == group.contentHash,
|
||||
onKeepNewest = { viewModel.keepNewest(group) },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun DuplicateGroupCard(
|
||||
group: DuplicateGroupDto,
|
||||
busy: Boolean,
|
||||
onKeepNewest: () -> Unit,
|
||||
) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(12.dp)) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Icon(
|
||||
Icons.Filled.ContentCopy,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(24.dp),
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = stringResource(R.string.duplicates_group, group.count),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Medium,
|
||||
)
|
||||
Text(
|
||||
text = stringResource(
|
||||
R.string.duplicates_reclaimable,
|
||||
formatFileSize(group.reclaimableBytes),
|
||||
),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
if (busy) {
|
||||
CircularProgressIndicator(modifier = Modifier.size(24.dp))
|
||||
} else {
|
||||
IconButton(onClick = onKeepNewest) {
|
||||
Icon(
|
||||
Icons.Filled.Delete,
|
||||
contentDescription = stringResource(R.string.duplicates_keep_newest),
|
||||
tint = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(8.dp))
|
||||
group.files.forEachIndexed { index, file ->
|
||||
Text(
|
||||
text = (if (index == 0) "✓ " else " ") + file.name,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = if (index == 0) MaterialTheme.colorScheme.onSurface
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.kazier.mobile.ui.duplicates
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.kazier.mobile.data.remote.ApiClient
|
||||
import com.kazier.mobile.data.remote.dto.DuplicateGroupDto
|
||||
import com.kazier.mobile.data.repository.FileRepository
|
||||
import com.kazier.mobile.features.saf.FileDeleter
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Doublons V3 (S5 B2) : groupes de fichiers aux octets identiques, avec le
|
||||
* gain récupérable. « Garder le plus récent » trashe le reste (FULL :
|
||||
* corbeille serveur + suppression locale) — le plus récent (1er, tri
|
||||
* serveur) est conservé.
|
||||
*/
|
||||
@HiltViewModel
|
||||
class DuplicatesViewModel @Inject constructor(
|
||||
private val apiClient: ApiClient,
|
||||
private val fileRepository: FileRepository,
|
||||
private val fileDeleter: FileDeleter,
|
||||
) : ViewModel() {
|
||||
|
||||
data class DuplicatesUiState(
|
||||
val isLoading: Boolean = false,
|
||||
val groups: List<DuplicateGroupDto> = emptyList(),
|
||||
val error: String? = null,
|
||||
val busyGroup: String? = null,
|
||||
)
|
||||
|
||||
private val _uiState = MutableStateFlow(DuplicatesUiState())
|
||||
val uiState: StateFlow<DuplicatesUiState> = _uiState.asStateFlow()
|
||||
|
||||
init {
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun refresh() {
|
||||
viewModelScope.launch {
|
||||
_uiState.update { it.copy(isLoading = true, error = null) }
|
||||
runCatching { apiClient.listDuplicates() }
|
||||
.onSuccess { groups ->
|
||||
_uiState.update { it.copy(isLoading = false, groups = groups) }
|
||||
}
|
||||
.onFailure { e ->
|
||||
Timber.d("duplicates refresh failed: %s", e.message)
|
||||
_uiState.update {
|
||||
it.copy(isLoading = false, error = e.message ?: e.javaClass.simpleName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clearError() {
|
||||
_uiState.update { it.copy(error = null) }
|
||||
}
|
||||
|
||||
/** Trashe tous les membres sauf le plus récent (files[0], tri serveur). */
|
||||
fun keepNewest(group: DuplicateGroupDto) {
|
||||
if (group.files.size < 2) return
|
||||
viewModelScope.launch {
|
||||
_uiState.update { it.copy(busyGroup = group.contentHash) }
|
||||
runCatching {
|
||||
val evicted = group.files.drop(1).mapNotNull { fileRepository.getFile(it.id) }
|
||||
fileDeleter.deleteFiles(evicted, FileDeleter.DeleteMode.FULL)
|
||||
}.onSuccess { report ->
|
||||
if (report.failed > 0) {
|
||||
_uiState.update { it.copy(error = "${report.failed} fichier(s) non trashé(s)") }
|
||||
}
|
||||
refresh()
|
||||
}.onFailure { e ->
|
||||
Timber.w(e, "duplicates keep newest failed")
|
||||
_uiState.update { it.copy(error = e.message ?: e.javaClass.simpleName) }
|
||||
}
|
||||
_uiState.update { it.copy(busyGroup = null) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,19 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.Collections
|
||||
import androidx.compose.material.icons.filled.ContentCopy
|
||||
import androidx.compose.material.icons.filled.Edit
|
||||
import androidx.compose.material.icons.filled.Link
|
||||
import androidx.compose.material.icons.filled.RestartAlt
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.AssistChip
|
||||
import androidx.compose.material3.AssistChipDefaults
|
||||
@@ -40,22 +47,29 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.kazier.mobile.R
|
||||
import com.kazier.mobile.data.local.entity.FactOrigin
|
||||
import com.kazier.mobile.data.local.entity.FactType
|
||||
import com.kazier.mobile.data.local.entity.LinkOrigin
|
||||
import com.kazier.mobile.data.local.entity.LinkType
|
||||
import com.kazier.mobile.data.local.entity.ResourceFact
|
||||
import com.kazier.mobile.data.local.entity.ResourceLink
|
||||
|
||||
/**
|
||||
* Fiche « Ce qu'on a compris » (V3 S3) : faits génériques extraits du
|
||||
* document, avec correction en un tap.
|
||||
* Fiche « Ce qu'on a compris » (V3 S3) + « Voir aussi » (V3 S5) : faits
|
||||
* génériques extraits du document (correction en un tap) et graphe
|
||||
* documentaire (doublons, même émetteur, pages du même scan — invalidables).
|
||||
*
|
||||
* - Confiance < 0.5 → chip grisé + « (suggéré) » (humble par design).
|
||||
* - Crayon → dialogue d'édition (texte / nombre / date ISO) ; la correction
|
||||
* devient un fait `user` (badge « corrigé ») et part en outbox.
|
||||
* - « Rétablir auto » → efface les corrections (l'auto réapparaît).
|
||||
* - Arête infirmée (×) → confiance 0 conservée (ne revient pas) ;
|
||||
* ré-affichée grisée avec option de re-confirmation.
|
||||
*/
|
||||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
|
||||
@Composable
|
||||
@@ -66,10 +80,15 @@ fun FactsBottomSheet(
|
||||
viewModel: FactsViewModel = hiltViewModel(),
|
||||
) {
|
||||
val facts by viewModel.facts.collectAsStateWithLifecycle()
|
||||
val links by viewModel.links.collectAsStateWithLifecycle()
|
||||
val linkNames by viewModel.linkNames.collectAsStateWithLifecycle()
|
||||
val syncing by viewModel.syncing.collectAsStateWithLifecycle()
|
||||
val error by viewModel.error.collectAsStateWithLifecycle()
|
||||
|
||||
LaunchedEffect(resourceId) { viewModel.watch(resourceId) }
|
||||
LaunchedEffect(links, resourceId) {
|
||||
viewModel.resolveLinkNames(links.map { it.otherEnd(resourceId) }.toSet())
|
||||
}
|
||||
|
||||
var editing by rememberSaveable { mutableStateOf<String?>(null) }
|
||||
var showResetConfirm by rememberSaveable { mutableStateOf(false) }
|
||||
@@ -139,6 +158,24 @@ fun FactsBottomSheet(
|
||||
)
|
||||
}
|
||||
}
|
||||
if (links.isNotEmpty()) {
|
||||
Text(
|
||||
text = stringResource(R.string.links_title),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
)
|
||||
links.forEach { link ->
|
||||
val otherId = link.otherEnd(resourceId)
|
||||
LinkRow(
|
||||
link = link,
|
||||
displayName = linkNames[otherId] ?: otherId,
|
||||
onVerdict = { confirmed ->
|
||||
viewModel.setVerdict(otherId, link.linkType, confirmed)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(4.dp))
|
||||
}
|
||||
}
|
||||
@@ -248,6 +285,78 @@ private fun formatFactAmount(num: Double): String {
|
||||
return if (num == asLong.toDouble()) "$asLong €" else "$num €"
|
||||
}
|
||||
|
||||
/**
|
||||
* Ligne « Voir aussi » : icône par type, nom de l'autre bout, libellé du
|
||||
* lien, action de verdict (× = infirmer, ↺ = re-confirmer un lien infirmé).
|
||||
* Les liens infirmés (confiance 0, verdict user) restent affichés grisés —
|
||||
* ils ne reviendront pas tout seuls.
|
||||
*/
|
||||
@Composable
|
||||
private fun LinkRow(
|
||||
link: ResourceLink,
|
||||
displayName: String,
|
||||
onVerdict: (Boolean) -> Unit,
|
||||
) {
|
||||
val dismissed = link.confidence <= 0.0
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
Icon(
|
||||
imageVector = when (link.linkType) {
|
||||
LinkType.DUPLICATE_OF -> Icons.Filled.ContentCopy
|
||||
LinkType.SAME_SCAN -> Icons.Filled.Collections
|
||||
else -> Icons.Filled.Link
|
||||
},
|
||||
contentDescription = null,
|
||||
tint = if (dismissed) MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else MaterialTheme.colorScheme.primary,
|
||||
modifier = Modifier.size(24.dp),
|
||||
)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(
|
||||
text = displayName,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
fontWeight = FontWeight.Medium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
color = if (dismissed) MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
Text(
|
||||
text = stringResource(linkTypeLabel(link.linkType)),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
if (dismissed && link.createdBy == LinkOrigin.USER) {
|
||||
IconButton(onClick = { onVerdict(true) }) {
|
||||
Icon(
|
||||
Icons.Filled.RestartAlt,
|
||||
contentDescription = stringResource(R.string.links_reconfirm),
|
||||
)
|
||||
}
|
||||
} else if (!dismissed) {
|
||||
IconButton(onClick = { onVerdict(false) }) {
|
||||
Icon(
|
||||
Icons.Filled.Close,
|
||||
contentDescription = stringResource(R.string.links_dismiss),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun linkTypeLabel(type: String): Int = when (type) {
|
||||
LinkType.SAME_SCAN -> R.string.links_type_same_scan
|
||||
LinkType.DUPLICATE_OF -> R.string.links_type_duplicate
|
||||
LinkType.SAME_ISSUER -> R.string.links_type_same_issuer
|
||||
LinkType.SAME_REFERENCE -> R.string.links_type_same_reference
|
||||
else -> R.string.links_type_other
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun FactEditDialog(
|
||||
fact: ResourceFact,
|
||||
|
||||
@@ -3,8 +3,12 @@ package com.kazier.mobile.ui.facts
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.kazier.mobile.data.local.entity.ResourceFact
|
||||
import com.kazier.mobile.data.local.entity.ResourceLink
|
||||
import com.kazier.mobile.data.local.entity.displayFacts
|
||||
import com.kazier.mobile.data.repository.FactsRepository
|
||||
import com.kazier.mobile.data.repository.FileRepository
|
||||
import com.kazier.mobile.data.repository.FolderRepository
|
||||
import com.kazier.mobile.data.repository.LinksRepository
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -20,16 +24,21 @@ import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Fiche « Ce qu'on a compris » (V3 S3) : faits génériques d'un document.
|
||||
* Fiche « Ce qu'on a compris » (V3 S3) + « Voir aussi » (V3 S5) : faits
|
||||
* génériques et graphe documentaire d'un document.
|
||||
*
|
||||
* [watch] charge le miroir Room puis rafraîchit depuis le serveur
|
||||
* [watch] charge les miroirs Room puis rafraîchit depuis le serveur
|
||||
* (best-effort — offline = cache). [saveCorrection] remplace le fait du même
|
||||
* type dans le jeu `user` (optimiste + outbox `correct_facts`) ;
|
||||
* [resetToAuto] efface les corrections (l'auto réapparaît à l'affichage).
|
||||
* [resetToAuto] efface les corrections (l'auto réapparaît). [setVerdict]
|
||||
* confirme/infirme une arête (REST direct, en ligne uniquement).
|
||||
*/
|
||||
@HiltViewModel
|
||||
class FactsViewModel @Inject constructor(
|
||||
private val factsRepository: FactsRepository,
|
||||
private val linksRepository: LinksRepository,
|
||||
private val fileRepository: FileRepository,
|
||||
private val folderRepository: FolderRepository,
|
||||
) : ViewModel() {
|
||||
|
||||
private val resourceId = MutableStateFlow<String?>(null)
|
||||
@@ -41,12 +50,36 @@ class FactsViewModel @Inject constructor(
|
||||
}
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
val links: StateFlow<List<ResourceLink>> = resourceId
|
||||
.flatMapLatest { id: String? ->
|
||||
id?.let { linksRepository.observeRelations(it) } ?: flowOf(emptyList())
|
||||
}
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), emptyList())
|
||||
|
||||
private val _syncing = MutableStateFlow(false)
|
||||
val syncing: StateFlow<Boolean> = _syncing.asStateFlow()
|
||||
|
||||
private val _error = MutableStateFlow<String?>(null)
|
||||
val error: StateFlow<String?> = _error.asStateFlow()
|
||||
|
||||
/** Noms résolus des autres bouts (fichier puis dossier, sinon id brut). */
|
||||
private val _linkNames = MutableStateFlow<Map<String, String>>(emptyMap())
|
||||
val linkNames: StateFlow<Map<String, String>> = _linkNames.asStateFlow()
|
||||
|
||||
fun resolveLinkNames(ids: Set<String>) {
|
||||
val missing = ids.filter { it !in _linkNames.value }.toSet()
|
||||
if (missing.isEmpty()) return
|
||||
viewModelScope.launch {
|
||||
val resolved = missing.associateWith { id ->
|
||||
fileRepository.getFile(id)?.name
|
||||
?: folderRepository.getFolder(id)?.name
|
||||
?: id
|
||||
}
|
||||
_linkNames.value = _linkNames.value + resolved
|
||||
}
|
||||
}
|
||||
|
||||
fun watch(id: String) {
|
||||
if (resourceId.value == id) {
|
||||
refresh()
|
||||
@@ -66,6 +99,10 @@ class FactsViewModel @Inject constructor(
|
||||
Timber.d("facts sync failed for %s: %s", id, e.message)
|
||||
_error.value = e.message ?: e.javaClass.simpleName
|
||||
}
|
||||
runCatching { linksRepository.syncFromServer(id) }
|
||||
.onFailure { e ->
|
||||
Timber.d("links sync failed for %s: %s", id, e.message)
|
||||
}
|
||||
_syncing.value = false
|
||||
}
|
||||
}
|
||||
@@ -105,4 +142,20 @@ class FactsViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verdict sur une arête (confirmé → 1.0, infirmé → 0.0 conservé).
|
||||
* REST direct, en ligne uniquement : hors-ligne = erreur affichée,
|
||||
* la fiche garde l'état serveur.
|
||||
*/
|
||||
fun setVerdict(otherId: String, linkType: String, confirmed: Boolean) {
|
||||
val id = resourceId.value ?: return
|
||||
viewModelScope.launch {
|
||||
runCatching { linksRepository.setVerdict(id, otherId, linkType, confirmed) }
|
||||
.onFailure { e ->
|
||||
Timber.w(e, "link verdict failed for %s", id)
|
||||
_error.value = e.message ?: e.javaClass.simpleName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.kazier.mobile.ui.search.SearchScreen
|
||||
import com.kazier.mobile.ui.settings.SettingsScreen
|
||||
import com.kazier.mobile.ui.share.OpenLinkScreen
|
||||
import com.kazier.mobile.ui.trash.TrashScreen
|
||||
import com.kazier.mobile.ui.duplicates.DuplicatesScreen
|
||||
import com.kazier.mobile.ui.watchedfolders.WatchedFoldersScreen
|
||||
|
||||
object Routes {
|
||||
@@ -40,6 +41,7 @@ object Routes {
|
||||
const val REVIEW = "review"
|
||||
const val WATCHED_FOLDERS = "watched"
|
||||
const val TRASH = "trash"
|
||||
const val DUPLICATES = "duplicates"
|
||||
const val FOLDER_DETAIL = "folder/{folderResourceId}"
|
||||
const val ARG_FOLDER = "folderResourceId"
|
||||
const val DOCUMENT = "document/{documentResourceId}"
|
||||
@@ -149,6 +151,7 @@ fun NavGraph(
|
||||
onTabSelected = onTabSelected,
|
||||
onOpenWatchedFolders = onOpenWatchedFolders,
|
||||
onOpenTrash = { navController.navigate(Routes.TRASH) },
|
||||
onOpenDuplicates = { navController.navigate(Routes.DUPLICATES) },
|
||||
authViewModel = authViewModel,
|
||||
connectionStatusViewModel = connectionStatusViewModel,
|
||||
syncViewModel = syncViewModel,
|
||||
@@ -187,6 +190,11 @@ fun NavGraph(
|
||||
onBack = { navController.popBackStack() },
|
||||
)
|
||||
}
|
||||
composable(Routes.DUPLICATES) {
|
||||
DuplicatesScreen(
|
||||
onBack = { navController.popBackStack() },
|
||||
)
|
||||
}
|
||||
composable(
|
||||
route = Routes.FOLDER_DETAIL,
|
||||
arguments = listOf(
|
||||
|
||||
@@ -329,6 +329,9 @@ class ScanViewModel @Inject constructor(
|
||||
exists = true,
|
||||
// Déjà traité au scan : ne pas remonter dans la review.
|
||||
processed = true,
|
||||
// V3 S5 : pages d'un même export → arêtes
|
||||
// `same_scan` serveur (via le create outbox).
|
||||
scanSessionId = currentSession.resourceId,
|
||||
),
|
||||
folderResourceId = folderId,
|
||||
)
|
||||
@@ -427,6 +430,8 @@ class ScanViewModel @Inject constructor(
|
||||
lastModified = System.currentTimeMillis(),
|
||||
exists = true,
|
||||
processed = true,
|
||||
// V3 S5 : voir export page — même session de scan.
|
||||
scanSessionId = currentSession.resourceId,
|
||||
),
|
||||
folderResourceId = folderId,
|
||||
)
|
||||
|
||||
@@ -22,7 +22,9 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Clear
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilterChip
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -33,6 +35,7 @@ import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -54,6 +57,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.kazier.mobile.R
|
||||
import com.kazier.mobile.data.local.entity.CollectionEntity
|
||||
import com.kazier.mobile.data.local.entity.FileEntity
|
||||
import com.kazier.mobile.domain.FileCategory
|
||||
import com.kazier.mobile.features.connection.ConnectionStatusViewModel
|
||||
@@ -94,6 +98,7 @@ fun SearchScreen(
|
||||
) {
|
||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
val docTypes by viewModel.docTypes.collectAsStateWithLifecycle()
|
||||
val collections by viewModel.collections.collectAsStateWithLifecycle()
|
||||
val moveFolders by viewModel.moveFolders.collectAsStateWithLifecycle()
|
||||
val moveError by viewModel.moveError.collectAsStateWithLifecycle()
|
||||
val deleteError by viewModel.deleteError.collectAsStateWithLifecycle()
|
||||
@@ -200,6 +205,7 @@ fun SearchScreen(
|
||||
SearchContent(
|
||||
uiState = uiState,
|
||||
docTypes = docTypes,
|
||||
collections = collections,
|
||||
selection = selection,
|
||||
onQueryChange = viewModel::onQueryChange,
|
||||
onCategorySelect = viewModel::onCategorySelect,
|
||||
@@ -210,6 +216,9 @@ fun SearchScreen(
|
||||
onFromDateChange = viewModel::onFromDateChange,
|
||||
onToDateChange = viewModel::onToDateChange,
|
||||
onClearFacets = viewModel::clearFacets,
|
||||
onSaveCollection = viewModel::saveCollection,
|
||||
onApplyCollection = viewModel::applyCollection,
|
||||
onDeleteCollection = viewModel::deleteCollection,
|
||||
onOpenDocument = onOpenDocument,
|
||||
modifier = Modifier.padding(padding),
|
||||
)
|
||||
@@ -278,6 +287,7 @@ fun SearchScreen(
|
||||
private fun SearchContent(
|
||||
uiState: SearchUiState,
|
||||
docTypes: List<String>,
|
||||
collections: List<CollectionEntity>,
|
||||
selection: SelectionState,
|
||||
onQueryChange: (String) -> Unit,
|
||||
onCategorySelect: (String?) -> Unit,
|
||||
@@ -288,11 +298,15 @@ private fun SearchContent(
|
||||
onFromDateChange: (String) -> Unit,
|
||||
onToDateChange: (String) -> Unit,
|
||||
onClearFacets: () -> Unit,
|
||||
onSaveCollection: (String) -> Unit,
|
||||
onApplyCollection: (CollectionEntity) -> Unit,
|
||||
onDeleteCollection: (Long) -> Unit,
|
||||
onOpenDocument: (String) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val keyboardController = LocalSoftwareKeyboardController.current
|
||||
var filtersExpanded by rememberSaveable { mutableStateOf(false) }
|
||||
var showSaveDialog by rememberSaveable { mutableStateOf(false) }
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
@@ -364,6 +378,25 @@ private fun SearchContent(
|
||||
onClearFacets = onClearFacets,
|
||||
)
|
||||
|
||||
CollectionsRow(
|
||||
collections = collections,
|
||||
enabled = !selection.active,
|
||||
onApply = onApplyCollection,
|
||||
onDelete = onDeleteCollection,
|
||||
onSave = { showSaveDialog = true },
|
||||
)
|
||||
|
||||
if (showSaveDialog) {
|
||||
SaveCollectionDialog(
|
||||
initialName = uiState.query.trim().takeIf { it.isNotEmpty() }.orEmpty(),
|
||||
onDismiss = { showSaveDialog = false },
|
||||
onConfirm = { name ->
|
||||
showSaveDialog = false
|
||||
onSaveCollection(name)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
SearchResults(
|
||||
uiState = uiState,
|
||||
selection = selection,
|
||||
@@ -398,6 +431,100 @@ private fun CategoryChip(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Collections locales (S5) : chips des recherches sauvegardées + sauvegarde
|
||||
* de la recherche courante. Tap = rejoue (texte + catégorie + facettes),
|
||||
* appui long = supprime (avec confirmation).
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun CollectionsRow(
|
||||
collections: List<CollectionEntity>,
|
||||
enabled: Boolean,
|
||||
onApply: (CollectionEntity) -> Unit,
|
||||
onDelete: (Long) -> Unit,
|
||||
onSave: () -> Unit,
|
||||
) {
|
||||
var pendingDelete by rememberSaveable { mutableStateOf<CollectionEntity?>(null) }
|
||||
LazyRow(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
) {
|
||||
item(key = "save") {
|
||||
FilterChip(
|
||||
selected = false,
|
||||
onClick = onSave,
|
||||
enabled = enabled,
|
||||
label = { Text(stringResource(R.string.collection_save)) },
|
||||
leadingIcon = {
|
||||
Icon(Icons.Filled.Add, contentDescription = null)
|
||||
},
|
||||
)
|
||||
}
|
||||
items(collections, key = { it.id }) { collection ->
|
||||
FilterChip(
|
||||
selected = false,
|
||||
onClick = { onApply(collection) },
|
||||
enabled = enabled,
|
||||
label = { Text(collection.name) },
|
||||
modifier = Modifier.combinedClickable(
|
||||
onClick = { onApply(collection) },
|
||||
onLongClick = { pendingDelete = collection },
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
val toDelete = pendingDelete
|
||||
if (toDelete != null) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { pendingDelete = null },
|
||||
title = { Text(stringResource(R.string.collection_delete_title, toDelete.name)) },
|
||||
text = { Text(stringResource(R.string.collection_delete_message)) },
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
pendingDelete = null
|
||||
onDelete(toDelete.id)
|
||||
}) { Text(stringResource(R.string.collection_delete_confirm)) }
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { pendingDelete = null }) {
|
||||
Text(stringResource(R.string.delete_cancel))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SaveCollectionDialog(
|
||||
initialName: String,
|
||||
onDismiss: () -> Unit,
|
||||
onConfirm: (String) -> Unit,
|
||||
) {
|
||||
var name by rememberSaveable(initialName) { mutableStateOf(initialName) }
|
||||
AlertDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = { Text(stringResource(R.string.collection_save_title)) },
|
||||
text = {
|
||||
OutlinedTextField(
|
||||
value = name,
|
||||
onValueChange = { name = it },
|
||||
label = { Text(stringResource(R.string.collection_name)) },
|
||||
singleLine = true,
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = { onConfirm(name) },
|
||||
enabled = name.trim().isNotEmpty(),
|
||||
) { Text(stringResource(R.string.collection_save_confirm)) }
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onDismiss) { Text(stringResource(R.string.delete_cancel)) }
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Facettes V3 (S4) : émetteur, type suggéré (chips dynamiques), montants,
|
||||
* période ISO. Repliées par défaut (bouton avec compteur) ; saisies
|
||||
|
||||
@@ -6,6 +6,9 @@ import androidx.lifecycle.viewModelScope
|
||||
import com.kazier.mobile.R
|
||||
import com.kazier.mobile.data.local.entity.FileEntity
|
||||
import com.kazier.mobile.data.local.entity.FolderEntity
|
||||
import com.kazier.mobile.data.local.entity.CollectionEntity
|
||||
import com.kazier.mobile.data.repository.CollectionsRepository
|
||||
import com.kazier.mobile.data.repository.AppliedCollection
|
||||
import com.kazier.mobile.data.repository.FileRepository
|
||||
import com.kazier.mobile.data.repository.FolderRepository
|
||||
import com.kazier.mobile.data.repository.SearchFacets
|
||||
@@ -32,6 +35,7 @@ import javax.inject.Inject
|
||||
class SearchViewModel @Inject constructor(
|
||||
private val fileRepository: FileRepository,
|
||||
private val folderRepository: FolderRepository,
|
||||
private val collectionsRepository: CollectionsRepository,
|
||||
private val fileMover: FileMover,
|
||||
private val fileDeleter: FileDeleter,
|
||||
@ApplicationContext private val context: Context,
|
||||
@@ -223,6 +227,53 @@ class SearchViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/** Collections locales (requêtes sauvegardées, jamais syncées). */
|
||||
val collections: StateFlow<List<CollectionEntity>> =
|
||||
collectionsRepository.observeAll()
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(STOP_TIMEOUT_MS), emptyList())
|
||||
|
||||
/** Sauvegarde la recherche courante (texte + catégorie + facettes). */
|
||||
fun saveCollection(name: String) {
|
||||
viewModelScope.launch {
|
||||
runCatching {
|
||||
collectionsRepository.save(
|
||||
name = name,
|
||||
query = _searchQuery.value,
|
||||
category = _selectedCategory.value,
|
||||
facets = SearchFacets(
|
||||
issuer = _issuer.value.trim().takeIf { it.isNotEmpty() },
|
||||
docType = _docType.value,
|
||||
minAmount = _minAmount.value.toDoubleOrNull(),
|
||||
maxAmount = _maxAmount.value.toDoubleOrNull(),
|
||||
fromDate = _fromDate.value.trim().takeIf { it.matches(DATE_RE) },
|
||||
toDate = _toDate.value.trim().takeIf { it.matches(DATE_RE) },
|
||||
),
|
||||
)
|
||||
}.onFailure {
|
||||
_deleteError.value = context.getString(R.string.collection_save_error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteCollection(id: Long) {
|
||||
viewModelScope.launch {
|
||||
runCatching { collectionsRepository.delete(id) }
|
||||
}
|
||||
}
|
||||
|
||||
/** Rejoue une collection (texte + catégorie + facettes). */
|
||||
fun applyCollection(collection: CollectionEntity) {
|
||||
val applied: AppliedCollection = collectionsRepository.apply(collection)
|
||||
_searchQuery.value = applied.query
|
||||
_selectedCategory.value = applied.category
|
||||
_issuer.value = applied.facets.issuer.orEmpty()
|
||||
_docType.value = applied.facets.docType
|
||||
_minAmount.value = applied.facets.minAmount?.toString().orEmpty()
|
||||
_maxAmount.value = applied.facets.maxAmount?.toString().orEmpty()
|
||||
_fromDate.value = applied.facets.fromDate.orEmpty()
|
||||
_toDate.value = applied.facets.toDate.orEmpty()
|
||||
}
|
||||
|
||||
fun clearDeleteError() {
|
||||
_deleteError.value = null
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.CloudOff
|
||||
import androidx.compose.material.icons.filled.ContentCopy
|
||||
import androidx.compose.material.icons.filled.DarkMode
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Dns
|
||||
@@ -71,6 +72,7 @@ fun SettingsScreen(
|
||||
onTabSelected: (NavTab) -> Unit,
|
||||
onOpenWatchedFolders: () -> Unit,
|
||||
onOpenTrash: () -> Unit,
|
||||
onOpenDuplicates: () -> Unit,
|
||||
authViewModel: AuthViewModel,
|
||||
connectionStatusViewModel: ConnectionStatusViewModel,
|
||||
syncViewModel: SyncViewModel,
|
||||
@@ -163,6 +165,14 @@ fun SettingsScreen(
|
||||
onClick = onOpenTrash,
|
||||
)
|
||||
|
||||
HorizontalDivider()
|
||||
SettingsRow(
|
||||
icon = { Icon(Icons.Filled.ContentCopy, contentDescription = null) },
|
||||
title = stringResource(R.string.duplicates_title),
|
||||
subtitle = stringResource(R.string.duplicates_hint),
|
||||
onClick = onOpenDuplicates,
|
||||
)
|
||||
|
||||
HorizontalDivider()
|
||||
SettingsRow(
|
||||
icon = { Icon(Icons.Filled.Dns, contentDescription = null) },
|
||||
|
||||
@@ -418,6 +418,22 @@
|
||||
<string name="facts_type_reference">Reference</string>
|
||||
<string name="facts_type_doc_type">Document type</string>
|
||||
<string name="facts_type_other">Info</string>
|
||||
<!-- Graph V3 S5 -->
|
||||
<string name="links_title">See also</string>
|
||||
<string name="links_dismiss">This link is wrong</string>
|
||||
<string name="links_reconfirm">Re-confirm this link</string>
|
||||
<string name="links_type_same_scan">Same scan</string>
|
||||
<string name="links_type_duplicate">Duplicate</string>
|
||||
<string name="links_type_same_issuer">Same issuer</string>
|
||||
<string name="links_type_same_reference">Same reference</string>
|
||||
<string name="links_type_other">Linked</string>
|
||||
<!-- Duplicates V3 S5 B2 -->
|
||||
<string name="duplicates_title">Duplicates</string>
|
||||
<string name="duplicates_hint">Files with identical bytes — keep just one.</string>
|
||||
<string name="duplicates_empty">No duplicates detected</string>
|
||||
<string name="duplicates_keep_newest">Keep newest</string>
|
||||
<string name="duplicates_reclaimable">%1$s reclaimable</string>
|
||||
<string name="duplicates_group">%1$d identical files</string>
|
||||
<!-- Search facets V3 S4 -->
|
||||
<string name="search_filters">Filters</string>
|
||||
<string name="search_filters_count">Filters (%1$d)</string>
|
||||
@@ -428,4 +444,13 @@
|
||||
<string name="search_facet_max_amount">Max amount (€)</string>
|
||||
<string name="search_facet_from">From (YYYY-MM-DD)</string>
|
||||
<string name="search_facet_to">To (YYYY-MM-DD)</string>
|
||||
<!-- Collections V3 S5 -->
|
||||
<string name="collection_save">Save search</string>
|
||||
<string name="collection_save_title">Save as collection</string>
|
||||
<string name="collection_name">Name</string>
|
||||
<string name="collection_save_confirm">Save</string>
|
||||
<string name="collection_save_error">Cannot save</string>
|
||||
<string name="collection_delete_title">Delete “%1$s”?</string>
|
||||
<string name="collection_delete_message">The collection disappears from this device.</string>
|
||||
<string name="collection_delete_confirm">Delete</string>
|
||||
</resources>
|
||||
@@ -419,6 +419,22 @@
|
||||
<string name="facts_type_reference">Référence</string>
|
||||
<string name="facts_type_doc_type">Type de document</string>
|
||||
<string name="facts_type_other">Info</string>
|
||||
<!-- Graphe V3 S5 -->
|
||||
<string name="links_title">Voir aussi</string>
|
||||
<string name="links_dismiss">Ce lien est faux</string>
|
||||
<string name="links_reconfirm">Re-confirmer ce lien</string>
|
||||
<string name="links_type_same_scan">Même scan</string>
|
||||
<string name="links_type_duplicate">Doublon</string>
|
||||
<string name="links_type_same_issuer">Même émetteur</string>
|
||||
<string name="links_type_same_reference">Même référence</string>
|
||||
<string name="links_type_other">Lié</string>
|
||||
<!-- Doublons V3 S5 B2 -->
|
||||
<string name="duplicates_title">Doublons</string>
|
||||
<string name="duplicates_hint">Fichiers aux octets identiques — gardez-en un seul.</string>
|
||||
<string name="duplicates_empty">Aucun doublon détecté</string>
|
||||
<string name="duplicates_keep_newest">Garder le plus récent</string>
|
||||
<string name="duplicates_reclaimable">%1$s récupérables</string>
|
||||
<string name="duplicates_group">%1$d fichiers identiques</string>
|
||||
<!-- Recherche facettes V3 S4 -->
|
||||
<string name="search_filters">Filtres</string>
|
||||
<string name="search_filters_count">Filtres (%1$d)</string>
|
||||
@@ -429,4 +445,13 @@
|
||||
<string name="search_facet_max_amount">Montant max. (€)</string>
|
||||
<string name="search_facet_from">Du (AAAA-MM-JJ)</string>
|
||||
<string name="search_facet_to">Au (AAAA-MM-JJ)</string>
|
||||
<!-- Collections V3 S5 -->
|
||||
<string name="collection_save">Sauver la recherche</string>
|
||||
<string name="collection_save_title">Sauver comme collection</string>
|
||||
<string name="collection_name">Nom</string>
|
||||
<string name="collection_save_confirm">Sauver</string>
|
||||
<string name="collection_save_error">Sauvegarde impossible</string>
|
||||
<string name="collection_delete_title">Supprimer « %1$s » ?</string>
|
||||
<string name="collection_delete_message">La collection disparaît de cet appareil.</string>
|
||||
<string name="collection_delete_confirm">Supprimer</string>
|
||||
</resources>
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.kazier.mobile.data.local.migration
|
||||
|
||||
import android.content.Context
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import androidx.sqlite.db.SupportSQLiteOpenHelper
|
||||
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
/**
|
||||
* V3 relations + collections (S5) : la migration 21→22 crée `resource_links`
|
||||
* (miroir `GET /relations`) + `collections` (requêtes sauvegardées locales).
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
class Migration21To22Test {
|
||||
|
||||
@Test
|
||||
fun migration_cree_links_et_collections() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val helper = FrameworkSQLiteOpenHelperFactory().create(
|
||||
SupportSQLiteOpenHelper.Configuration.builder(context)
|
||||
.name(null)
|
||||
.callback(V21Callback())
|
||||
.build(),
|
||||
)
|
||||
val db = helper.writableDatabase
|
||||
|
||||
val migration = Migrations.ALL.first { it.startVersion == 21 && it.endVersion == 22 }
|
||||
migration.migrate(db)
|
||||
|
||||
val tables = mutableSetOf<String>()
|
||||
db.query("SELECT `name` FROM `sqlite_master` WHERE `type` = 'table'").use { cursor ->
|
||||
while (cursor.moveToNext()) tables += cursor.getString(0)
|
||||
}
|
||||
assertTrue("resource_links manquante", tables.contains("resource_links"))
|
||||
assertTrue("collections manquante", tables.contains("collections"))
|
||||
|
||||
val indexes = mutableSetOf<String>()
|
||||
db.query("SELECT `name` FROM `sqlite_master` WHERE `type` = 'index'").use { cursor ->
|
||||
while (cursor.moveToNext()) indexes += cursor.getString(0)
|
||||
}
|
||||
assertTrue(indexes.contains("index_resource_links_from_id_to_id_link_type"))
|
||||
assertTrue(indexes.contains("index_resource_links_to_id"))
|
||||
assertTrue(indexes.contains("index_collections_name"))
|
||||
|
||||
// Idempotence : re-passe sans erreur.
|
||||
migration.migrate(db)
|
||||
helper.close()
|
||||
}
|
||||
|
||||
/** Schéma v21 minimal (sans links ni collections). */
|
||||
private class V21Callback : SupportSQLiteOpenHelper.Callback(21) {
|
||||
override fun onCreate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL(
|
||||
"CREATE TABLE `files` (" +
|
||||
"`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
|
||||
"`resource_id` TEXT NOT NULL, " +
|
||||
"`name` TEXT NOT NULL, " +
|
||||
"`folder_resource_id` TEXT NOT NULL, " +
|
||||
"`size` INTEGER NOT NULL, " +
|
||||
"`added_at` INTEGER NOT NULL, " +
|
||||
"`updated_at` INTEGER NOT NULL)",
|
||||
)
|
||||
}
|
||||
|
||||
override fun onUpgrade(
|
||||
db: SupportSQLiteDatabase,
|
||||
oldVersion: Int,
|
||||
newVersion: Int,
|
||||
) = Unit
|
||||
}
|
||||
}
|
||||
@@ -343,6 +343,20 @@ class Auth401Test {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
@@ -217,6 +217,20 @@ class PaginationTest {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
@@ -150,6 +150,15 @@ class RemoteContentTest {
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<FileDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
|
||||
@@ -356,6 +356,15 @@ class SessionReloginTest {
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<FileDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
|
||||
@@ -189,6 +189,15 @@ class ShareManagementTest {
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<FileDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
|
||||
@@ -283,6 +283,15 @@ class BytesUploadTest {
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<FileDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.kazier.mobile.data.repository
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||
import com.kazier.mobile.data.local.AppDatabase
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
/**
|
||||
* Collections locales V3 (S5) : sauvegarde, relecture, application,
|
||||
* suppression. Pur local, jamais synchronisé.
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
class CollectionsRepositoryTest {
|
||||
|
||||
private lateinit var db: AppDatabase
|
||||
private lateinit var collectionsRepository: CollectionsRepository
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
db = Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java)
|
||||
.allowMainThreadQueries()
|
||||
.build()
|
||||
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
||||
collectionsRepository = CollectionsRepository(db.collectionDao(), moshi)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
db.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sauver_puis_rejouer() = runTest {
|
||||
val id = collectionsRepository.save(
|
||||
name = "Impôts 2026",
|
||||
query = "impot",
|
||||
category = null,
|
||||
facets = SearchFacets(docType = "impot", minAmount = 10.0, fromDate = "2026-01-01"),
|
||||
)
|
||||
|
||||
val all = collectionsRepository.observeAll().first()
|
||||
assertEquals(1, all.size)
|
||||
assertEquals("Impôts 2026", all[0].name)
|
||||
|
||||
val stored = collectionsRepository.get(id)!!
|
||||
val applied = collectionsRepository.apply(stored)
|
||||
assertEquals("impot", applied.query)
|
||||
assertEquals(null, applied.category)
|
||||
assertEquals("impot", applied.facets.docType)
|
||||
assertEquals(10.0, applied.facets.minAmount!!, 0.0)
|
||||
assertEquals("2026-01-01", applied.facets.fromDate)
|
||||
assertEquals(null, applied.facets.issuer)
|
||||
|
||||
collectionsRepository.delete(id)
|
||||
assertTrue(collectionsRepository.observeAll().first().isEmpty())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nom_vide_refuse() = runTest {
|
||||
var failed = false
|
||||
try {
|
||||
collectionsRepository.save(" ", "x", null, SearchFacets())
|
||||
} catch (e: IllegalArgumentException) {
|
||||
failed = true
|
||||
}
|
||||
assertTrue("nom vide doit être refusé", failed)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun json_corrompu_rejoue_vide() = runTest {
|
||||
db.collectionDao().insert(
|
||||
com.kazier.mobile.data.local.entity.CollectionEntity(
|
||||
name = "Cassée", query = "x", facetsJson = "{pas du json", createdAt = 1,
|
||||
),
|
||||
)
|
||||
val stored = collectionsRepository.observeAll().first().first()
|
||||
val applied = collectionsRepository.apply(stored)
|
||||
assertEquals("x", applied.query)
|
||||
assertTrue(applied.facets.isEmpty())
|
||||
}
|
||||
}
|
||||
+3
@@ -192,6 +192,9 @@ class FactsRepositoryTest {
|
||||
override suspend fun listVersions(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.VersionDto>>> = TODO()
|
||||
override suspend fun restoreVersion(fileId: String, versionNo: Int): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.FileDto>> = TODO()
|
||||
override suspend fun correctFacts(fileId: String, body: CorrectFactsDto): Response<ApiEnvelope<List<FactDto>>> = TODO()
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> = TODO()
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> = TODO()
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> = TODO()
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FileDto>>> = TODO()
|
||||
override suspend fun changePassword(body: com.kazier.mobile.data.remote.dto.ChangePasswordDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun getShareLink(token: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.ShareLinkDto>> = TODO()
|
||||
|
||||
+14
@@ -403,6 +403,20 @@ private class FolderMergeApiService : ApiService {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
package com.kazier.mobile.data.repository
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||
import com.kazier.mobile.data.local.AppDatabase
|
||||
import com.kazier.mobile.data.local.dao.LinksDao
|
||||
import com.kazier.mobile.data.local.entity.LinkOrigin
|
||||
import com.kazier.mobile.data.local.entity.LinkType
|
||||
import com.kazier.mobile.data.remote.ApiClient
|
||||
import com.kazier.mobile.data.remote.ApiService
|
||||
import com.kazier.mobile.data.remote.dto.ApiEnvelope
|
||||
import com.kazier.mobile.data.remote.dto.RelationDto
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import retrofit2.Response
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.moshi.MoshiConverterFactory
|
||||
|
||||
/**
|
||||
* Graphe V3 (S5) côté client : sync remplace-en-bloc, verdict optimiste +
|
||||
* REST direct (pas d'outbox — acte rare, en ligne uniquement).
|
||||
*/
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [34])
|
||||
class LinksRepositoryTest {
|
||||
|
||||
private lateinit var db: AppDatabase
|
||||
private lateinit var linksDao: LinksDao
|
||||
private lateinit var linksRepository: LinksRepository
|
||||
private lateinit var fakeApi: LinksFakeApiService
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
db = Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java)
|
||||
.allowMainThreadQueries()
|
||||
.build()
|
||||
linksDao = db.linksDao()
|
||||
|
||||
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
||||
fakeApi = LinksFakeApiService()
|
||||
val apiClient = ApiClient(fakeApi, moshi)
|
||||
linksRepository = LinksRepository(db, linksDao, apiClient)
|
||||
assertTrue(Retrofit.Builder().baseUrl("http://localhost:1/").build().baseUrl().toString().startsWith("http://localhost"))
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
db.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sync_remplace_en_bloc() = runTest {
|
||||
fakeApi.relations = listOf(
|
||||
RelationDto("1", "b", LinkType.SAME_SCAN, 1.0, "auto", "p2.png", "file", 10),
|
||||
)
|
||||
linksRepository.syncFromServer("a")
|
||||
|
||||
val rows = linksDao.getForResource("a")
|
||||
assertEquals(1, rows.size)
|
||||
assertEquals("b", rows[0].otherEnd("a"))
|
||||
|
||||
// Re-passe avec un jeu différent : remplacement, pas d'accumulation.
|
||||
fakeApi.relations = listOf(
|
||||
RelationDto("2", "c", LinkType.SAME_ISSUER, 0.7, "auto", "f.pdf", "file", 5),
|
||||
)
|
||||
linksRepository.syncFromServer("a")
|
||||
val rows2 = linksRepository.observeRelations("a").first()
|
||||
assertEquals(1, rows2.size)
|
||||
assertEquals("c", rows2[0].otherEnd("a"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verdict_optimiste_puis_convergence() = runTest {
|
||||
fakeApi.relations = listOf(
|
||||
RelationDto("1", "b", LinkType.SAME_ISSUER, 0.7, "auto", "f.pdf", "file", 5),
|
||||
)
|
||||
linksRepository.syncFromServer("a")
|
||||
|
||||
// Le serveur renvoie le jeu réconcilié après verdict.
|
||||
fakeApi.relations = listOf(
|
||||
RelationDto("1", "b", LinkType.SAME_ISSUER, 0.0, "user", "f.pdf", "file", 5),
|
||||
)
|
||||
linksRepository.setVerdict("a", "b", LinkType.SAME_ISSUER, confirmed = false)
|
||||
|
||||
assertEquals("b", fakeApi.lastVerdict?.otherId)
|
||||
assertEquals(LinkType.SAME_ISSUER, fakeApi.lastVerdict?.linkType)
|
||||
assertEquals(false, fakeApi.lastVerdict?.confirmed)
|
||||
|
||||
val rows = linksDao.getForResource("a")
|
||||
assertEquals(1, rows.size)
|
||||
assertEquals(0.0, rows[0].confidence, 0.0)
|
||||
assertEquals(LinkOrigin.USER, rows[0].createdBy)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verdict_hors_ligne_remonte_une_erreur() = runTest {
|
||||
fakeApi.failVerdict = true
|
||||
var failed = false
|
||||
try {
|
||||
linksRepository.setVerdict("a", "b", LinkType.SAME_SCAN, confirmed = false)
|
||||
} catch (e: Exception) {
|
||||
failed = true
|
||||
}
|
||||
assertTrue("verdict hors-ligne doit lever", failed)
|
||||
// L'optimiste local reste (réessai possible au retour réseau).
|
||||
assertEquals(1, linksDao.getForResource("a").size)
|
||||
}
|
||||
|
||||
data class VerdictCall(val otherId: String, val linkType: String, val confirmed: Boolean)
|
||||
|
||||
class LinksFakeApiService : ApiService {
|
||||
var relations: List<RelationDto> = emptyList()
|
||||
var lastVerdict: VerdictCall? = null
|
||||
var failVerdict: Boolean = false
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = relations))
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<RelationDto>>> {
|
||||
if (failVerdict) throw com.kazier.mobile.data.remote.ApiException("NETWORK_ERROR", "offline", 0)
|
||||
lastVerdict = VerdictCall(body.otherId, body.linkType, body.confirmed)
|
||||
return Response.success(ApiEnvelope(data = relations))
|
||||
}
|
||||
|
||||
override suspend fun listFolders(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FolderDto>>> = TODO()
|
||||
override suspend fun listFiles(folderId: String?, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FileDto>>> = TODO()
|
||||
override suspend fun registerDevice(body: com.kazier.mobile.data.remote.dto.DeviceRegistrationDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.DeviceRegistrationDto>> = TODO()
|
||||
override suspend fun login(body: com.kazier.mobile.data.remote.dto.LoginRequestDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.LoginResponseDto>> = TODO()
|
||||
override suspend fun syncOps(body: com.kazier.mobile.data.remote.dto.SyncOpsRequest): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.SyncOpsResult>> = TODO()
|
||||
override suspend fun resolveUser(username: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.ResolvedUserDto>> = TODO()
|
||||
override suspend fun syncPermissions(after: Long?): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.ResourcePermissionDto>>> = TODO()
|
||||
override suspend fun uploadFile(file: okhttp3.MultipartBody.Part, resourceId: okhttp3.RequestBody?, folderId: okhttp3.RequestBody?): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.FileDto>> = TODO()
|
||||
override suspend fun submitOcr(body: com.kazier.mobile.data.remote.dto.OcrSubmitDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.OcrJobDto>> = TODO()
|
||||
override suspend fun getOcrJob(jobId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.OcrJobDto>> = TODO()
|
||||
override suspend fun getFileOcr(fileId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.FileOcrDto>> = TODO()
|
||||
override suspend fun getFile(fileId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.FileDto>> = TODO()
|
||||
override suspend fun downloadContent(fileId: String): Response<okhttp3.ResponseBody> = TODO()
|
||||
override suspend fun deleteFile(fileId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun listTrash(page: Int?, pageSize: Int?): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.TrashDto>>> = TODO()
|
||||
override suspend fun restoreFile(fileId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun listVersions(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.VersionDto>>> = TODO()
|
||||
override suspend fun restoreVersion(fileId: String, versionNo: Int): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.FileDto>> = TODO()
|
||||
override suspend fun listFacts(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> = TODO()
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> = TODO()
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> = TODO()
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FileDto>>> = TODO()
|
||||
override suspend fun changePassword(body: com.kazier.mobile.data.remote.dto.ChangePasswordDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun getShareLink(token: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.ShareLinkDto>> = TODO()
|
||||
override suspend fun listShares(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.ShareGrantDto>>> = TODO()
|
||||
override suspend fun listLinks(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.ShareLinkDto>>> = TODO()
|
||||
override suspend fun listPlacements(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.PlacementDto>>> = TODO()
|
||||
override suspend fun createGroup(body: com.kazier.mobile.data.remote.dto.CreateGroupDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.GroupDto>> = TODO()
|
||||
override suspend fun listGroups(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.GroupDto>>> = TODO()
|
||||
override suspend fun addGroupMember(groupId: String, body: com.kazier.mobile.data.remote.dto.AddGroupMemberDto): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun listGroupMembers(groupId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.GroupMemberDto>>> = TODO()
|
||||
override suspend fun removeGroupMember(groupId: String, userId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun deleteGroup(groupId: String): Response<ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
}
|
||||
}
|
||||
+14
@@ -492,6 +492,20 @@ private class MoveProtectionApiService : ApiService {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
+14
@@ -404,6 +404,20 @@ private class OcrApiServiceFake : ApiService {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
+9
@@ -291,6 +291,15 @@ class OfflineDownloadTest {
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): Response<ApiEnvelope<List<FileDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
|
||||
+14
@@ -259,6 +259,20 @@ private class RefreshVsMoveApiService : ApiService {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
+14
@@ -513,6 +513,20 @@ private class FakeApiService : ApiService {
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listRelations(
|
||||
fileId: String,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun verdictRelation(
|
||||
fileId: String,
|
||||
body: com.kazier.mobile.data.remote.dto.RelationVerdictDto,
|
||||
): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
Response.success(ApiEnvelope(data = emptyList()))
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
@@ -161,6 +161,9 @@ class ReleaseLocalCopyTest {
|
||||
override suspend fun restoreVersion(fileId: String, versionNo: Int): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<com.kazier.mobile.data.remote.dto.FileDto>> = TODO()
|
||||
override suspend fun listFacts(fileId: String): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> = TODO()
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> = TODO()
|
||||
override suspend fun listRelations(fileId: String): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> = TODO()
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> = TODO()
|
||||
override suspend fun listDuplicates(): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> = TODO()
|
||||
override suspend fun searchFiles(query: String, page: Int?, pageSize: Int?): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FileDto>>> = TODO()
|
||||
override suspend fun changePassword(body: com.kazier.mobile.data.remote.dto.ChangePasswordDto): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<com.kazier.mobile.data.remote.dto.IdResultDto>> = TODO()
|
||||
override suspend fun getShareLink(token: String): retrofit2.Response<com.kazier.mobile.data.remote.dto.ApiEnvelope<com.kazier.mobile.data.remote.dto.ShareLinkDto>> = TODO()
|
||||
|
||||
+9
@@ -513,6 +513,15 @@ class OutboxSyncWorkerTest {
|
||||
override suspend fun correctFacts(fileId: String, body: com.kazier.mobile.data.remote.dto.CorrectFactsDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.FactDto>>> =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override suspend fun listRelations(fileId: String): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override suspend fun verdictRelation(fileId: String, body: com.kazier.mobile.data.remote.dto.RelationVerdictDto): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.RelationDto>>> =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override suspend fun listDuplicates(): Response<ApiEnvelope<List<com.kazier.mobile.data.remote.dto.DuplicateGroupDto>>> =
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
override suspend fun searchFiles(
|
||||
query: String,
|
||||
page: Int?,
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.kazier.mobile.data.remote.ApiClient
|
||||
import com.kazier.mobile.data.remote.ApiService
|
||||
import com.kazier.mobile.data.repository.FileRepository
|
||||
import com.kazier.mobile.data.repository.FolderRepository
|
||||
import com.kazier.mobile.data.repository.CollectionsRepository
|
||||
import com.kazier.mobile.data.repository.OutboxRepository
|
||||
import com.kazier.mobile.data.repository.SaveFileInput
|
||||
import com.kazier.mobile.domain.ActiveUserStore
|
||||
@@ -207,6 +208,7 @@ class SearchFieldTest {
|
||||
return SearchViewModel(
|
||||
fileRepo,
|
||||
folderRepository,
|
||||
CollectionsRepository(db.collectionDao(), moshi),
|
||||
FileMover(context, fileRepo, folderRepository),
|
||||
FileDeleter(context, fileRepo, outboxRepository, db, ThumbnailStore(context)),
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user