@@ -65,23 +65,24 @@ class ApiClient(private val config: ApiClientConfig) {
6565 return executeAPICall(200 ) {
6666 val response = service.listAssetsFromAlbum(albumId)
6767 val album = response.body()
68- val assets = album!! .assets.map { Asset (it.id, it.type, it.deviceAssetId, it.exifInfo, it.fileModifiedAt, album.albumName, it.people) }
68+ val assets = album!! .assets.filter(excludeByTag())
69+ .map { Asset (it.id, it.type, it.deviceAssetId, it.exifInfo, it.fileModifiedAt, album.albumName, it.people, it.tags) }
6970 val updatedAlbum = AlbumDetails (album.albumName, album.description, album.id, album.albumThumbnailAssetId, assets)
7071 Response .success(updatedAlbum)
7172 }
7273 }
7374
7475 suspend fun recentAssets (page : Int , pageCount : Int , includeVideos : Boolean ): Either <String , List <Asset >> {
7576 val now = LocalDateTime .now()
76- return apiClient !! . listAssets(page, pageCount, true , " desc" ,
77+ return listAssets(page, pageCount, true , " desc" ,
7778 includeVideos = includeVideos, fromDate = now.minusMonths(PreferenceManager .recentAssetsMonthsBack().toLong()), endDate = now)
7879 .map { it.shuffled() }
7980 }
8081
8182 suspend fun similarAssets (page : Int , pageCount : Int , includeVideos : Boolean ): Either <String , List <Asset >> {
8283 val now = LocalDateTime .now()
8384 val map: List <Either <String , List <Asset >>> = (0 until PreferenceManager .similarAssetsYearsBack()).toList().map {
84- apiClient !! . listAssets(page,
85+ listAssets(page,
8586 pageCount,
8687 true ,
8788 " desc" ,
@@ -110,11 +111,15 @@ class ApiClient(private val config: ApiClientConfig) {
110111 personIds,
111112 endDate?.format(dateTimeFormatter),
112113 fromDate?.format(dateTimeFormatter))
113- return if (random) {
114+ return ( if (random) {
114115 executeAPICall(200 ) { service.randomAssets(searchRequest) }
115116 } else {
116117 executeAPICall(200 ) { service.listAssets(searchRequest) }.map { res -> res.assets.items }
117- }
118+ }).map { it.filter(excludeByTag()) }
119+ }
120+
121+ private fun excludeByTag () = { asset: Asset ->
122+ asset.tags?.none { t -> t.name == " exclude_immich_tv" } ? : true
118123 }
119124
120125 suspend fun listBuckets (albumId : String , order : PhotosOrder ): Either <String , List <Bucket >> {
@@ -145,13 +150,13 @@ class ApiClient(private val config: ApiClientConfig) {
145150 return parent
146151 }
147152
148- private fun createFolders (paths : List <String >, currentParent : Folder ): Folder {
149- if (paths.isEmpty()){
153+ private fun createFolders (paths : List <String >, currentParent : Folder ): Folder {
154+ if (paths.isEmpty()) {
150155 return currentParent
151156 }
152157 val createdChild = Folder (paths.first(), mutableListOf (), currentParent)
153158 val alreadyOwnedChild = currentParent.hasPath(paths.first())
154- if (alreadyOwnedChild != null ){
159+ if (alreadyOwnedChild != null ) {
155160 return createFolders(paths.drop(1 ), alreadyOwnedChild)
156161 }
157162 currentParent.children.add(createdChild)
@@ -161,7 +166,7 @@ class ApiClient(private val config: ApiClientConfig) {
161166 suspend fun listAssetsForFolder (folder : String ): Either <String , List <Asset >> {
162167 return executeAPICall(200 ) {
163168 service.getAssetsForPath(folder)
164- }
169+ }.map { it.filter(excludeByTag()) }
165170 }
166171}
167172
0 commit comments