File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,13 +126,20 @@ class MessageListViewController: BaseViewController<MessageListViewModel> {
126126 self ? . scrollToTop ( )
127127 } ) . disposed ( by: self . rx. disposeBag)
128128
129- NotificationCenter . default. rx
130- . notification ( kBarkMessagesDidChangeNotification)
131- . subscribe ( onNext: { [ weak self] _ in
132- // 默认加载未完成前,不执行刷新,避免重复刷新
133- guard let self, self . hasFinishedInitialLoadingTransition else { return }
134- self . reloadRelay. accept ( ( ) )
135- } ) . disposed ( by: rx. disposeBag)
129+ Observable . merge (
130+ NotificationCenter . default. rx
131+ . notification ( UIApplication . willEnterForegroundNotification) ,
132+ NotificationCenter . default. rx
133+ . notification ( kBarkMessagesDidChangeNotification)
134+ )
135+ // 防止重复加载
136+ // 另外顺便延迟0.5秒,需要等待数据库 Results 更新到最新数据集,否则可能新推送没有显示出来。
137+ . debounce ( . milliseconds( 500 ) , scheduler: MainScheduler . instance)
138+ . subscribe ( onNext: { [ weak self] _ in
139+ // 默认加载未完成前,不执行刷新,避免重复刷新
140+ guard let self, self . hasFinishedInitialLoadingTransition else { return }
141+ self . reloadRelay. accept ( ( ) )
142+ } ) . disposed ( by: rx. disposeBag)
136143
137144 // 点击群组消息,展开群
138145 tableView. rx. itemSelected. subscribe ( onNext: { [ weak self] indexPath in
You can’t perform that action at this time.
0 commit comments