From b60c57a4efbe33b259004c9b408ee69dac289221 Mon Sep 17 00:00:00 2001 From: Marco Gomiero Date: Sun, 2 Jun 2024 09:14:07 +0200 Subject: [PATCH] Remove feed source image migration --- .../feedflow/database/DatabaseHelper.kt | 11 --------- .../com/prof18/feedflow/db/FeedSource.sq | 5 ---- .../feedflow/shared/data/SettingsHelper.kt | 7 ------ .../feed/retriever/FeedRetrieverRepository.kt | 23 ------------------- 4 files changed, 46 deletions(-) diff --git a/database/src/commonMain/kotlin/com/prof18/feedflow/database/DatabaseHelper.kt b/database/src/commonMain/kotlin/com/prof18/feedflow/database/DatabaseHelper.kt index b423a5f1..bc053366 100644 --- a/database/src/commonMain/kotlin/com/prof18/feedflow/database/DatabaseHelper.kt +++ b/database/src/commonMain/kotlin/com/prof18/feedflow/database/DatabaseHelper.kt @@ -45,9 +45,6 @@ class DatabaseHelper( ), ) - fun getDatabaseVersion(): Long = - FeedFlowDB.Schema.version - suspend fun getFeedSources(): List = withContext(backgroundDispatcher) { dbRef.feedSourceQueries .selectFeedUrls() @@ -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() diff --git a/database/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedSource.sq b/database/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedSource.sq index 2cb2d751..04df37d5 100644 --- a/database/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedSource.sq +++ b/database/src/commonMain/sqldelight/com/prof18/feedflow/db/FeedSource.sq @@ -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 diff --git a/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/data/SettingsHelper.kt b/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/data/SettingsHelper.kt index 40b2130d..f2fc8335 100644 --- a/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/data/SettingsHelper.kt +++ b/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/data/SettingsHelper.kt @@ -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) @@ -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, diff --git a/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/domain/feed/retriever/FeedRetrieverRepository.kt b/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/domain/feed/retriever/FeedRetrieverRepository.kt index 410a573c..1070d8cb 100644 --- a/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/domain/feed/retriever/FeedRetrieverRepository.kt +++ b/shared/src/commonMain/kotlin/com/prof18/feedflow/shared/domain/feed/retriever/FeedRetrieverRepository.kt @@ -198,13 +198,8 @@ internal class FeedRetrieverRepository( parseFeeds( feedSourceUrls = feedSourceUrls, forceRefresh = forceRefresh, - isFeedSourceMigrationRequired = isFirstLaunch && isSourceImageMigrationRequired(), ) - if (isFirstLaunch && isSourceImageMigrationRequired()) { - settingsHelper.setFeedSourceImageMigrationDone() - } - getFeeds() } } @@ -330,7 +325,6 @@ internal class FeedRetrieverRepository( private suspend fun parseFeeds( feedSourceUrls: List, forceRefresh: Boolean, - isFeedSourceMigrationRequired: Boolean, ) = feedSourceUrls .mapNotNull { feedSource -> @@ -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}}" } @@ -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"