Kaynağa Gözat

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

rugk 3 ay önce
ebeveyn
işleme
bdf5c4768a
1 değiştirilmiş dosya ile 10 ekleme ve 14 silme
  1. 10 14
      js/privatebin.js

+ 10 - 14
js/privatebin.js

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