* event machine fix is critical (long polling has been broken)

* thin upgrade
* work in progress - groups
* fix live-refresh in dev
This commit is contained in:
Sam 2013-04-19 13:06:00 +10:00
parent d0a8cfa6c0
commit de9ca54aed
6 changed files with 21 additions and 13 deletions

View File

@ -165,7 +165,7 @@ GEM
em-redis (0.3.0)
eventmachine
erubis (2.7.0)
eventmachine (1.0.1)
eventmachine (1.0.3)
excon (0.16.10)
execjs (1.4.0)
multi_json (~> 1.0)
@ -452,7 +452,7 @@ GEM
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
thin (1.5.0)
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)

View File

@ -7,7 +7,7 @@
<li>{{#linkTo 'admin.site_settings'}}{{i18n admin.site_settings.title}}{{/linkTo}}</li>
<li>{{#linkTo 'adminSiteContents'}}{{i18n admin.site_content.title}}{{/linkTo}}</li>
<li>{{#linkTo 'adminUsersList.active'}}{{i18n admin.users.title}}{{/linkTo}}</li>
<li>{{#linkTo 'admin.groups'}}{{i18n admin.groups.title}}{{/linkTo}}</li>
<!--<li>{{#linkTo 'admin.groups'}}{{i18n admin.groups.title}}{{/linkTo}}</li>-->
<li>{{#linkTo 'admin.email_logs'}}{{i18n admin.email_logs.title}}{{/linkTo}}</li>
<li>{{#linkTo 'adminFlags.active'}}{{i18n admin.flags.title}}{{/linkTo}}</li>
<li>{{#linkTo 'admin.customize'}}{{i18n admin.customize.title}}{{/linkTo}}</li>

View File

@ -1,3 +1,4 @@
<!-- work in progress, please ignore -->
<div class='row'>
<div class='content-list span6'>
<h3>{{i18n admin.groups.edit}}</h3>
@ -13,8 +14,10 @@
<div class='content-editor'>
{{#if content.active}}
{{#with content.active}}
{{name}}
<h3>{{name}}</h3>
{{view Discourse.UserSelector id="private-message-users" class="span8" placeholderKey="admin.groups.selector_placeholder" tabindex="1" usernamesBinding="usernames"}}
<button>Save</button>
{{/with}}
{{else}}
nothing here yet

View File

@ -205,6 +205,7 @@ Discourse = Ember.Application.createWithMixins({
start: function() {
Discourse.bindDOMEvents();
Discourse.SiteSettings = PreloadStore.get('siteSettings');
Discourse.MessageBus.alwaysLongPoll = Discourse.Environment === "development";
Discourse.MessageBus.start();
Discourse.KeyValueStore.init("discourse_", Discourse.MessageBus);
// Make sure we delete preloaded data

View File

@ -9,7 +9,8 @@
**/
Discourse.MessageBus = (function() {
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
var callbacks, clientId, failCount, interval, isHidden, queue, responseCallbacks, uniqueId;
var callbacks, clientId, failCount, interval, shouldLongPoll, queue, responseCallbacks, uniqueId;
var me;
uniqueId = function() {
return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
@ -27,7 +28,7 @@ Discourse.MessageBus = (function() {
interval = null;
failCount = 0;
isHidden = function() {
var isHidden = function() {
if (document.hidden !== void 0) {
return document.hidden;
} else if (document.webkitHidden !== void 0) {
@ -42,13 +43,17 @@ Discourse.MessageBus = (function() {
}
};
return {
shouldLongPoll = function() {
return me.alwaysLongPoll || !isHidden();
};
me = {
enableLongPolling: true,
callbackInterval: 60000,
maxPollInterval: 3 * 60 * 1000,
callbacks: callbacks,
clientId: clientId,
alwaysLongPoll: false,
stop: false,
// Start polling
@ -68,7 +73,7 @@ Discourse.MessageBus = (function() {
data[c.channel] = c.last_id === void 0 ? -1 : c.last_id;
});
gotData = false;
_this.longPoll = Discourse.ajax(Discourse.getURL("/message-bus/") + clientId + "/poll?" + (isHidden() || !_this.enableLongPolling ? "dlp=t" : ""), {
_this.longPoll = Discourse.ajax(Discourse.getURL("/message-bus/") + clientId + "/poll?" + (!shouldLongPoll() || !_this.enableLongPolling ? "dlp=t" : ""), {
data: data,
cache: false,
dataType: 'json',
@ -101,7 +106,7 @@ Discourse.MessageBus = (function() {
interval = _this.callbackInterval;
if (failCount > 2) {
interval = interval * failCount;
} else if (isHidden()) {
} else if (!shouldLongPoll()) {
// slowning down stuff a lot when hidden
// we will need to add a lot of fine tuning here
interval = interval * 4;
@ -150,4 +155,6 @@ Discourse.MessageBus = (function() {
}
}
};
return me;
})();

View File

@ -1,6 +1,3 @@
// Manifest
//
//= require_tree ./admin