Skip to content

Commit

Permalink
Fixes [BUG] Scope Control Issue in 'Ignored' Feature with Regex Pattern
Browse files Browse the repository at this point in the history
#511

Signed-off-by: IacobIonut01 <paulionut2003@gmail.com>
  • Loading branch information
IacobIonut01 committed Nov 3, 2024
1 parent 0a8bdcb commit 508cbcd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
applicationId = "com.dot.gallery"
minSdk = 30
targetSdk = 35
versionCode = 30124
versionCode = 30125
versionName = "3.0.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ data class IgnoredAlbum(
) : Parcelable {

private val hiddenInBoth get() = location == ALBUMS_AND_TIMELINE
private val hiddenInAlbums get() = location == ALBUMS_ONLY || hiddenInBoth
private val hiddenInTimeline get() = location == TIMELINE_ONLY || hiddenInBoth
val hiddenInAlbums get() = location == ALBUMS_ONLY || hiddenInBoth
val hiddenInTimeline get() = location == TIMELINE_ONLY || hiddenInBoth

fun matchesMedia(media: Media): Boolean =
matches(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.dot.gallery.R
import com.dot.gallery.feature_node.domain.model.AlbumState
import com.dot.gallery.core.Resource
import com.dot.gallery.core.Settings
import com.dot.gallery.core.presentation.components.FilterKind
import com.dot.gallery.core.presentation.components.FilterOption
import com.dot.gallery.feature_node.domain.model.Album
import com.dot.gallery.feature_node.domain.model.AlbumState
import com.dot.gallery.feature_node.domain.model.IgnoredAlbum
import com.dot.gallery.feature_node.domain.model.PinnedAlbum
import com.dot.gallery.feature_node.domain.model.TimelineSettings
Expand Down Expand Up @@ -134,7 +134,7 @@ class AlbumsViewModel @Inject constructor(

private fun List<Album>.removeBlacklisted(blacklistedAlbums: List<IgnoredAlbum>): List<Album> =
toMutableList().apply {
removeAll { album -> blacklistedAlbums.any { it.matchesAlbum(album) } }
removeAll { album -> blacklistedAlbums.any { it.matchesAlbum(album) && it.hiddenInAlbums } }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ open class MediaViewModel @Inject constructor(
updateDatabase()
mapMediaToItem(
data = (result.data ?: emptyList()).toMutableList().apply {
removeAll { media -> blacklistedAlbums.any { it.matchesMedia(media) } }
removeAll { media -> blacklistedAlbums.any { it.matchesMedia(media) && it.hiddenInTimeline } }
},
error = result.message ?: "",
albumId = albumId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ open class PickerViewModel @Inject constructor(
repository.mediaFlowWithType(value, allowedMedia)
) { blacklisted, mediaResult ->
val data = (mediaResult.data ?: emptyList()).toMutableList().apply {
removeAll { media -> blacklisted.any { it.matchesMedia(media) } }
removeAll { media -> blacklisted.any { it.matchesMedia(media) && it.hiddenInTimeline } }
}
val error = if (mediaResult is Resource.Error) mediaResult.message
?: "An error occurred" else ""
Expand All @@ -58,7 +58,7 @@ open class PickerViewModel @Inject constructor(
repository.mediaFlowWithType(albumId, allowedMedia)
) { blacklisted, mediaResult ->
val data = (mediaResult.data ?: emptyList()).toMutableList().apply {
removeAll { media -> blacklisted.any { it.matchesMedia(media) } }
removeAll { media -> blacklisted.any { it.matchesMedia(media) && it.hiddenInTimeline } }
}
val error = if (mediaResult is Resource.Error) mediaResult.message
?: "An error occurred" else ""
Expand All @@ -80,7 +80,7 @@ open class PickerViewModel @Inject constructor(
repository.getAlbumsWithType(allowedMedia)
) { blacklisted, albumsResult ->
val data = (albumsResult.data ?: emptyList()).toMutableList().apply {
removeAll { album -> blacklisted.any { it.matchesAlbum(album) } }
removeAll { album -> blacklisted.any { it.matchesAlbum(album) && it.hiddenInAlbums } }
}
val error = if (albumsResult is Resource.Error) albumsResult.message
?: "An error occurred" else ""
Expand Down

0 comments on commit 508cbcd

Please sign in to comment.