username
diff --git a/src/js/glowingbear.js b/src/js/glowingbear.js
index f9eaf9e..3af6701 100644
--- a/src/js/glowingbear.js
+++ b/src/js/glowingbear.js
@@ -4,6 +4,7 @@ import * as Favico from "favico.js";
import { connectionFactory } from './connection';
+import { sortBy } from './misc';
/* debounce helper so we dont have to use underscore.js */
const debounce = function (func, wait, immediate) {
@@ -19,10 +20,6 @@ const debounce = function (func, wait, immediate) {
};
};
-const sortBy = (key) => {
- return (a, b) => (a[key] > b[key]) ? 1 : ((b[key] > a[key]) ? -1 : 0);
-};
-
var weechat = angular.module('weechat', ['ngRoute', 'localStorage', 'weechatModels', 'bufferResume', 'plugins', 'IrcUtils', 'ngSanitize', 'ngWebsockets', 'ngTouch'], ['$compileProvider', function($compileProvider) {
// hacky way to be able to find out if we're in debug mode
weechat.compileProvider = $compileProvider;
diff --git a/src/js/inputbar.js b/src/js/inputbar.js
index 29f43d4..f6ba2b4 100644
--- a/src/js/inputbar.js
+++ b/src/js/inputbar.js
@@ -104,7 +104,7 @@ weechat.directive('inputBar', function() {
var completion_suffix = models.wconfig['weechat.completion.nick_completer'];
var add_space = models.wconfig['weechat.completion.nick_add_space'];
var nickComp = IrcUtils.completeNick(input, caretPos, $scope.iterCandidate,
- activeBuffer.getNicklistByTime(),
+ activeBuffer.getNicklistByTime().reverse(),
completion_suffix, add_space);
// remember iteration candidate
diff --git a/src/js/irc-utils.js b/src/js/irc-utils.js
index d3e0ae6..9199b9e 100644
--- a/src/js/irc-utils.js
+++ b/src/js/irc-utils.js
@@ -16,19 +16,6 @@ IrcUtils.service('IrcUtils', [function() {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
- /**
- * Get a new version of a nick list
- *
- * @param nickList Original nick list
- * @return list of nick names
- */
- var _ciNickList = function(nickList) {
-
- let newList = nickList.map((el) => el.name);
-
- return newList;
- };
-
/**
* Completes a single nick.
*
@@ -118,7 +105,7 @@ IrcUtils.service('IrcUtils', [function() {
var addSpaceChar = (addSpace === undefined || addSpace === 'on') ? ' ' : '';
// new nick list to search in
- var searchNickList = _ciNickList(nickList);
+ var searchNickList = nickList.map((el) => el.name);
// text before and after caret
var beforeCaret = text.substring(0, caretPos);
diff --git a/src/js/misc.js b/src/js/misc.js
new file mode 100644
index 0000000..9894874
--- /dev/null
+++ b/src/js/misc.js
@@ -0,0 +1,5 @@
+'use strict';
+
+export const sortBy = (key) => {
+ return (a, b) => (a[key] > b[key]) ? 1 : ((b[key] > a[key]) ? -1 : 0);
+}
diff --git a/src/js/models.js b/src/js/models.js
index 49b2e5e..c099616 100644
--- a/src/js/models.js
+++ b/src/js/models.js
@@ -7,6 +7,7 @@
import * as weeChat from './weechat';
+import { sortBy } from './misc';
var models = angular.module('weechatModels', []);
@@ -219,9 +220,10 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
}
for (let groupIdx in nicklist) {
let nicks = nicklist[groupIdx].nicks;
- for (let nickIdx in nicks) {
- if (nicks[nickIdx].name === nick) {
- nicks[nickIdx].spokeAt = Date.now();
+ for (let curr_nick of nicks) {
+ if (curr_nick.name === nick) {
+ curr_nick.spokeAt = Date.now();
+ return;
}
}
}
@@ -235,15 +237,10 @@ models.service('models', ['$rootScope', '$filter', 'bufferResume', function($roo
var getNicklistByTime = function() {
var newlist = [];
for (let groupIdx in nicklist) {
- let nicks = nicklist[groupIdx].nicks;
- for (let nickIdx in nicks) {
- newlist.push(nicks[nickIdx]);
- }
+ newlist = newlist.concat(nicklist[groupIdx].nicks);
}
- newlist.sort(function(a, b) {
- return a.spokeAt < b.spokeAt;
- });
+ newlist.sort(sortBy('spokeAt'));
return newlist;
};
diff --git a/src/manifest.json b/src/manifest.json
index f651645..c7dc41e 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,7 +1,7 @@
{
"name": "Glowing Bear",
"description": "WeeChat Web frontend",
- "version": "0.11.0",
+ "version": "0.10.0",
"manifest_version": 2,
"icons": {
"32": "assets/img/favicon.png",
diff --git a/src/manifest.webapp b/src/manifest.webapp
index 5d26c1e..246406a 100644
--- a/src/manifest.webapp
+++ b/src/manifest.webapp
@@ -25,5 +25,5 @@
"desktop-notification":{}
},
"default_locale": "en",
- "version": "0.11.0"
+ "version": "0.10.0"
}