From 724787615b623017ca656d4b948927d4f2a39bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Tue, 16 Jan 2018 13:57:44 +0100 Subject: [PATCH] Reset the rooms previous batch if we clear the buffer. --- weechat-matrix.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/weechat-matrix.py b/weechat-matrix.py index 5da1549..a5d6a03 100644 --- a/weechat-matrix.py +++ b/weechat-matrix.py @@ -2041,6 +2041,18 @@ def matrix_fetch_old_messages(server, room_id): return +@utf8_decode +def matrix_command_buf_clear_cb(data, buffer, command): + for server in SERVERS.values(): + if buffer in server.buffers.values(): + room_id = key_from_value(server.buffers, buffer) + server.rooms[room_id].prev_batch = server.next_batch + + return W.WEECHAT_RC_OK + + return W.WEECHAT_RC_OK + + @utf8_decode def matrix_command_pgup_cb(data, buffer, command): for server in SERVERS.values(): @@ -2306,6 +2318,7 @@ def init_hooks(): W.hook_command_run('/topic', 'matrix_command_topic_cb', '') W.hook_command_run('/window page_up', 'matrix_command_pgup_cb', '') + W.hook_command_run('/buffer clear', 'matrix_command_buf_clear_cb', '') def autoconnect(servers):