Commit 93ab723d authored by Elizabeth Myers's avatar Elizabeth Myers 💬
Browse files

Fixes and such

parent 0a4aca94
......@@ -115,6 +115,12 @@ class NetworkConnection:
self.add_text_to_buf('', f'* Disconnected from {self.name}')
self.src = '@'
for i in reversed(range(self.tree_children[''].childCount())):
self.tree_children[''].removeChild(self.tree_children[''].child(i))
self.text_bufs = dict()
self.member_bufs = dict()
def error(self, e):
err = self.socket.errorString()
self.add_text_to_buf('', f'* Socket error ({err}), trying to reconnect')
......@@ -132,16 +138,29 @@ class NetworkConnection:
if frame.dst[0] == '@':
for group in frame.data.get('groups', []):
self.add_buf(group)
elif t == 'listmembers':
if frame.dst not in self.member_bufs:
return
if 'members' in frame.data:
if self.window.current_buf == (self, frame.dst):
for member in frame.data['members']:
if member not in self.member_bufs[frame.dst]:
self.window.list_widget.addItem(member)
self.member_bufs[frame.dst].add(member)
elif t == 'login':
self.src = frame.dst
self.send(Frame.create(self.src, self.src, 'listgroups'))
elif t == 'join':
if frame.dst not in self.member_bufs:
print(frame.dst)
return
if 'members' in frame.data:
self.member_bufs[frame.dst].update(frame.data['members'])
if self.window.current_buf == (self, frame.dst):
for member in frame.data['members']:
if member not in self.member_bufs[frame.dst]:
self.window.list_widget.addItem(member)
self.member_bufs[frame.dst].add(member)
else:
self.member_bufs[frame.dst].add(frame.src)
......@@ -246,10 +265,8 @@ class MainWindow(QMainWindow):
def on_tree_double_click(self, item, column):
if item.parent() == None:
print("Switching buf to parent")
self.connection.switch_buf('')
else:
print("Switching to", item.text(0))
self.connection.switch_buf(item.text(0))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment