Fix server buffer merging if no server buffers are created.

This commit is contained in:
poljar (Damir Jelić) 2018-02-07 12:43:35 +01:00
parent 90c63c197c
commit e39fa57f83
2 changed files with 11 additions and 5 deletions

View file

@ -45,7 +45,8 @@ def matrix_config_change_cb(data, option):
OPTIONS.look_server_buf = ServerBufferType(
W.config_integer(option))
for server in SERVERS.values():
server_buffer_merge(server.server_buffer)
if server.server_buffer:
server_buffer_merge(server.server_buffer)
elif option_name == "max_initial_sync_events":
OPTIONS.sync_limit = W.config_integer(option)

View file

@ -84,10 +84,15 @@ def server_buffer_merge(buffer):
W.buffer_merge(buffer, W.buffer_search_main())
elif OPTIONS.look_server_buf == ServerBufferType.MERGE:
if SERVERS:
first = list(SERVERS.values())[0].server_buffer
num = W.buffer_get_integer(W.buffer_search_main(), "number")
W.buffer_unmerge(buffer, num + 1)
W.buffer_merge(buffer, first)
first = None
for server in SERVERS.values():
if server.server_buffer and buffer is not server.server_buffer:
first = server.server_buffer
break
if first:
num = W.buffer_get_integer(W.buffer_search_main(), "number")
W.buffer_unmerge(buffer, num + 1)
W.buffer_merge(buffer, first)
else:
num = W.buffer_get_integer(W.buffer_search_main(), "number")
W.buffer_unmerge(buffer, num + 1)