Sort support messages differently
This commit is contained in:
parent
d5a3581469
commit
81cbb3f6fe
@ -18,5 +18,10 @@
|
|||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
|
|
||||||
|
.cp-support-container {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -170,10 +170,36 @@ define([
|
|||||||
var supportKey = ApiConfig.supportMailbox;
|
var supportKey = ApiConfig.supportMailbox;
|
||||||
create['support-list'] = function () {
|
create['support-list'] = function () {
|
||||||
if (!supportKey || !APP.privateKey) { return; }
|
if (!supportKey || !APP.privateKey) { return; }
|
||||||
var $div = makeBlock('support-list');
|
var $container = makeBlock('support-list');
|
||||||
$div.addClass('cp-support-container');
|
var $div = $(h('div.cp-support-container')).appendTo($container);
|
||||||
var hashesById = {};
|
var hashesById = {};
|
||||||
|
|
||||||
|
var reorder = function () {
|
||||||
|
var order = Object.keys(hashesById);
|
||||||
|
order.sort(function (id1, id2) {
|
||||||
|
var t1 = hashesById[id1];
|
||||||
|
var t2 = hashesById[id2];
|
||||||
|
if (!Array.isArray(t1)) { return 1; }
|
||||||
|
if (!Array.isArray(t2)) { return -1; }
|
||||||
|
var lastMsg1 = t1[t1.length - 1];
|
||||||
|
var lastMsg2 = t2[t2.length - 1];
|
||||||
|
var time1 = Util.find(lastMsg1, ['content', 'msg', 'content', 'time']);
|
||||||
|
var time2 = Util.find(lastMsg2, ['content', 'msg', 'content', 'time']);
|
||||||
|
var authorEd1 = Util.find(lastMsg1, ['content', 'msg', 'content', 'sender', 'edPublic']);
|
||||||
|
var authorEd2 = Util.find(lastMsg2, ['content', 'msg', 'content', 'sender', 'edPublic']);
|
||||||
|
var admin1 = ApiConfig.adminKeys.indexOf(authorEd1) !== -1;
|
||||||
|
var admin2 = ApiConfig.adminKeys.indexOf(authorEd2) !== -1;
|
||||||
|
// If one is answered and not the other, put the unanswered first
|
||||||
|
if (admin1 && !admin2) { return 1; }
|
||||||
|
if (!admin1 && admin2) { return -1; }
|
||||||
|
// Otherwise, sort them by time
|
||||||
|
return time2 - time1;
|
||||||
|
});
|
||||||
|
order.forEach(function (id, i) {
|
||||||
|
$div.find('[data-id="'+id+'"]').css('order', i);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Register to the "support" mailbox
|
// Register to the "support" mailbox
|
||||||
common.mailbox.subscribe(['supportadmin'], {
|
common.mailbox.subscribe(['supportadmin'], {
|
||||||
onMessage: function (data) {
|
onMessage: function (data) {
|
||||||
@ -219,11 +245,13 @@ define([
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
$ticket.append(APP.support.makeMessage(content, hash));
|
$ticket.append(APP.support.makeMessage(content, hash));
|
||||||
|
reorder();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return $div;
|
return $container;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var checkAdminKey = function (priv) {
|
var checkAdminKey = function (priv) {
|
||||||
if (!supportKey) { return; }
|
if (!supportKey) { return; }
|
||||||
return Hash.checkBoxKeyPair(priv, supportKey);
|
return Hash.checkBoxKeyPair(priv, supportKey);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user