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

Allow feeds without article title #28

Merged
merged 1 commit into from
Sep 22, 2023
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 @@ -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?,
Expand Down
18 changes: 14 additions & 4 deletions iosApp/Source/Home/Components/FeedItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
3 changes: 2 additions & 1 deletion iosApp/Source/Home/HomeListIndexHolder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ internal class FeedRetrieverRepositoryImpl(
rssItem.image
}

if (title == null || url == null) {
if (url == null) {
logger.d { "Skipping: ${rssItem.title}" }
null
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<p>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.</p> <p>The post <a rel=\"nofollow\" href=\"https://9to5linux.com/obs-studio-29-0-1-is-out-to-fix-linux-crash-on-wayland-x11-capture-issue\">OBS Studio 29.0.1 Is Out to Fix Linux Crash on Wayland, X11 Capture Issue</a> appeared first on <a rel=\"nofollow\" href=\"https://9to5linux.com\">9to5Linux</a> - do not reproduce this article without permission. This RSS feed is intended for readers, not scrapers.</p>",
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 = "<p>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.</p> <p>The post <a rel=\"nofollow\" href=\"https://9to5linux.com/obs-studio-29-0-1-is-out-to-fix-linux-crash-on-wayland-x11-capture-issue\">OBS Studio 29.0.1 Is Out to Fix Linux Crash on Wayland, X11 Capture Issue</a> appeared first on <a rel=\"nofollow\" href=\"https://9to5linux.com\">9to5Linux</a> - do not reproduce this article without permission. This RSS feed is intended for readers, not scrapers.</p>",
id = 4,
url = "https://androiddev.social/@marcogom/111096537433708200",
title = null,
subtitle = "<p>Back to writing after a while!</p><p>In this article, I cover how I used the HiddenFromObjC and ObjCName annotations introduced with <a href=\"https://androiddev.social/tags/Kotlin\" class=\"mention hashtag\" rel=\"tag\">#<span>Kotlin</span></a> 1.8 to improve the architecture of MoneyFlow!</p><p><a href=\"https://www.marcogomiero.com/posts/2023/objc-annotiations-better-kmp-api/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">marcogomiero.com/posts/2023/ob</span><span class=\"invisible\">jc-annotiations-better-kmp-api/</span></a></p>",
content = null,
imageUrl = null,
feedSource = FeedSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down