From 6214e1373cf0715be01de1837daf73cfc5043c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 4 May 2020 17:13:17 +0200 Subject: [PATCH] Remove deletion toast after deletion --- js/imgur.js | 2 +- js/inputbar.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/imgur.js b/js/imgur.js index f743bc3..3162cbc 100644 --- a/js/imgur.js +++ b/js/imgur.js @@ -153,7 +153,7 @@ weechat.factory('imgur', ['$rootScope', 'settings', function($rootScope, setting xhttp.onload = function() { // Check state and response status if(xhttp.status === 200) { - callback(); + callback(deletehash); } else { showErrorMsg(); } diff --git a/js/inputbar.js b/js/inputbar.js index f84afac..b2725f9 100644 --- a/js/inputbar.js +++ b/js/inputbar.js @@ -280,12 +280,20 @@ weechat.directive('inputBar', function() { } }; - var deleteCallback = function () { + var deleteCallback = function (deleteHash) { // Image got sucessfully deleted. // Show toast with delete link var toastDeleted = $compile('
Successfully deleted.
')($scope)[0]; document.body.appendChild(toastDeleted); setTimeout(function() { document.body.removeChild(toastDeleted); }, 5000); + + // Try to remove the toast with the deletion link (it stays 15s + // instead of the 5 of the deletion notification, so it could + // come back beneath it, which would be confusing) + var pasteToast = document.querySelector("[data-imgur-deletehash='" + deleteHash + "']"); + if (!!pasteToast) { + document.body.removeChild(pasteToast); + } } $scope.imgurDelete = function (deleteHash) { @@ -774,7 +782,7 @@ weechat.directive('inputBar', function() { } // Show toast with delete link - var toastImgur = $compile('
Image uploaded to Imgur. Delete?
')($scope)[0]; + var toastImgur = $compile('
Image uploaded to Imgur. Delete?
')($scope)[0]; document.body.appendChild(toastImgur); setTimeout(function() { document.body.removeChild(toastImgur); }, 15000);