feat(fileDto, folderDto): add is_favorite + is_shared

- provide is_shared and is_favorite information in DTO, information propagated as badge/buttons per items
      regarding performances I try to be minimalis on SQL to prevent any perf regression

    - remove old set of sharedids and favoriteids (was not functionnal anymore)
    - fix date picker (no past selection) in grant
    - fix contextmenu close on /files section
This commit is contained in:
Edouard Vanbelle
2026-07-22 00:36:14 +02:00
parent b7d5d41c90
commit d9987782c4
50 changed files with 1140 additions and 287 deletions
@@ -50,6 +50,26 @@ impl FavoritesService {
) -> Result<HashSet<String>> {
self.repo.batch_check_favorites(user_id, items).await
}
/// Shared enrichment helper — computes `is_favorite` + `is_shared`
/// for a single resource so single-item handlers (get / rename /
/// move / upload / delta upload / photos / bulk get by ids) can
/// populate the two wire-contract flags on FileDto / FolderDto
/// before Json emission. Delegates straight to the repository
/// port; kept on `FavoritesService` because the port already
/// lives on that service and callers already hold it in DI.
///
/// `resource_type` MUST be `"file"` or `"folder"`.
pub async fn caller_flags(
&self,
caller_id: Uuid,
resource_type: &str,
resource_id: Uuid,
) -> Result<(bool, bool)> {
self.repo
.caller_flags(caller_id, resource_type, resource_id)
.await
}
}
impl FavoritesUseCase for FavoritesService {
+9 -1
View File
@@ -828,7 +828,15 @@ impl FolderService {
// 2. Fetch limit+1 rows so we can detect has_next
let mut rows = self
.folder_storage
.list_resources_paged(pid, limit + 1, cursor.as_ref(), order_by, kinds, reverse)
.list_resources_paged(
pid,
caller_id,
limit + 1,
cursor.as_ref(),
order_by,
kinds,
reverse,
)
.await?;
// 3. Detect has_next, build encoded next cursor
@@ -824,6 +824,7 @@ impl TrashService {
.trash_repository
.list_resources_paged(
&drive_ids,
user_id,
limit + 1,
cursor.as_ref(),
order_by,
@@ -890,6 +891,8 @@ fn row_to_item_dto(row: TrashResourceRow) -> TrashResourceItemDto {
category: intern_display("Folder"),
created_by: row.created_by,
updated_by: row.updated_by,
is_favorite: row.is_favorite,
is_shared: row.is_shared,
};
TrashResourceItemDto {
resource_type: ResourceTypeDto::Folder,
@@ -933,6 +936,8 @@ fn row_to_item_dto(row: TrashResourceRow) -> TrashResourceItemDto {
etag,
created_by: row.created_by,
updated_by: row.updated_by,
is_favorite: row.is_favorite,
is_shared: row.is_shared,
};
TrashResourceItemDto {
resource_type: ResourceTypeDto::File,