Commit 8dc55fc9 authored by Christophe Henry's avatar Christophe Henry
Browse files

Merge branch '99' into 'develop'

Fix #99: on first sync, images are not automatically refreshed anymore

Closes #99

See merge request christophehenry/freshrss-android!105
parents b7c1c537 5c18d6c7
Pipeline #4198 passed with stage
in 0 seconds
# Development
# Bug fixes
* Fix [#99](https://git.feneas.org/christophehenry/freshrss-android/-/issues/99): on first sync, images are not automatically refreshed anymore ([!105](https://git.feneas.org/christophehenry/freshrss-android/-/merge_requests/105))
# 1.3.1
## Features
......
......@@ -91,15 +91,18 @@ object Store {
}
suspend fun fetchImages(): Unit = withContext(Dispatchers.IO) {
db().getAllSubcriptionsWithImageToUpdate().mapNotNull {
val result = it.fetchImage()
if(result.isFailure) null
else async {
SubscriptionImageUpdate(it.id, result.getOrThrow(), it.iconUrl.trim())
.let(db()::insertSubscriptionImage)
db().getAllSubcriptionsWithImageToUpdate()
.map {
async {
val result = it.fetchImage()
if(result.isFailure) null
else SubscriptionImageUpdate(it.id, result.getOrThrow(), it.iconUrl.trim())
}
}
}.awaitAll()
}.unit()
.awaitAll()
.filterNotNull()
.let(db()::insertSubscriptionImages)
}
suspend fun getUnreadCount() {
executeSafeApiCall {getUnreadCount()}.onSuccess {result ->
......
......@@ -32,6 +32,7 @@ abstract class FreshRSSDabatabase: RoomDatabase() {
suspend fun insertAccount(account: Account) = getAccountsDAO().insert(account)
suspend fun updateLastFetchDate(id: Int, date: DateTime) =
getAccountsDAO().updateLastFetchDate(AccountLastFetchDateUpdate(id, date))
fun updateTotalUnreadCount(id: Int, unreadCount: Int) = getAccountsDAO().updateUnreadCount(id, unreadCount)
fun incrementTotalUnreadCount(id: Int) = getAccountsDAO().incrementUnreadCount(id)
fun decrementTotalUnreadCount(id: Int) = getAccountsDAO().decrementUnreadCount(id)
......@@ -86,7 +87,9 @@ abstract class FreshRSSDabatabase: RoomDatabase() {
fun incrementSubscriptionCount(id: String) = getSubscriptionsDAO().incrementCount(id)
fun decrementSubscriptionCount(id: String) = getSubscriptionsDAO().decrementCount(id)
fun insertSubscriptionImage(imageUpdate: SubscriptionImageUpdate) = getSubscriptionsDAO().insertImage(imageUpdate)
fun insertSubscriptionImages(imageUpdates: List<SubscriptionImageUpdate>) =
getSubscriptionsDAO().insertImages(imageUpdates)
fun getSubcriptionsById(id: String) = getSubscriptionsDAO().byId(id)
fun getSubcriptionTitleById(id: String) = getSubscriptionsDAO().titleById(id)
fun getSubcriptionsBySubscriptionCategory(feedTag: FeedTag) =
......
......@@ -158,7 +158,7 @@ interface SubscriptionsDAO {
fun decrementCount(id: String)
@Update(entity = Subscription::class)
fun insertImage(imageUpdate: SubscriptionImageUpdate)
fun insertImages(imageUpdates: List<SubscriptionImageUpdate>)
@Query("UPDATE subscriptions SET imageBitmap = NULL WHERE id = :id")
fun deleteImage(id: String)
......
......@@ -43,7 +43,6 @@ sealed class SubscriptionsVM: ViewModel() {
}
Flowable.combineLatest(combiner(), ::flowableTransformer)
.distinctUntilChanged()
.throttleLatest(1000, TimeUnit.MILLISECONDS)
.toLiveData().let {scope.emitSource(it)}
}
......
......@@ -5,14 +5,12 @@ import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.widget.ImageView
import android.widget.TextView
import androidx.annotation.DrawableRes
import androidx.appcompat.widget.AppCompatImageView
import androidx.databinding.BindingAdapter
import fr.chenry.android.freshrss.R
@BindingAdapter("font")
fun textStyle(textView: TextView, typeface: String) {
textView.typeface = when (typeface) {
textView.typeface = when(typeface) {
"bold" -> Typeface.create(textView.typeface, Typeface.BOLD)
"italic" -> Typeface.create(textView.typeface, Typeface.ITALIC)
"bold_italic" -> Typeface.create(textView.typeface, Typeface.BOLD_ITALIC)
......@@ -21,10 +19,8 @@ fun textStyle(textView: TextView, typeface: String) {
}
@BindingAdapter("android:src")
fun setImageViewResource(imageView: ImageView, resource: Bitmap?) =
resource?.let { imageView.setImageBitmap(resource) }
.whenNull { imageView.setImageResource(R.drawable.ic_rss_feed_black_24dp_no_padding) }
fun setImageViewResource(imageView: ImageView, resource: Bitmap?) = resource?.let(imageView::setImageBitmap)
@BindingAdapter("srcCompat")
fun setImageViewResourceCompat(imageView: AppCompatImageView, resource: Drawable?) =
resource?.let { imageView.setImageDrawable(resource) }
resource?.let(imageView::setImageDrawable)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment