FIX: Composer doesn't show an error message in case of a network issue and stops updating draft after (#13268)

FIX: Composer doesn’t show an error message in case of a network issue and stops updating draft after (#13268)

diff --git a/app/assets/javascripts/discourse/app/lib/ajax.js b/app/assets/javascripts/discourse/app/lib/ajax.js
index a47ed55..48b690c 100644
--- a/app/assets/javascripts/discourse/app/lib/ajax.js
+++ b/app/assets/javascripts/discourse/app/lib/ajax.js
@@ -70,6 +70,12 @@ export function ajax() {
     args = arguments[1];
   }
 
+  let ignoreUnsent = true;
+  if (args.ignoreUnsent !== undefined) {
+    ignoreUnsent = args.ignoreUnsent;
+    delete args.ignoreUnsent;
+  }
+
   function performAjax(resolve, reject) {
     args.headers = args.headers || {};
 
@@ -112,7 +118,7 @@ export function ajax() {
 
     args.error = (xhr, textStatus, errorThrown) => {
       // 0 represents the `UNSENT` state
-      if (xhr.readyState === 0) {
+      if (ignoreUnsent && xhr.readyState === 0) {
         // Make sure we log pretender errors in test mode
         if (textStatus === "error" && isTesting()) {
           throw errorThrown;
diff --git a/app/assets/javascripts/discourse/app/models/draft.js b/app/assets/javascripts/discourse/app/models/draft.js
index 5406c7f..37dda0b 100644
--- a/app/assets/javascripts/discourse/app/models/draft.js
+++ b/app/assets/javascripts/discourse/app/models/draft.js
@@ -34,6 +34,7 @@ Draft.reopenClass({
         owner: clientId,
         force_save: forceSave,
       },
+      ignoreUnsent: false,
     });
   },
 });

GitHub sha: 476dfaed

This commit appears in #13268 which was approved by pmusaraj. It was merged by AndrewPrigorshnev.