mirror of https://github.com/readrops/Readrops.git
Get starred items separately only for initial synchronisation and fetch starred items ids everytime
This commit is contained in:
parent
2411449863
commit
f412ae2f1e
|
@ -12,7 +12,6 @@ import com.readrops.db.entities.Item;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -24,7 +23,6 @@ import okhttp3.RequestBody;
|
||||||
public class FreshRSSDataSource {
|
public class FreshRSSDataSource {
|
||||||
|
|
||||||
private static final int MAX_ITEMS = 5000;
|
private static final int MAX_ITEMS = 5000;
|
||||||
private static final int MAX_UNREAD_ITEMS_IDS = 5000;
|
|
||||||
private static final int MAX_STARRED_ITEMS = 1000;
|
private static final int MAX_STARRED_ITEMS = 1000;
|
||||||
|
|
||||||
public static final String GOOGLE_READ = "user/-/state/com.google/read";
|
public static final String GOOGLE_READ = "user/-/state/com.google/read";
|
||||||
|
@ -33,7 +31,7 @@ public class FreshRSSDataSource {
|
||||||
|
|
||||||
private static final String FEED_PREFIX = "feed/";
|
private static final String FEED_PREFIX = "feed/";
|
||||||
|
|
||||||
private FreshRSSService api;
|
private final FreshRSSService api;
|
||||||
|
|
||||||
public FreshRSSDataSource(FreshRSSService api) {
|
public FreshRSSDataSource(FreshRSSService api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
@ -106,21 +104,29 @@ public class FreshRSSDataSource {
|
||||||
if (syncType == SyncType.INITIAL_SYNC) {
|
if (syncType == SyncType.INITIAL_SYNC) {
|
||||||
return getItems(Arrays.asList(GOOGLE_READ, GOOGLE_STARRED), MAX_ITEMS, null);
|
return getItems(Arrays.asList(GOOGLE_READ, GOOGLE_STARRED), MAX_ITEMS, null);
|
||||||
} else {
|
} else {
|
||||||
return getItems(Collections.singletonList(GOOGLE_STARRED), MAX_ITEMS, syncData.getLastModified());
|
return getItems(null, MAX_ITEMS, syncData.getLastModified());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.flatMap(freshRSSItems -> {
|
.flatMap(freshRSSItems -> {
|
||||||
syncResult.setItems(freshRSSItems);
|
syncResult.setItems(freshRSSItems);
|
||||||
|
|
||||||
return getItemsIds(GOOGLE_READ, GOOGLE_READING_LIST, MAX_UNREAD_ITEMS_IDS);
|
return getItemsIds(GOOGLE_READ, GOOGLE_READING_LIST, MAX_ITEMS);
|
||||||
}).flatMap(unreadItemsIds -> {
|
}).flatMap(unreadItemsIds -> {
|
||||||
syncResult.setUnreadIds(unreadItemsIds);
|
syncResult.setUnreadIds(unreadItemsIds);
|
||||||
|
|
||||||
return getStarredItems(MAX_STARRED_ITEMS);
|
return getItemsIds(null, GOOGLE_STARRED, MAX_STARRED_ITEMS);
|
||||||
}).flatMap(starredItems -> {
|
}).flatMap(starredItemsIds -> {
|
||||||
syncResult.setStarredItems(starredItems);
|
syncResult.setStarredIds(starredItemsIds);
|
||||||
|
|
||||||
return Single.just(syncResult);
|
if (syncType == SyncType.INITIAL_SYNC) {
|
||||||
|
return getStarredItems(MAX_STARRED_ITEMS).flatMap(starredItems -> {
|
||||||
|
syncResult.setStarredItems(starredItems);
|
||||||
|
|
||||||
|
return Single.just(syncResult);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return Single.just(syncResult);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue