Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deduplicate feeds in notification settings #836

Merged
merged 2 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ArticleScreenViewModel(

val savedSearches = account.savedSearches

val allFeeds = account.allFeeds
val allFeeds = account.taggedFeeds

val allFolders = account.folders

Expand Down
8 changes: 6 additions & 2 deletions capy/src/main/java/com/jocmp/capy/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ data class Account(

private val articleContent = ArticleContent(httpClient = localHttpClient)

val taggedFeeds = feedRecords.taggedFeeds().map {
it.sortedByTitle()
}

val allFeeds = feedRecords.feeds().map {
it.sortedByTitle()
}
Expand All @@ -76,12 +80,12 @@ data class Account(
it.sortedByName()
}

val feeds: Flow<List<Feed>> = allFeeds.map { all ->
val feeds: Flow<List<Feed>> = taggedFeeds.map { all ->
all.filter { it.folderName.isBlank() }
.sortedByTitle()
}

val folders: Flow<List<Folder>> = allFeeds.map { ungrouped ->
val folders: Flow<List<Folder>> = taggedFeeds.map { ungrouped ->
ungrouped
.filter { it.folderName.isNotBlank() }
.groupBy { it.folderName }
Expand Down
9 changes: 8 additions & 1 deletion capy/src/main/java/com/jocmp/capy/persistence/FeedRecords.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,20 @@ internal class FeedRecords(private val database: Database) {
return Folder(title = title, feeds = feeds)
}

internal fun feeds(): Flow<List<Feed>> {
internal fun taggedFeeds(): Flow<List<Feed>> {
return database.feedsQueries
.tagged(mapper = ::feedMapper)
.asFlow()
.mapToList(Dispatchers.IO)
}

internal fun feeds(): Flow<List<Feed>> {
return database.feedsQueries
.all(mapper = ::feedMapper)
.asFlow()
.mapToList(Dispatchers.IO)
}

internal fun removeFeed(feedID: String) {
database.feedsQueries.delete(listOf(feedID))
}
Expand Down