Remove deletion toast after deletion

codeql
Lorenz Hübschle-Schneider 5 years ago
parent 696c08200b
commit 6214e1373c
  1. 2
      js/imgur.js
  2. 12
      js/inputbar.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();
}

@ -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('<div class="toast toast-short">Successfully deleted.</div>')($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('<div class="toast toast-long">Image uploaded to Imgur. <a id="deleteImgur" ng-click="imgurDelete(\'' + deleteHash + '\')" href="">Delete?</a></div>')($scope)[0];
var toastImgur = $compile('<div class="toast toast-long" data-imgur-deletehash=\'' + deleteHash + '\'>Image uploaded to Imgur. <a id="deleteImgur" ng-click="imgurDelete(\'' + deleteHash + '\')" href="">Delete?</a></div>')($scope)[0];
document.body.appendChild(toastImgur);
setTimeout(function() { document.body.removeChild(toastImgur); }, 15000);

Loading…
Cancel
Save