mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-26 21:45:52 +01:00
fix(YouTube - SponsorBlock): Show a toast and not a dialog if segment submitted successfully
This commit is contained in:
parent
ed83a2cb4c
commit
134b189791
@ -150,11 +150,16 @@ public class SBRequester {
|
|||||||
String end = String.format(Locale.US, TIME_TEMPLATE, endTime / 1000f);
|
String end = String.format(Locale.US, TIME_TEMPLATE, endTime / 1000f);
|
||||||
String duration = String.format(Locale.US, TIME_TEMPLATE, videoLength / 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();
|
final int responseCode = connection.getResponseCode();
|
||||||
|
|
||||||
String userMessage = switch (responseCode) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
case HTTP_STATUS_CODE_SUCCESS -> str("revanced_sb_submit_succeeded");
|
Utils.showToastLong(str("revanced_sb_submit_succeeded"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String userErrorMessage = switch (responseCode) {
|
||||||
case 409 -> str("revanced_sb_submit_failed_duplicate");
|
case 409 -> str("revanced_sb_submit_failed_duplicate");
|
||||||
case 403 -> str("revanced_sb_submit_failed_forbidden",
|
case 403 -> str("revanced_sb_submit_failed_forbidden",
|
||||||
Requester.parseErrorStringAndDisconnect(connection));
|
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.
|
// Message might be about the users account or an error too large to show in a toast.
|
||||||
// Use a dialog instead.
|
// Use a dialog instead.
|
||||||
SponsorBlockUtils.showErrorDialog(userMessage);
|
SponsorBlockUtils.showErrorDialog(userErrorMessage);
|
||||||
} catch (SocketTimeoutException ex) {
|
} catch (SocketTimeoutException ex) {
|
||||||
Logger.printDebug(() -> "Timeout", ex);
|
Logger.printDebug(() -> "Timeout", ex);
|
||||||
Utils.showToastLong(str("revanced_sb_submit_failed_timeout"));
|
Utils.showToastLong(str("revanced_sb_submit_failed_timeout"));
|
||||||
|
Loading…
Reference in New Issue
Block a user