Commit a548e2ff authored by mathieui's avatar mathieui

Improve refresh performance in big rooms

going through a list with more than 1000 elements, one at a time, can be
a bit tedious. Especially if you go through it every time you receive
one of those elements.
parent d19f53c3
......@@ -532,7 +532,7 @@ class HandlerCore:
if tab is self.core.current_tab():
tab.text_win.refresh()
tab.info_header.refresh(tab, tab.text_win)
tab.info_header.refresh(tab, tab.text_win, user=tab.own_user)
tab.input.refresh()
self.core.doupdate()
elif tab.state != old_state:
......
......@@ -59,6 +59,7 @@ class MucTab(ChatTab):
if self.joined == False:
self._state = 'disconnected'
self.own_nick = nick
self.own_user = None
self.name = jid
self.password = password
self.users = []
......@@ -958,7 +959,7 @@ class MucTab(ChatTab):
if display_user_list:
self.v_separator.refresh()
self.user_win.refresh(self.users)
self.info_header.refresh(self, self.text_win)
self.info_header.refresh(self, self.text_win, user=self.own_user)
self.refresh_tab_win()
if display_info_win:
self.info_win.refresh()
......@@ -1096,6 +1097,7 @@ class MucTab(ChatTab):
# ejabberd or every gateway in the world that just do
# not send a 110 status code with the presence
self.own_nick = from_nick
self.own_user = new_user
self.joined = True
if self.name in self.core.initial_joins:
self.core.initial_joins.remove(self.name)
......@@ -1201,7 +1203,7 @@ class MucTab(ChatTab):
if self.core.current_tab() is self:
self.text_win.refresh()
self.user_win.refresh_if_changed(self.users)
self.info_header.refresh(self, self.text_win)
self.info_header.refresh(self, self.text_win, user=self.own_user)
self.input.refresh()
self.core.doupdate()
......
......@@ -213,14 +213,14 @@ class MucInfoWin(InfoWin):
def __init__(self):
InfoWin.__init__(self)
def refresh(self, room, window=None):
def refresh(self, room, window=None, user=None):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
self.write_room_name(room)
self.write_participants_number(room)
self.write_own_nick(room)
self.write_disconnected(room)
self.write_role(room)
self.write_role(room, user)
if window:
self.print_scroll_position(window)
self.finish_line(get_theme().COLOR_INFORMATION_BAR)
......@@ -252,21 +252,16 @@ class MucInfoWin(InfoWin):
return
self.addstr(truncate_nick(nick, 13), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
def write_role(self, room):
def write_role(self, room, user):
"""
Write our own role and affiliation
"""
own_user = None
for user in room.users:
if user.nick == room.own_nick:
own_user = user
break
if not own_user:
if not user:
return
txt = ' ('
if own_user.affiliation != 'none':
txt += own_user.affiliation+', '
txt += own_user.role+')'
if user.affiliation != 'none':
txt += user.affiliation + ', '
txt += user.role + ')'
self.addstr(txt, to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
class ConversationStatusMessageWin(InfoWin):
......
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