Readd date of last sync using a local value instead of using FreshRSS' one

This commit is contained in:
Shinokuni 2020-01-05 19:06:10 +01:00
parent 19ca5a7398
commit 45e594d4f2
2 changed files with 25 additions and 20 deletions

View File

@ -20,6 +20,8 @@ import com.readrops.readropslibrary.services.freshrss.FreshRSSAPI;
import com.readrops.readropslibrary.services.freshrss.FreshRSSCredentials;
import com.readrops.readropslibrary.services.freshrss.FreshRSSSyncData;
import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -90,6 +92,7 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
} else
syncType = SyncType.INITIAL_SYNC;
long newLastModified = DateTime.now().getMillis() / 1000L;
TimingLogger logger = new TimingLogger(TAG, "FreshRSS sync timer");
return Single.<FreshRSSSyncData>create(emitter -> {
@ -109,10 +112,11 @@ public class FreshRSSRepository extends ARepository<FreshRSSAPI> {
insertItems(syncResult.getItems(), syncType == SyncType.INITIAL_SYNC);
logger.addSplit("items insertion");
//account.setLastModified(syncResult.getLastUpdated());
//database.accountDao().updateLastModified(account.getId(), syncResult.getLastUpdated());
account.setLastModified(newLastModified);
database.accountDao().updateLastModified(account.getId(), newLastModified);
//database.itemDao().resetReadChanges(account.getId());
database.itemDao().resetReadChanges();
logger.addSplit("reset read changes");
logger.dumpToLog();
return Observable.empty();

View File

@ -97,26 +97,27 @@ public class FreshRSSAPI extends API<FreshRSSService> {
public Single<FreshRSSSyncResult> sync(@NonNull SyncType syncType, @NonNull FreshRSSSyncData syncData, @NonNull String writeToken) {
FreshRSSSyncResult syncResult = new FreshRSSSyncResult();
return getFolders()
.flatMap(freshRSSFolders -> {
syncResult.setFolders(freshRSSFolders);
return setItemsReadState(syncData, writeToken)
.andThen(getFolders()
.flatMap(freshRSSFolders -> {
syncResult.setFolders(freshRSSFolders);
return getFeeds();
})
.flatMap(freshRSSFeeds -> {
syncResult.setFeeds(freshRSSFeeds);
return getFeeds();
})
.flatMap(freshRSSFeeds -> {
syncResult.setFeeds(freshRSSFeeds);
if (syncType == SyncType.INITIAL_SYNC) {
return getItems(GOOGLE_READ, MAX_ITEMS, null);
} else {
return getItems(GOOGLE_READ, MAX_ITEMS, syncData.getLastModified());
}
})
.flatMap(freshRSSItems -> {
syncResult.setItems(freshRSSItems);
if (syncType == SyncType.INITIAL_SYNC) {
return getItems(GOOGLE_READ, MAX_ITEMS, null);
} else {
return getItems(GOOGLE_READ, MAX_ITEMS, syncData.getLastModified());
}
})
.flatMap(freshRSSItems -> {
syncResult.setItems(freshRSSItems);
return Single.just(syncResult);
});
return Single.just(syncResult);
}));
}
/**