mirror of https://github.com/readrops/Readrops.git
As greader write token is fetched at login, no need to fetch it when doing a write request
This commit is contained in:
parent
c9e47cfc12
commit
a585d7442a
|
@ -5,10 +5,10 @@ import android.app.Application;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.readrops.app.database.entities.account.Account;
|
|
||||||
import com.readrops.app.database.entities.Feed;
|
import com.readrops.app.database.entities.Feed;
|
||||||
import com.readrops.app.database.entities.Folder;
|
import com.readrops.app.database.entities.Folder;
|
||||||
import com.readrops.app.database.entities.Item;
|
import com.readrops.app.database.entities.Item;
|
||||||
|
import com.readrops.app.database.entities.account.Account;
|
||||||
import com.readrops.app.utils.FeedInsertionResult;
|
import com.readrops.app.utils.FeedInsertionResult;
|
||||||
import com.readrops.app.utils.FeedMatcher;
|
import com.readrops.app.utils.FeedMatcher;
|
||||||
import com.readrops.app.utils.ItemMatcher;
|
import com.readrops.app.utils.ItemMatcher;
|
||||||
|
@ -119,54 +119,23 @@ public class FreshRSSRepository extends ARepository {
|
||||||
Folder folder = feed.getFolderId() == null ? null : database.folderDao().select(feed.getFolderId());
|
Folder folder = feed.getFolderId() == null ? null : database.folderDao().select(feed.getFolderId());
|
||||||
emitter.onSuccess(folder);
|
emitter.onSuccess(folder);
|
||||||
|
|
||||||
}).flatMapCompletable(folder -> {
|
}).flatMapCompletable(folder -> api.updateFeed(account.getWriteToken(),
|
||||||
if (account.getWriteToken() == null) {
|
|
||||||
return api.getWriteToken()
|
|
||||||
.flatMapCompletable(token -> {
|
|
||||||
database.accountDao().updateWriteToken(account.getId(), token);
|
|
||||||
|
|
||||||
return api.updateFeed(token,
|
|
||||||
feed.getUrl(), feed.getName(), folder == null ? null : folder.getRemoteId())
|
feed.getUrl(), feed.getName(), folder == null ? null : folder.getRemoteId())
|
||||||
.andThen(super.updateFeed(feed));
|
.andThen(super.updateFeed(feed)));
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return api.updateFeed(account.getWriteToken(),
|
|
||||||
feed.getUrl(), feed.getName(), folder == null ? null : folder.getRemoteId())
|
|
||||||
.andThen(super.updateFeed(feed));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Completable deleteFeed(Feed feed) {
|
public Completable deleteFeed(Feed feed) {
|
||||||
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
||||||
|
|
||||||
if (account.getWriteToken() == null) {
|
|
||||||
return api.getWriteToken()
|
|
||||||
.flatMapCompletable(token -> {
|
|
||||||
database.accountDao().updateWriteToken(account.getId(), token);
|
|
||||||
|
|
||||||
return api.deleteFeed(token, feed.getUrl())
|
|
||||||
.andThen(super.deleteFeed(feed));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return api.deleteFeed(account.getWriteToken(), feed.getUrl())
|
return api.deleteFeed(account.getWriteToken(), feed.getUrl())
|
||||||
.andThen(super.deleteFeed(feed));
|
.andThen(super.deleteFeed(feed));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Completable addFolder(Folder folder) {
|
public Completable addFolder(Folder folder) {
|
||||||
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
||||||
|
|
||||||
if (account.getWriteToken() == null) {
|
|
||||||
return api.getWriteToken()
|
|
||||||
.flatMapCompletable(token -> {
|
|
||||||
database.accountDao().updateWriteToken(account.getId(), token);
|
|
||||||
|
|
||||||
return api.createFolder(token, folder.getName());
|
|
||||||
});
|
|
||||||
} else
|
|
||||||
return api.createFolder(account.getWriteToken(), folder.getName());
|
return api.createFolder(account.getWriteToken(), folder.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,33 +143,14 @@ public class FreshRSSRepository extends ARepository {
|
||||||
public Completable updateFolder(Folder folder) {
|
public Completable updateFolder(Folder folder) {
|
||||||
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
||||||
|
|
||||||
if (account.getWriteToken() == null) {
|
|
||||||
return api.getWriteToken()
|
|
||||||
.flatMapCompletable(token -> {
|
|
||||||
database.accountDao().updateWriteToken(account.getId(), token);
|
|
||||||
|
|
||||||
return api.updateFolder(token, folder.getRemoteId(), folder.getName())
|
|
||||||
.andThen(super.updateFolder(folder));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return api.updateFolder(account.getWriteToken(), folder.getRemoteId(), folder.getName())
|
return api.updateFolder(account.getWriteToken(), folder.getRemoteId(), folder.getName())
|
||||||
.andThen(super.updateFolder(folder));
|
.andThen(super.updateFolder(folder));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Completable deleteFolder(Folder folder) {
|
public Completable deleteFolder(Folder folder) {
|
||||||
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
FreshRSSAPI api = new FreshRSSAPI(account.toCredentials());
|
||||||
|
|
||||||
if (account.getWriteToken() == null) {
|
|
||||||
return api.getWriteToken()
|
|
||||||
.flatMapCompletable(token -> {
|
|
||||||
database.accountDao().updateWriteToken(account.getId(), token);
|
|
||||||
|
|
||||||
return api.deleteFolder(token, folder.getRemoteId())
|
|
||||||
.andThen(super.deleteFolder(folder));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return api.deleteFolder(account.getWriteToken(), folder.getRemoteId())
|
return api.deleteFolder(account.getWriteToken(), folder.getRemoteId())
|
||||||
.andThen(super.deleteFolder(folder));
|
.andThen(super.deleteFolder(folder));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue