Skip to content

Commit

Permalink
[Local] Use guid before URL for database ID (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
jocmp authored Jan 28, 2025
1 parent 7131aca commit b51e2f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
8 changes: 0 additions & 8 deletions app/src/main/java/com/capyreader/app/ui/articles/FeedList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -48,14 +46,8 @@ fun FeedList(
onNavigateToSettings: () -> Unit,
) {
val scrollState = rememberScrollState()
val (isMenuExpanded, setMenuExpanded) = remember { mutableStateOf(false) }
val articleStatus = filter.status

val onStatusChange = { status: ArticleStatus ->
setMenuExpanded(false)
onSelectStatus(status)
}

Column(
Modifier.fillMaxSize()
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import java.net.URL
internal class ParsedItem(private val item: RssItem, private val siteURL: String?) {
val url: String? = articleURL()

val id: String? = url ?: item.guid
val id: String? = item.guid ?: url

val contentHTML: String?
get() {
Expand Down
13 changes: 13 additions & 0 deletions capy/src/test/java/com/jocmp/capy/accounts/local/ParsedItemTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ class ParsedItemTest {
assertEquals(expected = url, actual = parsedItem.id)
}

@Test
fun id_prefersID() {
val id = "my-guid-here"
val url = "https://example.com/article"
val item = RssItem.Builder()
.guid(id)
.link(url)
.build()
val parsedItem = ParsedItem(item, siteURL = "")

assertEquals(expected = id, actual = parsedItem.id)
}

@Test
fun id_whenUrlIsMissing() {
val id = "https://example.com/article"
Expand Down

0 comments on commit b51e2f9

Please sign in to comment.