From 7dac06b96e55b975e4c6e7646a9b47017a1d408c Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 10 Oct 2021 19:05:51 +0200 Subject: [PATCH 1/3] Fix 401 error when synchronising for the second time with a FreshRSS account --- app/src/main/java/com/readrops/app/utils/Utils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/src/main/java/com/readrops/app/utils/Utils.java b/app/src/main/java/com/readrops/app/utils/Utils.java index 1c3ecb28..aad043b1 100644 --- a/app/src/main/java/com/readrops/app/utils/Utils.java +++ b/app/src/main/java/com/readrops/app/utils/Utils.java @@ -15,7 +15,6 @@ import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import com.google.android.material.snackbar.Snackbar; -import com.readrops.api.utils.AuthInterceptor; import org.koin.java.KoinJavaComponent; @@ -37,7 +36,6 @@ public final class Utils { public static Bitmap getImageFromUrl(String url) { try { Request request = new Request.Builder().url(url).build(); - KoinJavaComponent.get(AuthInterceptor.class).setCredentials(null); Response response = KoinJavaComponent.get(OkHttpClient.class).newCall(request).execute(); From 3d78b2a951d26773ce5adbb3107c47020b929fda Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 10 Oct 2021 19:31:47 +0200 Subject: [PATCH 2/3] Fix items being fav locally randomly for FreshRSS account --- .../com/readrops/api/services/SyncResult.kt | 1 + .../services/freshrss/FreshRSSDataSource.java | 80 ++++++++----------- .../app/repositories/FreshRSSRepository.java | 14 +++- 3 files changed, 47 insertions(+), 48 deletions(-) diff --git a/api/src/main/java/com/readrops/api/services/SyncResult.kt b/api/src/main/java/com/readrops/api/services/SyncResult.kt index 6252affa..aff7c954 100644 --- a/api/src/main/java/com/readrops/api/services/SyncResult.kt +++ b/api/src/main/java/com/readrops/api/services/SyncResult.kt @@ -9,6 +9,7 @@ class SyncResult(var items: List = mutableListOf(), var feeds: List = listOf(), var folders: List = listOf(), var unreadIds: List? = null, + var readIds: List? = null, var starredIds: List? = null, var isError: Boolean = false ) diff --git a/api/src/main/java/com/readrops/api/services/freshrss/FreshRSSDataSource.java b/api/src/main/java/com/readrops/api/services/freshrss/FreshRSSDataSource.java index 16f4c602..3e48d53d 100644 --- a/api/src/main/java/com/readrops/api/services/freshrss/FreshRSSDataSource.java +++ b/api/src/main/java/com/readrops/api/services/freshrss/FreshRSSDataSource.java @@ -12,6 +12,7 @@ import com.readrops.db.entities.Item; import java.io.StringReader; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Properties; @@ -22,10 +23,11 @@ import okhttp3.RequestBody; public class FreshRSSDataSource { - private static final int MAX_ITEMS = 5000; + private static final int MAX_ITEMS = 2500; private static final int MAX_STARRED_ITEMS = 1000; public static final String GOOGLE_READ = "user/-/state/com.google/read"; + public static final String GOOGLE_UNREAD = "user/-/state/com.google/unread"; public static final String GOOGLE_STARRED = "user/-/state/com.google/starred"; public static final String GOOGLE_READING_LIST = "user/-/state/com.google/reading-list"; @@ -88,46 +90,32 @@ public class FreshRSSDataSource { * @return the result of the synchronization */ public Single sync(@NonNull SyncType syncType, @NonNull FreshRSSSyncData syncData, @NonNull String writeToken) { - SyncResult syncResult = new SyncResult(); + if (syncType == SyncType.INITIAL_SYNC) { + return Single.zip(setItemsReadState(syncData, writeToken).toSingleDefault(""), + setItemsStarState(syncData, writeToken).toSingleDefault(""), + getFolders(), + getFeeds(), + getItems(Arrays.asList(GOOGLE_READ, GOOGLE_STARRED), MAX_ITEMS, null), + getItemsIds(GOOGLE_READ, GOOGLE_READING_LIST, MAX_ITEMS), // unread items ids + getItemsIds(null, GOOGLE_STARRED, MAX_STARRED_ITEMS), // starred items ids + getStarredItems(MAX_STARRED_ITEMS), + (readState, starState, folders, feeds, items, unreadItemsIds, starredItemsIds, starredItems) -> + new SyncResult(items, starredItems, feeds, folders, unreadItemsIds, Collections.emptyList(), starredItemsIds, false) + ); + } else { + return Single.zip(setItemsReadState(syncData, writeToken).toSingleDefault(""), + setItemsStarState(syncData, writeToken).toSingleDefault(""), + getFolders(), + getFeeds(), + getItems(null, MAX_ITEMS, syncData.getLastModified()), + getItemsIds(GOOGLE_READ, GOOGLE_READING_LIST, MAX_ITEMS), // unread items ids + getItemsIds(GOOGLE_UNREAD, GOOGLE_READING_LIST, MAX_ITEMS), // read items ids + getItemsIds(null, GOOGLE_STARRED, MAX_STARRED_ITEMS), // starred items ids + (readState, starState, folders, feeds, items, unreadItemsIds, readItemsIds, starredItemsIds) -> + new SyncResult(items, Collections.emptyList(), feeds, folders, unreadItemsIds, readItemsIds, starredItemsIds, false) - return setItemsReadState(syncData, writeToken) - .andThen(setItemsStarState(syncData, writeToken)) - .andThen(getFolders() - .flatMap(freshRSSFolders -> { - syncResult.setFolders(freshRSSFolders); - - return getFeeds(); - }) - .flatMap(freshRSSFeeds -> { - syncResult.setFeeds(freshRSSFeeds); - - if (syncType == SyncType.INITIAL_SYNC) { - return getItems(Arrays.asList(GOOGLE_READ, GOOGLE_STARRED), MAX_ITEMS, null); - } else { - return getItems(null, MAX_ITEMS, syncData.getLastModified()); - } - }) - .flatMap(freshRSSItems -> { - syncResult.setItems(freshRSSItems); - - return getItemsIds(GOOGLE_READ, GOOGLE_READING_LIST, MAX_ITEMS); - }).flatMap(unreadItemsIds -> { - syncResult.setUnreadIds(unreadItemsIds); - - return getItemsIds(null, GOOGLE_STARRED, MAX_STARRED_ITEMS); - }).flatMap(starredItemsIds -> { - syncResult.setStarredIds(starredItemsIds); - - if (syncType == SyncType.INITIAL_SYNC) { - return getStarredItems(MAX_STARRED_ITEMS).flatMap(starredItems -> { - syncResult.setStarredItems(starredItems); - - return Single.just(syncResult); - }); - } else { - return Single.just(syncResult); - } - })); + ); + } } /** @@ -183,7 +171,7 @@ public class FreshRSSDataSource { * @param token token for modifications * @return Completable */ - public Completable markItemsReadUnread(boolean read, @NonNull List itemIds, @NonNull String token) { + public Completable setItemsReadState(boolean read, @NonNull List itemIds, @NonNull String token) { if (read) { return api.setItemsState(token, GOOGLE_READ, null, itemIds); } else { @@ -199,7 +187,7 @@ public class FreshRSSDataSource { * @param token token for modifications * @return Completable */ - public Completable markItemsStarredUnstarred(boolean starred, @NonNull List itemIds, @NonNull String token) { + public Completable setItemsStarState(boolean starred, @NonNull List itemIds, @NonNull String token) { if (starred) { return api.setItemsState(token, GOOGLE_STARRED, null, itemIds); } else { @@ -288,14 +276,14 @@ public class FreshRSSDataSource { if (syncData.getReadItemsIds().isEmpty()) { readItemsCompletable = Completable.complete(); } else { - readItemsCompletable = markItemsReadUnread(true, syncData.getReadItemsIds(), token); + readItemsCompletable = setItemsReadState(true, syncData.getReadItemsIds(), token); } Completable unreadItemsCompletable; if (syncData.getUnreadItemsIds().isEmpty()) { unreadItemsCompletable = Completable.complete(); } else { - unreadItemsCompletable = markItemsReadUnread(false, syncData.getUnreadItemsIds(), token); + unreadItemsCompletable = setItemsReadState(false, syncData.getUnreadItemsIds(), token); } return readItemsCompletable.concatWith(unreadItemsCompletable); @@ -313,14 +301,14 @@ public class FreshRSSDataSource { if (syncData.getStarredItemsIds().isEmpty()) { starredItemsCompletable = Completable.complete(); } else { - starredItemsCompletable = markItemsStarredUnstarred(true, syncData.getStarredItemsIds(), token); + starredItemsCompletable = setItemsStarState(true, syncData.getStarredItemsIds(), token); } Completable unstarredItemsCompletable; if (syncData.getUnstarredItemsIds().isEmpty()) { unstarredItemsCompletable = Completable.complete(); } else { - unstarredItemsCompletable = markItemsStarredUnstarred(false, syncData.getUnstarredItemsIds(), token); + unstarredItemsCompletable = setItemsStarState(false, syncData.getUnstarredItemsIds(), token); } return starredItemsCompletable.concatWith(unstarredItemsCompletable); diff --git a/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java b/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java index 5161c6ea..8f484b78 100644 --- a/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java +++ b/app/src/main/java/com/readrops/app/repositories/FreshRSSRepository.java @@ -133,7 +133,7 @@ public class FreshRSSRepository extends ARepository { insertItems(syncResult.getStarredItems(), true); logger.addSplit("starred items insertion"); - insertItemsIds(syncResult.getUnreadIds(), syncResult.getStarredIds()); + insertItemsIds(syncResult.getUnreadIds(), syncResult.getReadIds(), syncResult.getStarredIds()); logger.addSplit("insert and update items ids"); account.setLastModified(newLastModified); @@ -266,7 +266,7 @@ public class FreshRSSRepository extends ARepository { } } - private void insertItemsIds(List unreadIds, List starredIds) { + private void insertItemsIds(List unreadIds, List readIds, List starredIds) { database.itemStateDao().deleteItemsStates(account.getId()); database.itemStateDao().insertItemStates(unreadIds.stream().map(id -> { @@ -279,6 +279,16 @@ public class FreshRSSRepository extends ARepository { } ).collect(Collectors.toList())); + database.itemStateDao().insertItemStates(readIds.stream().map(id -> { + boolean starred = starredIds.stream().filter(starredId -> starredId.equals(id)).count() == 1; + if (starred) { + starredIds.remove(id); + } + + return new ItemState(0, true, starred, id, account.getId()); + } + ).collect(Collectors.toList())); + // insert starred items ids which are read if (!starredIds.isEmpty()) { database.itemStateDao().insertItemStates(starredIds.stream().map(id -> From 7feb54f44ac7c65f2cef5dc9921c6b008268bba3 Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Sun, 10 Oct 2021 19:48:54 +0200 Subject: [PATCH 3/3] v1.3.1 --- CHANGELOG.md | 4 ++++ app/build.gradle | 4 ++-- fastlane/metadata/android/en-US/changelogs/14.txt | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/14.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 7df24dd9..ad545f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v1.3.1 +- FreshRSS : Fix items being fav unintentionally +- FreshRSS : Fix 401 error when synchronising for the second time + # v1.3.0 - New local RSS parser, much reliable - New external navigator view for items (Custom tabs) diff --git a/app/build.gradle b/app/build.gradle index 3ddce5c7..d2e42900 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,8 +11,8 @@ android { targetSdkVersion rootProject.ext.targetSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion - versionCode 13 - versionName "1.3.0" + versionCode 14 + versionName "1.3.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } testOptions { diff --git a/fastlane/metadata/android/en-US/changelogs/14.txt b/fastlane/metadata/android/en-US/changelogs/14.txt new file mode 100644 index 00000000..dc548020 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/14.txt @@ -0,0 +1,4 @@ +
    +
  • FreshRSS : Fix items being fav unintentionally
  • +
  • FreshRSS : Fix 401 error when synchronising for the second time
  • +