Skip to content

Commit

Permalink
Always save articles on feed add
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp committed Sep 10, 2024
1 parent a9bbe3f commit eda7e09
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ fun ArticleLayout(
openNextList()

showSnackbar(addFeedSuccessMessage)

refreshFeeds()
}
}

Expand Down
1 change: 0 additions & 1 deletion capy/src/main/java/com/jocmp/capy/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.jocmp.feedbinclient.Feedbin
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import java.io.File
import java.io.InputStream
import java.net.URI
import java.time.ZonedDateTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.jocmp.feedbinclient.Subscription
import com.jocmp.feedbinclient.UnreadEntriesRequest
import com.jocmp.feedbinclient.UpdateSubscriptionRequest
import com.jocmp.feedbinclient.pagingInfo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
Expand Down Expand Up @@ -162,6 +163,10 @@ internal class FeedbinAccountDelegate(
val feed = feedRecords.findBy(subscription.feed_id.toString())

if (feed != null) {
coroutineScope {
launch(Dispatchers.IO) { refreshFeeds() }
}

AddFeedResult.Success(feed)
} else {
AddFeedResult.Failure(AddFeedError.SaveFailure())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.jocmp.capy.persistence.TaggingRecords
import com.jocmp.feedfinder.DefaultFeedFinder
import com.jocmp.feedfinder.FeedFinder
import com.prof18.rssparser.model.RssItem
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -62,6 +63,7 @@ class LocalAccountDelegate(

return if (feed != null) {
upsertFolders(feed, folderTitles)
saveArticles(resultFeed.items, cutoffDate = null, feed = feed)

AddFeedResult.Success(feed)
} else {
Expand Down
3 changes: 3 additions & 0 deletions feedfinder/src/main/java/com/jocmp/feedfinder/parser/Feed.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jocmp.feedfinder.parser

import com.prof18.rssparser.model.RssItem
import java.net.URL

interface Feed {
Expand All @@ -12,4 +13,6 @@ interface Feed {
val siteURL: URL?

val faviconURL: URL?

val items: List<RssItem>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.jocmp.feedfinder.parser
import com.jocmp.feedfinder.optionalURL
import com.prof18.rssparser.RssParser
import com.prof18.rssparser.model.RssChannel
import com.prof18.rssparser.model.RssItem
import java.net.URL

internal class XMLFeed(
Expand All @@ -24,6 +25,9 @@ internal class XMLFeed(
override val faviconURL: URL?
get() = channel?.image?.url?.let { optionalURL(it) }

override val items: List<RssItem>
get() = channel?.items.orEmpty()

private fun hasEntries(): Boolean {
return channel != null &&
channel.items.isNotEmpty()
Expand Down

0 comments on commit eda7e09

Please sign in to comment.