From: Radek Czajka Date: Fri, 11 Oct 2024 13:36:32 +0000 (+0200) Subject: Fix error with revision check during saving. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/309ec8b919d57858254b78cd7ba3b4d84d90da9a?ds=inline;hp=da0fee096a166c7fd97857af84d99fe2facfe7f3 Fix error with revision check during saving. --- diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js index 4a28d630..73642ac0 100644 --- a/src/redakcja/static/js/wiki/wikiapi.js +++ b/src/redakcja/static/js/wiki/wikiapi.js @@ -126,6 +126,7 @@ 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; @@ -217,6 +218,7 @@ /* 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), @@ -247,7 +249,7 @@ }); $("#people").html(people); - if (data.rev != self.revision) { + if (!saving && (data.rev != self.revision)) { params.outdated(); } } @@ -375,6 +377,7 @@ data['textsave-text'] = self.text; + self.saving = true; $.ajax({ url: reverse("ajax_document_text", self.id), type: "POST", @@ -392,10 +395,12 @@ 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({ diff --git a/src/team/models.py b/src/team/models.py index 9bd4bf5d..31f44353 100644 --- a/src/team/models.py +++ b/src/team/models.py @@ -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)