From 134b189791113dcf1a1cb7c87b8a0954f432730c Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:31:41 +0400 Subject: [PATCH] fix(YouTube - SponsorBlock): Show a toast and not a dialog if segment submitted successfully --- .../youtube/sponsorblock/requests/SBRequester.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/requests/SBRequester.java b/extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/requests/SBRequester.java index 6a36a2525..445b711dc 100644 --- a/extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/requests/SBRequester.java +++ b/extensions/youtube/src/main/java/app/revanced/extension/youtube/sponsorblock/requests/SBRequester.java @@ -150,11 +150,16 @@ public class SBRequester { String end = String.format(Locale.US, TIME_TEMPLATE, endTime / 1000f); String duration = String.format(Locale.US, TIME_TEMPLATE, videoLength / 1000f); - HttpURLConnection connection = getConnectionFromRoute(SBRoutes.SUBMIT_SEGMENTS, privateUserId, videoId, category, start, end, duration); + HttpURLConnection connection = getConnectionFromRoute(SBRoutes.SUBMIT_SEGMENTS, + privateUserId, videoId, category, start, end, duration); final int responseCode = connection.getResponseCode(); - String userMessage = switch (responseCode) { - case HTTP_STATUS_CODE_SUCCESS -> str("revanced_sb_submit_succeeded"); + if (responseCode == HTTP_STATUS_CODE_SUCCESS) { + Utils.showToastLong(str("revanced_sb_submit_succeeded")); + return; + } + + String userErrorMessage = switch (responseCode) { case 409 -> str("revanced_sb_submit_failed_duplicate"); case 403 -> str("revanced_sb_submit_failed_forbidden", Requester.parseErrorStringAndDisconnect(connection)); @@ -167,7 +172,7 @@ public class SBRequester { // Message might be about the users account or an error too large to show in a toast. // Use a dialog instead. - SponsorBlockUtils.showErrorDialog(userMessage); + SponsorBlockUtils.showErrorDialog(userErrorMessage); } catch (SocketTimeoutException ex) { Logger.printDebug(() -> "Timeout", ex); Utils.showToastLong(str("revanced_sb_submit_failed_timeout"));