diff --git a/main.py b/main.py index dfe8535..9d61759 100644 --- a/main.py +++ b/main.py @@ -578,7 +578,9 @@ def buffer_switch_cb(_, _signal, buffer_ptr): # The buffer is empty and we are seeing it for the first time. # Let us fetch some messages from the room history so it doesn't feel so # empty. - if room_buffer.first_view and not last_event_id: + if room_buffer.first_view and room_buffer.weechat_buffer.num_lines < 10: + # TODO we may want to fetch 10 - num_lines messages here for + # consistency reasons. if server.room_get_messages(room_buffer.room.room_id): room_buffer.first_view = True diff --git a/matrix/buffer.py b/matrix/buffer.py index dab8f08..09518fc 100644 --- a/matrix/buffer.py +++ b/matrix/buffer.py @@ -446,6 +446,12 @@ class WeechatChannelBuffer(object): """Get the bar item input text of the buffer.""" return W.buffer_get_string(self._ptr, "input") + @property + def num_lines(self): + own_lines = W.hdata_pointer(self._hdata, self._ptr, "own_lines") + return W.hdata_integer(W.hdata_get("lines"), own_lines, "lines_count") + + @property def lines(self): own_lines = W.hdata_pointer(self._hdata, self._ptr, "own_lines")