Fix error with revision check during saving.
authorRadek Czajka <rczajka@rczajka.pl>
Fri, 11 Oct 2024 13:36:32 +0000 (15:36 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Fri, 11 Oct 2024 13:36:32 +0000 (15:36 +0200)
src/redakcja/static/js/wiki/wikiapi.js
src/team/models.py

index 4a28d63..73642ac 100644 (file)
             this.fullUri = $("*[data-key='full-uri']", meta).text();
 
            this.text = null;
+            this.saving = false;
            this.has_local_changes = false;
             this.active = new Date();
            this._lock = -1;
             /* this doesn't modify anything, so no locks */
             var self = this;
             let active = new Date() - self.active < 30 * 1000;
+            let saving = self.saving;
             $.ajax({
                 method: "GET",
                 url: reverse("ajax_document_rev", self.id),
                         });
                         $("#people").html(people);
 
-                        if (data.rev != self.revision) {
+                        if (!saving && (data.rev != self.revision)) {
                             params.outdated();
                         }
                    }
 
            data['textsave-text'] = self.text;
 
+            self.saving = true;
            $.ajax({
                url: reverse("ajax_document_text", self.id),
                type: "POST",
                        changed = true;
                        self.triggerDocumentChanged();
                    };
+                    self.saving = false;
 
                    params['success'](self, changed, ((changed && "Udało się zapisać :)") || "Twoja wersja i serwera jest identyczna"));
                },
                error: function(xhr) {
+                    self.saving = false;
                     if ($('#header').hasClass('saving')) {
                         $('#header').removeClass('saving');
                         $.blockUI({
index 9bd4bf5..31f4435 100644 (file)
@@ -17,7 +17,7 @@ class Profile(models.Model):
 
 
 class Presence(models.Model):
-    GAP_THRESHOLD = 60
+    GAP_THRESHOLD = 10
 
     user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE, null=True, blank=True)
     session_key = models.CharField(max_length=255)