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

Fix refresh bug when adding Feedbin feed #355

Merged
merged 1 commit into from
Sep 12, 2024
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 @@ -105,7 +105,7 @@ fun ArticleRow(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 4.dp)
.padding(bottom = 2.dp)
) {
if (options.showFeedName) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ internal class FeedbinAccountDelegate(

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

AddFeedResult.Success(feed)
Expand All @@ -191,10 +191,7 @@ internal class FeedbinAccountDelegate(
return try {
refreshFeeds()
refreshTaggings()
refreshStarredEntries()
refreshUnreadEntries()
refreshAllArticles(since = since)
fetchMissingArticles()
refreshArticles(since = since)

Result.success(Unit)
} catch (exception: UnknownHostException) {
Expand All @@ -204,6 +201,13 @@ internal class FeedbinAccountDelegate(
}
}

private suspend fun refreshArticles(since: String = articleRecords.maxUpdatedAt()) {
refreshStarredEntries()
refreshUnreadEntries()
refreshAllArticles(since = since)
fetchMissingArticles()
}

private suspend fun refreshFeeds() {
val icons = fetchIcons()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,16 @@ class FeedbinAccountDelegateTest {
feedbin.createSubscription(body = CreateSubscriptionRequest(feed_url = url))
} returns successResponse

coEvery { feedbin.unreadEntries() }.returns(Response.success(entries.map { it.id }))
coEvery { feedbin.starredEntries() }.returns(Response.success(emptyList()))
coEvery {
feedbin.subscriptions()
} returns Response.success(emptyList())
feedbin.entries(
since = any(),
perPage = any(),
page = any(),
ids = any(),
)
}.returns(Response.success(emptyList()))

val result = delegate.addFeed(url = url) as AddFeedResult.Success
val feed = result.feed
Expand Down
Loading