Skip to content

Commit

Permalink
Remove feed source image migration
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Jun 2, 2024
1 parent dab022d commit b60c57a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class DatabaseHelper(
),
)

fun getDatabaseVersion(): Long =
FeedFlowDB.Schema.version

suspend fun getFeedSources(): List<FeedSource> = withContext(backgroundDispatcher) {
dbRef.feedSourceQueries
.selectFeedUrls()
Expand Down Expand Up @@ -210,14 +207,6 @@ class DatabaseHelper(
}
}

suspend fun updateFeedSourceLogo(feedSource: FeedSource) =
withContext(backgroundDispatcher) {
dbRef.feedSourceQueries.updateLogoUrl(
logoUrl = feedSource.logoUrl,
urlHash = feedSource.id,
)
}

fun deleteAllFeeds() =
dbRef.transaction {
dbRef.feedItemQueries.deleteAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ deleteAllLastSync:
UPDATE feed_source
SET last_sync_timestamp = NULL;

updateLogoUrl:
UPDATE feed_source
SET logo_url = :logoUrl
WHERE url_hash = :urlHash;

resetCategory:
UPDATE feed_source
SET category_id = NULL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ internal class SettingsHelper(
fun saveFavouriteBrowserId(browserId: String) =
settings.set(SettingsFields.FAVOURITE_BROWSER_ID.name, browserId)

fun isFeedSourceImageMigrationDone(): Boolean =
settings.getBoolean(SettingsFields.FEED_SOURCE_IMAGE_MIGRATION.name, false)

fun setFeedSourceImageMigrationDone() =
settings.set(SettingsFields.FEED_SOURCE_IMAGE_MIGRATION.name, true)

fun getMarkFeedAsReadWhenScrolling(): Boolean =
settings.getBoolean(SettingsFields.MARK_FEED_AS_READ_WHEN_SCROLLING.name, true)

Expand All @@ -39,7 +33,6 @@ internal class SettingsHelper(

internal enum class SettingsFields {
FAVOURITE_BROWSER_ID,
FEED_SOURCE_IMAGE_MIGRATION,
MARK_FEED_AS_READ_WHEN_SCROLLING,
SHOW_READ_ARTICLES_TIMELINE,
USE_READER_MODE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,8 @@ internal class FeedRetrieverRepository(
parseFeeds(
feedSourceUrls = feedSourceUrls,
forceRefresh = forceRefresh,
isFeedSourceMigrationRequired = isFirstLaunch && isSourceImageMigrationRequired(),
)

if (isFirstLaunch && isSourceImageMigrationRequired()) {
settingsHelper.setFeedSourceImageMigrationDone()
}

getFeeds()
}
}
Expand Down Expand Up @@ -330,7 +325,6 @@ internal class FeedRetrieverRepository(
private suspend fun parseFeeds(
feedSourceUrls: List<FeedSource>,
forceRefresh: Boolean,
isFeedSourceMigrationRequired: Boolean,
) =
feedSourceUrls
.mapNotNull { feedSource ->
Expand Down Expand Up @@ -359,16 +353,6 @@ internal class FeedRetrieverRepository(
feedSource = feedSource,
)

if (isFeedSourceMigrationRequired) {
val logoUrl = feedSourceLogoRetriever.getFeedSourceLogoUrl(rssChannel)

logger.d { "Setting source logo url: $logoUrl" }

databaseHelper.updateFeedSourceLogo(
feedSource = feedSource.copy(logoUrl = logoUrl),
)
}

databaseHelper.insertFeedItems(items, dateFormatter.currentTimeMillis())
} catch (e: Throwable) {
logger.e(e) { "Something went wrong, skipping: ${feedSource.url}}" }
Expand Down Expand Up @@ -417,13 +401,6 @@ internal class FeedRetrieverRepository(
}
}

@Suppress("MagicNumber")
private fun isSourceImageMigrationRequired(): Boolean {
val databaseVersion = databaseHelper.getDatabaseVersion()
val isMigrationDone = settingsHelper.isFeedSourceImageMigrationDone()
return !isMigrationDone && databaseVersion >= 4.0
}

private fun String.buildUrl(originalUrl: String) =
if (originalUrl.endsWith("/")) {
"$originalUrl$this"
Expand Down

0 comments on commit b60c57a

Please sign in to comment.