diff --git a/core/src/commonMain/kotlin/com/prof18/feedflow/core/model/FeedItem.kt b/core/src/commonMain/kotlin/com/prof18/feedflow/core/model/FeedItem.kt index 15a545ad..b6efe281 100644 --- a/core/src/commonMain/kotlin/com/prof18/feedflow/core/model/FeedItem.kt +++ b/core/src/commonMain/kotlin/com/prof18/feedflow/core/model/FeedItem.kt @@ -3,7 +3,7 @@ package com.prof18.feedflow.core.model data class FeedItem( val id: Int, val url: String, - val title: String, + val title: String?, val subtitle: String?, val content: String?, val imageUrl: String?, diff --git a/iosApp/Source/Home/Components/FeedItemView.swift b/iosApp/Source/Home/Components/FeedItemView.swift index 87a133b2..4712f4df 100644 --- a/iosApp/Source/Home/Components/FeedItemView.swift +++ b/iosApp/Source/Home/Components/FeedItemView.swift @@ -48,17 +48,27 @@ struct TitleAndSubtitleCell: View { let feedItem: FeedItem + func getPaddingTop(feedItem: FeedItem) -> CGFloat { + if feedItem.title != nil { + return Spacing.xxsmall + } else { + return CGFloat(0) + } + } + var body: some View { VStack(alignment: .leading) { - Text(feedItem.title) - .font(.system(size: 16)) - .bold() + if let title = feedItem.title { + Text(title) + .font(.system(size: 16)) + .bold() + } if let subtitle = feedItem.subtitle { Text(subtitle) .lineLimit(3) .font(.system(size: 14)) - .padding(.top, Spacing.xxsmall) + .padding(.top, getPaddingTop(feedItem: feedItem)) } } diff --git a/iosApp/Source/Home/HomeListIndexHolder.swift b/iosApp/Source/Home/HomeListIndexHolder.swift index 6fa97238..ccdf6424 100644 --- a/iosApp/Source/Home/HomeListIndexHolder.swift +++ b/iosApp/Source/Home/HomeListIndexHolder.swift @@ -30,7 +30,8 @@ class HomeListIndexHolder: ObservableObject { if !self.isLoading && index > lastReadIndex { lastReadIndex = index timer?.invalidate() - timer = Timer.scheduledTimer(withTimeInterval: 2, repeats: false) { [self] _ in + timer = Timer.scheduledTimer(withTimeInterval: 2, repeats: false) { [weak self] _ in + guard let self else { return } KotlinDependencies.shared.getHomeViewModel() .updateReadStatus(lastVisibleIndex: Int32(getLastReadIndex())) } diff --git a/shared/src/commonMain/kotlin/com/prof18/feedflow/domain/feed/retriever/FeedRetrieverRepositoryImpl.kt b/shared/src/commonMain/kotlin/com/prof18/feedflow/domain/feed/retriever/FeedRetrieverRepositoryImpl.kt index fa9d1127..4830741a 100644 --- a/shared/src/commonMain/kotlin/com/prof18/feedflow/domain/feed/retriever/FeedRetrieverRepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/com/prof18/feedflow/domain/feed/retriever/FeedRetrieverRepositoryImpl.kt @@ -257,7 +257,7 @@ internal class FeedRetrieverRepositoryImpl( rssItem.image } - if (title == null || url == null) { + if (url == null) { logger.d { "Skipping: ${rssItem.title}" } null } else { diff --git a/shared/src/commonMain/kotlin/com/prof18/feedflow/presentation/preview/PreviewItems.kt b/shared/src/commonMain/kotlin/com/prof18/feedflow/presentation/preview/PreviewItems.kt index 72c5a6ef..de645f20 100644 --- a/shared/src/commonMain/kotlin/com/prof18/feedflow/presentation/preview/PreviewItems.kt +++ b/shared/src/commonMain/kotlin/com/prof18/feedflow/presentation/preview/PreviewItems.kt @@ -46,28 +46,28 @@ val feedItemsForPreview = listOf( commentsUrl = null, ), FeedItem( - id = 2, - url = "https://www.androidpolice.com/google-pixel-7-pro-vs-pixel-6-pro/", - title = "TikTok turns up the volume on its music play with NewMusic search feature", - subtitle = "TikTok has upended how music is discovered, used and consumed these days; now, its long-term effort to build a business around that is getting a boost. The ByteDance-owned app today announced a search feature called “NewMusic,” which users can use to find new tracks, and artists can use to promote them.", + id = 3, + url = "https://9to5linux.com/obs-studio-29-0-1-is-out-to-fix-linux-crash-on-wayland-x11-capture-issue", + title = "OBS Studio 29.0.1 Is Out to Fix Linux Crash on Wayland, X11 Capture Issue", + subtitle = "
OBS Studio 29.0.1 open-source and free software for live streaming and screen recording is now available for download with several bug fixes.
The post OBS Studio 29.0.1 Is Out to Fix Linux Crash on Wayland, X11 Capture Issue appeared first on 9to5Linux - do not reproduce this article without permission. This RSS feed is intended for readers, not scrapers.
", content = null, - imageUrl = "https://techcrunch.com/wp-content/uploads/2023/05/89b4c85ae18bcc236df3198528a5a427.jpeg?resize=743,1536", + imageUrl = null, feedSource = FeedSource( - id = 2, - url = "", - title = "Tech Crunch", + id = 3, + url = "https://9to5linux.com", + title = "9to5 Linux", lastSyncTimestamp = null, ), - isRead = true, - pubDateMillis = 1675890077000, - dateString = "12/02 - 16:22", + isRead = false, + pubDateMillis = 0, + dateString = "12/12 - 9:22", commentsUrl = null, ), FeedItem( - id = 3, - url = "https://9to5linux.com/obs-studio-29-0-1-is-out-to-fix-linux-crash-on-wayland-x11-capture-issue", - title = "OBS Studio 29.0.1 Is Out to Fix Linux Crash on Wayland, X11 Capture Issue", - subtitle = "OBS Studio 29.0.1 open-source and free software for live streaming and screen recording is now available for download with several bug fixes.
The post OBS Studio 29.0.1 Is Out to Fix Linux Crash on Wayland, X11 Capture Issue appeared first on 9to5Linux - do not reproduce this article without permission. This RSS feed is intended for readers, not scrapers.
", + id = 4, + url = "https://androiddev.social/@marcogom/111096537433708200", + title = null, + subtitle = "Back to writing after a while!
In this article, I cover how I used the HiddenFromObjC and ObjCName annotations introduced with #Kotlin 1.8 to improve the architecture of MoneyFlow!
https://www.marcogomiero.com/posts/2023/objc-annotiations-better-kmp-api/
", content = null, imageUrl = null, feedSource = FeedSource( diff --git a/shared/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedItem.sq b/shared/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedItem.sq index b1cae661..a6444d45 100644 --- a/shared/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedItem.sq +++ b/shared/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedItem.sq @@ -4,7 +4,7 @@ import kotlin.Int; CREATE TABLE feed_item ( url_hash INTEGER AS Int NOT NULL PRIMARY KEY, url TEXT NOT NULL, - title TEXT NOT NULL, + title TEXT, subtitle TEXT, content TEXT, image_url TEXT, diff --git a/shared/src/commonMain/sqldelight/com/prof18/feedflow/migrations/2.sqm b/shared/src/commonMain/sqldelight/com/prof18/feedflow/migrations/2.sqm new file mode 100644 index 00000000..d435be16 --- /dev/null +++ b/shared/src/commonMain/sqldelight/com/prof18/feedflow/migrations/2.sqm @@ -0,0 +1,23 @@ +-- Make title nullable +CREATE TABLE feed_item_temp ( + url_hash INTEGER AS Int NOT NULL PRIMARY KEY, + url TEXT NOT NULL, + title TEXT, + subtitle TEXT, + content TEXT, + image_url TEXT, + feed_source_id INTEGER AS Int NOT NULL, + is_read INTEGER AS Boolean NOT NULL DEFAULT 0, + is_new INTEGER AS Boolean NOT NULL DEFAULT 1, + pub_date INTEGER, + comments_url TEXT +); + +-- Copy data from the original table to the temporary table +INSERT INTO feed_item_temp SELECT * FROM feed_item; + +-- Drop the original table +DROP TABLE feed_item; + +-- Rename the temporary table to the original table's name +ALTER TABLE feed_item_temp RENAME TO feed_item; \ No newline at end of file diff --git a/shared/src/commonMain/sqldelight/com/prof18/feedflow/schema/2.db b/shared/src/commonMain/sqldelight/com/prof18/feedflow/schema/2.db new file mode 100644 index 00000000..24138518 Binary files /dev/null and b/shared/src/commonMain/sqldelight/com/prof18/feedflow/schema/2.db differ diff --git a/shared/src/commonMain/sqldelight/com/prof18/feedflow/schema/3.db b/shared/src/commonMain/sqldelight/com/prof18/feedflow/schema/3.db new file mode 100644 index 00000000..a5746c9a Binary files /dev/null and b/shared/src/commonMain/sqldelight/com/prof18/feedflow/schema/3.db differ diff --git a/sharedUI/src/commonMain/kotlin/com/prof18/feedflow/ui/home/components/FeedListView.kt b/sharedUI/src/commonMain/kotlin/com/prof18/feedflow/ui/home/components/FeedListView.kt index 5f1b9cf0..9e4890c7 100644 --- a/sharedUI/src/commonMain/kotlin/com/prof18/feedflow/ui/home/components/FeedListView.kt +++ b/sharedUI/src/commonMain/kotlin/com/prof18/feedflow/ui/home/components/FeedListView.kt @@ -145,16 +145,22 @@ private fun TitleSubtitleAndImageRow( modifier = Modifier .weight(1f), ) { - Text( + feedItem.title?.let { title -> + Text( + text = title, + style = MaterialTheme.typography.titleSmall, + ) + } - text = feedItem.title, - style = MaterialTheme.typography.titleSmall, - ) + val paddingTop = when { + feedItem.title != null -> Spacing.small + else -> 0.dp + } feedItem.subtitle?.let { subtitle -> Text( modifier = Modifier - .padding(top = Spacing.small), + .padding(top = paddingTop), text = subtitle, maxLines = 3, overflow = TextOverflow.Ellipsis,