From 0b1ad7a02a4b3120d6f52bc28bd433b5ff7ef6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 19 Apr 2012 15:01:38 +0200 Subject: [PATCH] Make only one Message-loading attempt at a time. --- file/js/be.bastelstu.WCF.Chat.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/file/js/be.bastelstu.WCF.Chat.coffee b/file/js/be.bastelstu.WCF.Chat.coffee index e93082e..bff3843 100644 --- a/file/js/be.bastelstu.WCF.Chat.coffee +++ b/file/js/be.bastelstu.WCF.Chat.coffee @@ -23,6 +23,9 @@ consoleMock ?= # TODO: We need an explosion animation shields: 3 + # Are we currently loading messages? + loading: false + # Templates titleTemplate: null messageTemplate: null @@ -209,7 +212,7 @@ consoleMock ?= # inclusive the error-message :) window.location.reload true beforeSend: $.proxy(() -> - return false if @loading or target.parent().hasClass 'activeMenuItem' + return false if target.parent().hasClass('ajaxLoad') or target.parent().hasClass 'activeMenuItem' @loading = true target.parent().addClass 'ajaxLoad' @@ -254,6 +257,7 @@ consoleMock ?= dataType: 'json' type: 'POST' success: $.proxy((data, textStatus, jqXHR) -> + @loading = false @handleMessages(data.messages) @handleUsers(data.users) , @) @@ -266,6 +270,11 @@ consoleMock ?= console.error '[be.bastelstu.WCF.Chat] We got destroyed, but could free our friend the fish before he was killed as well. Have a nice life in freedom!' alert 'herp i cannot load messages' , @) + beforeSend: $.proxy(() -> + return false if @loading + + @loading = true + , @) ### # Inserts the new messages. #