فهرست منبع

refactor: no need to revert stuff if we can just check for null before start

rugk 3 ماه پیش
والد
کامیت
bdf5c4768a
1فایلهای تغییر یافته به همراه10 افزوده شده و 14 حذف شده
  1. 10 14
      js/privatebin.js

+ 10 - 14
js/privatebin.js

@@ -5136,27 +5136,23 @@ window.PrivateBin = (function () {
          * @function
          */
         me.sendComment = async function () {
-            Alert.hideMessages();
-            Alert.setCustomHandler(DiscussionViewer.handleNotification);
-
-            // UI loading state
-            TopNav.hideAllButtons();
-            Alert.showLoading('Sending comment…', 'cloud-upload');
-
             // get data
-            const plainText = DiscussionViewer.getReplyMessage(),
-                nickname = DiscussionViewer.getReplyNickname(),
-                parentid = DiscussionViewer.getReplyCommentId();
+            const plainText = DiscussionViewer.getReplyMessage();
 
             // do not send if there is no data
             if (plainText.length === 0) {
-                // revert loading status…
-                Alert.hideLoading();
-                Alert.setCustomHandler(null);
-                TopNav.showViewButtons();
                 return;
             }
 
+            let nickname = DiscussionViewer.getReplyNickname(),
+                parentid = DiscussionViewer.getReplyCommentId();
+
+            Alert.hideMessages();
+            Alert.setCustomHandler(DiscussionViewer.handleNotification);
+
+            // UI loading state
+            TopNav.hideAllButtons();
+            Alert.showLoading('Sending comment…', 'cloud-upload');
             // prepare server interaction
             ServerInteraction.prepare();
             ServerInteraction.setCryptParameters(Prompt.getPassword(), Model.getPasteKey());