local peers should always be online

This commit is contained in:
j 2016-02-07 13:55:12 +05:30
parent 828705923c
commit d799e690b5
4 changed files with 9 additions and 1 deletions

View file

@ -117,6 +117,7 @@ def getUsers(data):
''' '''
users = [] users = []
ids = set() ids = set()
local = set()
for u in models.User.query.filter(models.User.id!=settings.USER_ID).all(): for u in models.User.query.filter(models.User.id!=settings.USER_ID).all():
users.append(u.json()) users.append(u.json())
ids.add(u.id) ids.add(u.id)
@ -127,6 +128,10 @@ def getUsers(data):
n['online'] = True n['online'] = True
n['name'] = n['username'] n['name'] = n['username']
users.append(n) users.append(n)
local.add(id)
for n in users:
n['local'] = n['id'] in local
users.sort(key=lambda u: ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or ''))) users.sort(key=lambda u: ox.sort_string(str(u.get('index', '')) + 'Z' + (u.get('name') or '')))
return { return {
"users": users "users": users

View file

@ -2,7 +2,6 @@
# vi:si:et:sw=4:sts=4:ts=4 # vi:si:et:sw=4:sts=4:ts=4
from datetime import datetime from datetime import datetime
import json import json
import hashlib
import os import os
import shutil import shutil

View file

@ -490,6 +490,7 @@ oml.ui.peersPanel = function() {
} }
], ],
items: folder.items, items: folder.items,
keys: ['local'],
max: 1, max: 1,
sort: [{key: 'index', operator: '+'}], sort: [{key: 'index', operator: '+'}],
sortable: folder.id == 'peers', sortable: folder.id == 'peers',

View file

@ -45,6 +45,9 @@ oml.ui.statusIcon = function(user, index) {
if (user.id != oml.user.id && data.id == oml.user.id && data.online) { if (user.id != oml.user.id && data.id == oml.user.id && data.online) {
return status == 'unknown' ? 'disconnected' : status; return status == 'unknown' ? 'disconnected' : status;
} }
if (data.local) {
return 'connected';
}
if (!oml.user.online) { if (!oml.user.online) {
return 'unknown'; return 'unknown';
} }