From 7b40a31979f468f667d0f8f76a2a044e7ca8bd2d Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sun, 30 Oct 2022 21:21:43 +0100 Subject: [PATCH] Cleaning. --- androidApp/src/test/kotlin/DatesTest.kt | 4 +--- androidApp/src/test/kotlin/RepositoryTest.kt | 1 - .../bou/amine/apps/readerforselfossv2/utils/DateUtils.kt | 4 +--- .../apps/readerforselfossv2/repository/RepositoryImpl.kt | 4 +--- .../bou/amine/apps/readerforselfossv2/utils/DateUtils.kt | 4 +--- 5 files changed, 4 insertions(+), 13 deletions(-) diff --git a/androidApp/src/test/kotlin/DatesTest.kt b/androidApp/src/test/kotlin/DatesTest.kt index cd91125..67d88d3 100644 --- a/androidApp/src/test/kotlin/DatesTest.kt +++ b/androidApp/src/test/kotlin/DatesTest.kt @@ -10,9 +10,7 @@ import kotlinx.datetime.toInstant import org.junit.Test class DatesTest { - private val appSettingsService = mockk() - - private val dateUtils: DateUtils = DateUtils(appSettingsService) + private val dateUtils: DateUtils = DateUtils() private val v3Date = "2013-04-07T13:43:00+01:00" private val v4Date = "2013-04-07 13:43:00" diff --git a/androidApp/src/test/kotlin/RepositoryTest.kt b/androidApp/src/test/kotlin/RepositoryTest.kt index 347a0d5..803c5a2 100644 --- a/androidApp/src/test/kotlin/RepositoryTest.kt +++ b/androidApp/src/test/kotlin/RepositoryTest.kt @@ -1,6 +1,5 @@ package bou.amine.apps.readerforselfossv2.repository -import bou.amine.apps.readerforselfossv2.dao.ITEM import bou.amine.apps.readerforselfossv2.dao.ReaderForSelfossDB import bou.amine.apps.readerforselfossv2.dao.SOURCE import bou.amine.apps.readerforselfossv2.dao.TAG diff --git a/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt b/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt index ce3121a..ef09558 100644 --- a/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt +++ b/shared/src/androidMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt @@ -1,12 +1,10 @@ package bou.amine.apps.readerforselfossv2.utils import android.text.format.DateUtils -import bou.amine.apps.readerforselfossv2.service.AppSettingsService import kotlinx.datetime.* -import java.time.format.DateTimeFormatter -actual class DateUtils actual constructor(actual val appSettingsService: AppSettingsService) { +actual class DateUtils { actual fun parseDate(dateString: String): Long { return try { diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index cf25229..bf48211 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking class Repository(private val api: SelfossApi, private val appSettingsService: AppSettingsService, val isConnectionAvailable: MutableStateFlow, private val db: ReaderForSelfossDB) { @@ -19,7 +18,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap var connectionMonitored = false var baseUrl = appSettingsService.getBaseUrl() - lateinit var dateUtils: DateUtils + var dateUtils: DateUtils = DateUtils() var displayedItems = ItemType.UNREAD @@ -394,7 +393,6 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap appSettingsService.updateApiVersion(fetchedVersion.data.getApiMajorVersion()) } } - dateUtils = DateUtils(appSettingsService) } fun isNetworkAvailable() = isConnectionAvailable.value && !offlineOverride diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt index d235b97..9856726 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/utils/DateUtils.kt @@ -7,9 +7,7 @@ import bou.amine.apps.readerforselfossv2.service.AppSettingsService fun SelfossModel.Item.parseDate(dateUtils: DateUtils): Long = dateUtils.parseDate(this.datetime) -expect class DateUtils constructor(appSettingsService: AppSettingsService) { - val appSettingsService: AppSettingsService // This is needed because of https://stackoverflow.com/a/65249085 - +expect class DateUtils() { fun parseDate(dateString: String): Long fun parseRelativeDate(dateString: String): String