Quicksand - make notification and message counts update as you navigate around

Summary: Ref T7573. Unify code to fetch these counts and do some light formatting since we're going to need to do the same thing for some conpherence-specific ajax in the durable column (See T7708).

Test Plan: loaded up two tabs, one with a durable column on and one without. in the without browser, i read some messages, decrementing my unread count. when i navigated again in the durable column browser, the count updated correctly. with no notifications, commented on a task with another user to get a notification and it showed up properly. visited the task by clicking not the notification and the bubble count decremented correctly

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7573

Differential Revision: https://secure.phabricator.com/D12498
This commit is contained in:
Bob Trahan
2015-04-21 15:46:36 -07:00
parent c509e80a74
commit dd9ec255ec
7 changed files with 185 additions and 50 deletions

View File

@@ -28,6 +28,17 @@ JX.behavior('aphlict-dropdown', function(config, statics) {
JX.Title.setCount(config.countType, config.countNumber);
function _updateCount(number) {
JX.Title.setCount(config.countType, number);
JX.DOM.setContent(count, number);
if (number === 0) {
JX.DOM.alterClass(bubble, config.unreadClass, false);
} else {
JX.DOM.alterClass(bubble, config.unreadClass, true);
}
}
function refresh() {
if (dirty) {
JX.DOM.setContent(dropdown, config.loadingText);
@@ -43,16 +54,8 @@ JX.behavior('aphlict-dropdown', function(config, statics) {
}
request = new JX.Request(config.uri, function(response) {
JX.Title.setCount(config.countType, response.number);
var display = (response.number > 999) ? '\u221E' : response.number;
JX.DOM.setContent(count, display);
if (response.number === 0) {
JX.DOM.alterClass(bubble, config.unreadClass, false);
} else {
JX.DOM.alterClass(bubble, config.unreadClass, true);
}
var number = response.number;
_updateCount(number);
dirty = false;
JX.DOM.alterClass(
dropdown,
@@ -64,6 +67,35 @@ JX.behavior('aphlict-dropdown', function(config, statics) {
request.send();
}
JX.Stratcom.listen(
'quicksand-redraw',
null,
function (e) {
if (config.local) {
return;
}
var data = e.getData();
if (!data.fromServer) {
return;
}
var updated = false;
var new_data = data.newResponse.aphlictDropdownData;
for (var ii = 0; ii < new_data.length; ii++) {
if (new_data[ii].countType != config.countType) {
continue;
}
if (!new_data[ii].isInstalled) {
continue;
}
updated = true;
_updateCount(parseInt(new_data[ii].count));
}
if (updated) {
dirty = true;
}
});
function set_visible(menu, icon) {
if (menu) {
statics.visible = {menu: menu, icon: icon};