weechat-matrix: Fetch from the backlog if the buffer has < 10 lines at startup.

This commit is contained in:
Damir Jelić 2019-09-11 13:48:10 +02:00
parent f48a69a6b6
commit e5f6b597af
2 changed files with 9 additions and 1 deletions

View file

@ -578,7 +578,9 @@ def buffer_switch_cb(_, _signal, buffer_ptr):
# The buffer is empty and we are seeing it for the first time. # 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 # Let us fetch some messages from the room history so it doesn't feel so
# empty. # 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): if server.room_get_messages(room_buffer.room.room_id):
room_buffer.first_view = True room_buffer.first_view = True

View file

@ -446,6 +446,12 @@ class WeechatChannelBuffer(object):
"""Get the bar item input text of the buffer.""" """Get the bar item input text of the buffer."""
return W.buffer_get_string(self._ptr, "input") 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 @property
def lines(self): def lines(self):
own_lines = W.hdata_pointer(self._hdata, self._ptr, "own_lines") own_lines = W.hdata_pointer(self._hdata, self._ptr, "own_lines")