diff --git a/main.py b/main.py index 694896d..1eb57b0 100644 --- a/main.py +++ b/main.py @@ -53,7 +53,8 @@ from matrix.server import ( ) from matrix.bar_items import (init_bar_items, matrix_bar_item_name, - matrix_bar_item_plugin, matrix_bar_item_lag) + matrix_bar_item_plugin, matrix_bar_item_lag, + matrix_bar_item_buffer_modes) from matrix.completion import ( init_completion, matrix_command_completion_cb, diff --git a/matrix/bar_items.py b/matrix/bar_items.py index 3958483..db67a3c 100644 --- a/matrix/bar_items.py +++ b/matrix/bar_items.py @@ -85,7 +85,28 @@ def matrix_bar_item_lag(data, item, window, buffer, extra_info): return "" +@utf8_decode +def matrix_bar_item_buffer_modes(data, item, window, buffer, extra_info): + # pylint: disable=unused-argument + for server in SERVERS.values(): + if buffer in server.buffers.values(): + room_id = key_from_value(server.buffers, buffer) + room = server.rooms[room_id] + modes = [] + + if room.encrypted: + modes.append("🔐") + + if room.backlog_pending: + modes.append("⏳") + + return "".join(modes) + + return "" + + def init_bar_items(): W.bar_item_new("(extra)buffer_plugin", "matrix_bar_item_plugin", "") W.bar_item_new("(extra)buffer_name", "matrix_bar_item_name", "") W.bar_item_new("(extra)lag", "matrix_bar_item_lag", "") + W.bar_item_new("(extra)buffer_modes", "matrix_bar_item_buffer_modes", "") diff --git a/matrix/commands.py b/matrix/commands.py index dacd4e7..759d2bd 100644 --- a/matrix/commands.py +++ b/matrix/commands.py @@ -109,6 +109,7 @@ def matrix_fetch_old_messages(server, room_id): token=prev_batch, limit=OPTIONS.backlog_limit) room.backlog_pending = True + W.bar_item_update("buffer_modes") server.send_or_queue(message) diff --git a/matrix/events.py b/matrix/events.py index cb84365..ad241a3 100644 --- a/matrix/events.py +++ b/matrix/events.py @@ -344,6 +344,7 @@ class MatrixBacklogEvent(MatrixEvent): room.prev_batch = self.end_token room.backlog_pending = False + W.bar_item_update("buffer_modes") class MatrixSyncEvent(MatrixEvent):