Skip to content

Commit

Permalink
Fix proguard rules and database issue
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Jan 30, 2025
1 parent 9c47584 commit 74aa5dc
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 14 deletions.
48 changes: 47 additions & 1 deletion desktopApp/compose-desktop.pro
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,50 @@
-dontwarn com.google.appengine.**
-dontwarn com.dropbox**.android.**
-dontwarn org.testng.**
-dontwarn bsh.**
-dontwarn bsh.**

# Kotlinx Serialization
# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
static **$* *;
}
-keepclassmembers class <2>$<3> {
kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
public static ** INSTANCE;
}
-keepclassmembers class <1> {
public static <1> INSTANCE;
kotlinx.serialization.KSerializer serializer(...);
}

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

# Don't print notes about potential mistakes or omissions in the configuration for kotlinx-serialization classes
# See also https://github.com/Kotlin/kotlinx.serialization/issues/1900
-dontnote kotlinx.serialization.**

# Serialization core uses `java.lang.ClassValue` for caching inside these specified classes.
# If there is no `java.lang.ClassValue` (for example, in Android), then R8/ProGuard will print a warning.
# However, since in this case they will not be used, we can disable these warnings
-dontwarn kotlinx.serialization.internal.ClassValueReferences

# disable optimisation for descriptor field because in some versions of ProGuard, optimization generates incorrect bytecode that causes a verification error
# see https://github.com/Kotlin/kotlinx.serialization/issues/2719
-keepclassmembers public class **$$serializer {
private ** descriptor;
}


-keep class com.prof18.feedflow.feedsync.greader.data.dto.** { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.prof18.feedflow.core.domain.DateFormatter
import com.prof18.feedflow.core.model.DataNotFound
import com.prof18.feedflow.core.model.DataResult
import com.prof18.feedflow.core.model.FeedFilter
import com.prof18.feedflow.core.model.FeedItem
import com.prof18.feedflow.core.model.FeedItemId
import com.prof18.feedflow.core.model.FeedSource
import com.prof18.feedflow.core.model.FeedSourceCategory
Expand All @@ -32,10 +33,8 @@ import com.prof18.feedflow.feedsync.greader.domain.SubscriptionEditAction
import com.prof18.feedflow.feedsync.greader.domain.mapping.ItemContentDTOMapper
import com.prof18.feedflow.feedsync.greader.domain.mapping.toFeedSource
import com.prof18.feedflow.feedsync.networkcore.NetworkSettings
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flatMapMerge
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.datetime.Clock
import kotlin.time.Duration.Companion.days
Expand Down Expand Up @@ -361,7 +360,6 @@ class GReaderRepository internal constructor(
return Unit.success()
}

@OptIn(ExperimentalCoroutinesApi::class)
private suspend fun getItemsContent() {
val idsFromDb = databaseHelper.getAllFeedItemUrlHashes().toSet()
val items: Set<String> = with(syncItemHolder.get()) {
Expand All @@ -374,12 +372,11 @@ class GReaderRepository internal constructor(
}

val feedSources = databaseHelper.getFeedSources().toSet()
val feedItemsHolder = AtomicReference(emptyList<FeedItem>())

items
.chunked(PAGE_SIZE)
.asFlow()
.flatMapMerge { itemIds ->
suspend {
coroutineScope {
items.chunked(PAGE_SIZE).map { itemIds ->
launch {
gReaderClient.getStreamItemsContents(itemIds)
.fold(
onSuccess = { itemsResponse ->
Expand All @@ -392,15 +389,18 @@ class GReaderRepository internal constructor(
feedSource = feedSource,
)
}
databaseHelper.insertFeedItems(feedItems, dateFormatter.currentTimeMillis())
feedItemsHolder.set(feedItemsHolder.get() + feedItems)
logger.d { ">>> Finished chunk: size ${feedItems.size}" }
},
onFailure = {
feedSyncMessageQueue.emitResult(SyncResult.Error)
},
)
}.asFlow()
}
}
.collect()
}
logger.d { "Inserting into db: size ${feedItemsHolder.get().size}" }
databaseHelper.insertFeedItems(feedItemsHolder.get(), dateFormatter.currentTimeMillis())
}

private fun getAuthToken(responseBody: String): String? =
Expand Down

0 comments on commit 74aa5dc

Please sign in to comment.