Use buffer localvars instead of regex hackery

Fixes #589
This commit is contained in:
Lorenz Hübschle-Schneider 2015-12-05 13:58:02 +01:00
commit ceceac78a2
3 changed files with 19 additions and 4 deletions

View file

@ -84,13 +84,22 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
var notification = 0;
var unread = 0;
var lastSeen = -1;
var serverSortKey = fullName.replace(/^irc\.server\.(\w+)/, "irc.$1").toLowerCase();
// There are two kinds of types: bufferType (free vs formatted) and
// the kind of type that distinguishes queries from channels etc
var bufferType = message.type;
var type = message.local_variables.type;
var indent = (['channel', 'private'].indexOf(type) >= 0);
var plugin = message.local_variables.plugin;
var server = message.local_variables.server;
// Server buffers have this "irc.server.freenode" naming schema, which
// messes the sorting up. We need it to be "irc.freenode" instead.
var serverSortKey = plugin + "." + server +
(type === "server" ? "" : ("." + shortName));
// Lowercase it so alt+up/down traverses buffers in the same order
// angular's sortBy directive puts them in
serverSortKey = serverSortKey.toLowerCase();
// Buffer opened message does not include notify level
if (message.notify !== undefined) {
notify = message.notify;
@ -316,6 +325,8 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
indent: indent,
bufferType: bufferType,
type: type,
plugin: plugin,
server: server,
history: history,
addToHistory: addToHistory,
getHistoryUp: getHistoryUp,