mirror of
https://github.com/readrops/Readrops.git
synced 2025-01-23 07:21:52 +01:00
Delete model for Nextcloud News read state api calls and use a map instead
This commit is contained in:
parent
188d2086dd
commit
c5476199d8
@ -15,7 +15,6 @@ import com.readrops.readropslibrary.services.nextcloudnews.adapters.NextNewsFeed
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.adapters.NextNewsFoldersAdapter;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.adapters.NextNewsItemsAdapter;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsFolder;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsItemIds;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsUser;
|
||||
import com.readrops.readropslibrary.utils.ConflictException;
|
||||
import com.readrops.readropslibrary.utils.LibUtils;
|
||||
@ -138,20 +137,27 @@ public class NextNewsAPI extends API<NextNewsService> {
|
||||
}
|
||||
|
||||
private void putModifiedItems(NextNewsSyncData data, NextNewsSyncResult syncResult) throws IOException {
|
||||
if (data.getReadItems().size() == 0 && data.getUnreadItems().size() == 0)
|
||||
return;
|
||||
if (!data.getReadItems().isEmpty()) {
|
||||
Map<String, List<String>> itemIdsMap = new HashMap<>();
|
||||
itemIdsMap.put("items", data.getReadItems());
|
||||
|
||||
Response readItemsResponse = api.setArticlesState(StateType.READ.name().toLowerCase(),
|
||||
new NextNewsItemIds(data.getReadItems())).execute();
|
||||
Response readItemsResponse = api.setArticlesState(StateType.READ.name().toLowerCase(),
|
||||
itemIdsMap).execute();
|
||||
|
||||
Response unreadItemsResponse = api.setArticlesState(StateType.UNREAD.toString().toLowerCase(),
|
||||
new NextNewsItemIds(data.getUnreadItems())).execute();
|
||||
if (!readItemsResponse.isSuccessful())
|
||||
syncResult.setError(true);
|
||||
}
|
||||
|
||||
if (!readItemsResponse.isSuccessful())
|
||||
syncResult.setError(true);
|
||||
if (!data.getUnreadItems().isEmpty()) {
|
||||
Map<String, List<String>> itemIdsMap = new HashMap<>();
|
||||
itemIdsMap.put("items", data.getUnreadItems());
|
||||
|
||||
if (!unreadItemsResponse.isSuccessful())
|
||||
syncResult.setError(true);
|
||||
Response unreadItemsResponse = api.setArticlesState(StateType.UNREAD.toString().toLowerCase(),
|
||||
itemIdsMap).execute();
|
||||
|
||||
if (!unreadItemsResponse.isSuccessful())
|
||||
syncResult.setError(true);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Folder> createFolder(NextNewsFolder folder) throws IOException, UnknownFormatException, ConflictException {
|
||||
|
@ -4,7 +4,6 @@ import com.readrops.readropsdb.entities.Feed;
|
||||
import com.readrops.readropsdb.entities.Folder;
|
||||
import com.readrops.readropsdb.entities.Item;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsFolder;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsItemIds;
|
||||
import com.readrops.readropslibrary.services.nextcloudnews.json.NextNewsUser;
|
||||
|
||||
import java.util.List;
|
||||
@ -40,7 +39,7 @@ public interface NextNewsService {
|
||||
Call<List<Item>> getNewItems(@Query("lastModified") long lastModified, @Query("type") int type);
|
||||
|
||||
@PUT("items/{stateType}/multiple")
|
||||
Call<ResponseBody> setArticlesState(@Path("stateType") String stateType, @Body NextNewsItemIds items);
|
||||
Call<ResponseBody> setArticlesState(@Path("stateType") String stateType, @Body Map<String, List<String>> itemIdsMap);
|
||||
|
||||
@POST("feeds")
|
||||
Call<List<Feed>> createFeed(@Query("url") String url, @Query("folderId") int folderId);
|
||||
|
@ -1,20 +0,0 @@
|
||||
package com.readrops.readropslibrary.services.nextcloudnews.json;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NextNewsItemIds {
|
||||
|
||||
private List<String> items;
|
||||
|
||||
public NextNewsItemIds(List<String> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public List<String> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<String> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user