Skip to content

Commit

Permalink
Fixed error message when marking all inbox messages as read
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumBadger committed Nov 30, 2020
1 parent b5211df commit 3c23897
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
3 changes: 3 additions & 0 deletions assets/changelog-alpha.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/Alpha 255 (2020-11-30)
Fixed error message when marking all inbox messages as read

/Alpha 254 (2020-11-29)
Alpha changelog is now more granular
Show subreddit of comments in user profile/inbox (thanks to Cameron Merkel)
Expand Down
3 changes: 3 additions & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
96/1.16
Fixed error message when marking all inbox messages as read

95/1.15
Inline image previews (and preference to disable)
Stream videos rather than waiting until download complete
Expand Down
47 changes: 44 additions & 3 deletions src/main/java/org/quantumbadger/redreader/reddit/RedditAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
import org.quantumbadger.redreader.activities.BugReportActivity;
import org.quantumbadger.redreader.cache.CacheManager;
import org.quantumbadger.redreader.cache.CacheRequest;
import org.quantumbadger.redreader.cache.CacheRequestCallbacks;
import org.quantumbadger.redreader.cache.CacheRequestJSONParser;
import org.quantumbadger.redreader.cache.downloadstrategy.DownloadStrategy;
import org.quantumbadger.redreader.cache.downloadstrategy.DownloadStrategyAlways;
import org.quantumbadger.redreader.common.Constants;
import org.quantumbadger.redreader.common.GenericFactory;
import org.quantumbadger.redreader.common.Priority;
import org.quantumbadger.redreader.common.RRError;
import org.quantumbadger.redreader.common.TimestampBound;
import org.quantumbadger.redreader.common.datastream.SeekableInputStream;
import org.quantumbadger.redreader.http.HTTPBackend;
import org.quantumbadger.redreader.io.RequestResponseHandler;
import org.quantumbadger.redreader.jsonwrap.JsonArray;
Expand All @@ -44,6 +47,7 @@
import org.quantumbadger.redreader.reddit.things.RedditUser;
import org.quantumbadger.redreader.reddit.things.SubredditCanonicalId;

import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.URI;
Expand Down Expand Up @@ -282,12 +286,33 @@ public static void markAllAsRead(

final LinkedList<HTTPBackend.PostField> postFields = new LinkedList<>();

cm.makeRequest(createPostRequest(
cm.makeRequest(createPostRequestUnprocessedResponse(
Constants.Reddit.getUri("/api/read_all_messages"),
user,
postFields,
context,
new GenericResponseHandler(responseHandler)));
new CacheRequestCallbacks() {
@Override
public void onFailure(
final int type,
@Nullable final Throwable t,
@Nullable final Integer httpStatus,
@Nullable final String readableMessage) {

responseHandler.notifyFailure(type, t, httpStatus, readableMessage);
}

@Override
public void onDataStreamComplete(
@NonNull final GenericFactory<SeekableInputStream, IOException> streamFactory,
final long timestamp,
@NonNull final UUID session,
final boolean fromCache,
@Nullable final String mimetype) {

responseHandler.notifySuccess(null);
}
}));
}

public static void editComment(
Expand Down Expand Up @@ -690,6 +715,22 @@ private static CacheRequest createPostRequest(
@NonNull final Context context,
@NonNull final CacheRequestJSONParser.Listener handler) {

return createPostRequestUnprocessedResponse(
url,
user,
postFields,
context,
new CacheRequestJSONParser(context, handler));
}

@NonNull
private static CacheRequest createPostRequestUnprocessedResponse(
@NonNull final URI url,
@NonNull final RedditAccount user,
@NonNull final List<HTTPBackend.PostField> postFields,
@NonNull final Context context,
@NonNull final CacheRequestCallbacks callbacks) {

return new CacheRequest(
url,
user,
Expand All @@ -700,7 +741,7 @@ private static CacheRequest createPostRequest(
CacheRequest.DOWNLOAD_QUEUE_REDDIT_API,
postFields,
context,
new CacheRequestJSONParser(context, handler));
callbacks);
}

@NonNull
Expand Down

0 comments on commit 3c23897

Please sign in to comment.