From f2b60d3765185e458096ba96fb0786da2d729fee Mon Sep 17 00:00:00 2001 From: parthiv-m Date: Sun, 13 Oct 2024 17:45:05 -0400 Subject: [PATCH] Add _is_deleted status message to Controller and prompt for button click after paste delete --- js/privatebin.js | 6 +++--- lib/Controller.php | 10 ++++++++++ tpl/bootstrap.php | 7 +++++-- tpl/bootstrap5.php | 11 ++++++++--- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index a5ab23bd..37a077df 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -5626,11 +5626,11 @@ jQuery.PrivateBin = (function($, RawDeflate) { me.initZ(); // if delete token is passed (i.e. paste has been deleted by this - // access), redirect to baseurl after 5 seconds + // access), add an event listener for the 'new' paste button in the alert if (Model.hasDeleteToken()) { - setTimeout(() => { + $("#new-from-alert").on("click", function () { UiHelper.reloadHome(); - }, 5000); + }); return; } diff --git a/lib/Controller.php b/lib/Controller.php index 58d1369d..d07adda2 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -67,6 +67,14 @@ class Controller */ private $_status = ''; + /** + * status message + * + * @access private + * @var boolean + */ + private $_is_deleted = false; + /** * JSON message * @@ -309,6 +317,7 @@ class Controller // Paste exists and deletion token is valid: Delete the paste. $paste->delete(); $this->_status = 'Paste was properly deleted.'; + $this->_is_deleted = true; } else { $this->_error = 'Wrong deletion token. Paste was not deleted.'; } @@ -412,6 +421,7 @@ class Controller } $page->assign('BASEPATH', I18n::_($this->_conf->getKey('basepath'))); $page->assign('STATUS', I18n::_($this->_status)); + $page->assign('ISDELETED', I18n::_(json_encode($this->_is_deleted))); $page->assign('VERSION', self::VERSION); $page->assign('DISCUSSION', $this->_conf->getKey('discussion')); $page->assign('OPENDISCUSSION', $this->_conf->getKey('opendiscussion')); diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 74712355..37ff6f73 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -489,10 +489,13 @@ if ($FILEUPLOAD) : -