keep listorder in sync

This commit is contained in:
j 2019-02-02 18:04:06 +05:30
parent 5f36b2eab4
commit 103aab3f4a

View file

@ -130,16 +130,22 @@ class Peer(object):
self.info['lists'][new['name']] = self.info['lists'].pop(name)
else:
self.info['lists'][new['name']] = []
if name in self.info['listorder']:
self.info['listorder'] = [new['name'] if n == name else n for n in self.info['listorder']]
elif action == 'orderlists':
self.info['listorder'] = args[0]
elif action == 'removelist':
name = args[0]
if name in self.info['lists']:
del self.info['lists'][name]
if name in self.info['listorder']:
self.info['listorder'] = [n for n in self.info['listorder'] if n != name]
elif action == 'addlistitems':
name, ids = args
if name not in self.info['lists']:
self.info['lists'][name] = []
if name not in self.info['listorder']:
self.info['listorder'].append(name)
self.info['lists'][name] = list(set(self.info['lists'][name]) | set(ids))
elif action == 'removelistitems':
name, ids = args