From 3d957013f7ec769e5893d903b68cae0cbd8e1666 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 3 May 2022 19:48:18 +0800 Subject: [PATCH] feat(gitter): display more message about connection process --- bundle/vim-chat/autoload/chat/gitter.vim | 17 +++++++++++++++++ bundle/vim-chat/autoload/chat/windows.vim | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bundle/vim-chat/autoload/chat/gitter.vim b/bundle/vim-chat/autoload/chat/gitter.vim index a4b34b745..82a221426 100644 --- a/bundle/vim-chat/autoload/chat/gitter.vim +++ b/bundle/vim-chat/autoload/chat/gitter.vim @@ -195,6 +195,14 @@ let s:list_all_channels_jobid = -1 let s:list_all_channels_result = [] function! s:get_all_channels() abort if s:list_all_channels_jobid <= 0 + call chat#windows#push({ + \ 'user' : '--->', + \ 'username' : '--->', + \ 'room' : '', + \ 'protocol' : 'gitter', + \ 'msg' : 'listing gitter channels', + \ 'time': strftime("%Y-%m-%d %H:%M"), + \ }) let cmd = printf('curl -s -H "Accept: application/json" -H "Authorization: Bearer %s" "https://api.gitter.im/v1/rooms"', g:chat_gitter_token) let s:list_all_channels_jobid = s:JOB.start(cmd, { \ 'on_stdout' : function('s:get_all_channels_stdout'), @@ -223,6 +231,15 @@ function! s:get_all_channels_exit(id, data, event) abort endif if !chat#windows#is_opened() call chat#notify#noti('gitter protocol channels updated!') + else + call chat#windows#push({ + \ 'user' : '--->', + \ 'username' : '--->', + \ 'room' : '', + \ 'protocol' : 'gitter', + \ 'msg' : 'list channels done!', + \ 'time': strftime("%Y-%m-%d %H:%M"), + \ }) endif endfunction diff --git a/bundle/vim-chat/autoload/chat/windows.vim b/bundle/vim-chat/autoload/chat/windows.vim index 536483563..256ae178d 100644 --- a/bundle/vim-chat/autoload/chat/windows.vim +++ b/bundle/vim-chat/autoload/chat/windows.vim @@ -316,7 +316,7 @@ function! s:update_msg_screen() abort if s:msg_win_opened normal! gg"_dG let buffer = [] - let msgs = filter(deepcopy(s:messages), 'v:val["room"] ==# s:current_channel') + let msgs = filter(deepcopy(s:messages), 'v:val["room"] ==# s:current_channel || (empty(v:val["room"]) && v:val["protocol"] ==# s:protocol)') for msg in msgs let name = s:get_str_with_width(msg['user'], 13) let message = s:get_lines_with_width(msg['msg'], winwidth('$') - 36)