simplify replying to stories

no need to create thread before sending
This commit is contained in:
Austin Huang 2021-06-14 21:13:12 -04:00
parent e89c1ac9ef
commit a45844b50e
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F

View File

@ -86,7 +86,7 @@ import awais.instagrabber.models.stickers.SliderModel;
import awais.instagrabber.models.stickers.SwipeUpModel; import awais.instagrabber.models.stickers.SwipeUpModel;
import awais.instagrabber.repositories.requests.StoryViewerOptions; import awais.instagrabber.repositories.requests.StoryViewerOptions;
import awais.instagrabber.repositories.requests.StoryViewerOptions.Type; import awais.instagrabber.repositories.requests.StoryViewerOptions.Type;
import awais.instagrabber.repositories.requests.directmessages.ThreadIdOrUserIds; import awais.instagrabber.repositories.requests.directmessages.ThreadIdsOrUserIds;
import awais.instagrabber.utils.AppExecutors; import awais.instagrabber.utils.AppExecutors;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils; import awais.instagrabber.utils.CookieUtils;
@ -221,23 +221,11 @@ public class StoryViewerFragment extends Fragment {
final AlertDialog ad = new AlertDialog.Builder(context) final AlertDialog ad = new AlertDialog.Builder(context)
.setTitle(R.string.reply_story) .setTitle(R.string.reply_story)
.setView(input) .setView(input)
.setPositiveButton(R.string.confirm, (d, w) -> directMessagesService.createThread( .setPositiveButton(R.string.confirm, (d, w) -> directMessagesService.broadcastStoryReply(
csrfToken,
userId,
deviceId,
Collections.singletonList(currentStory.getUserId()),
null,
CoroutineUtilsKt.getContinuation((thread, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
if (throwable != null) {
Log.e(TAG, "onOptionsItemSelected: ", throwable);
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
return;
}
directMessagesService.broadcastStoryReply(
csrfToken, csrfToken,
userId, userId,
deviceId, deviceId,
ThreadIdOrUserIds.of(thread.getThreadId()), ThreadIdsOrUserIds.Companion.ofOneUser(String.valueOf(currentStory.getUserId())),
input.getText().toString(), input.getText().toString(),
currentStory.getStoryMediaId(), currentStory.getStoryMediaId(),
String.valueOf(currentStory.getUserId()), String.valueOf(currentStory.getUserId()),
@ -251,9 +239,6 @@ public class StoryViewerFragment extends Fragment {
Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.answered_story, Toast.LENGTH_SHORT).show();
}), Dispatchers.getIO() }), Dispatchers.getIO()
) )
);
}), Dispatchers.getIO())
)) ))
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show(); .show();