From 103aab3f4a09207e25e2e86daee6d912e27adedd Mon Sep 17 00:00:00 2001 From: j Date: Sat, 2 Feb 2019 18:04:06 +0530 Subject: [PATCH] keep listorder in sync --- oml/library.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oml/library.py b/oml/library.py index 94e30e8..362826d 100644 --- a/oml/library.py +++ b/oml/library.py @@ -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