| 625 | } |
| 626 | |
| 627 | void PeerListRow::refreshStatus() { |
| 628 | if (!_initialized |
| 629 | || special() |
| 630 | || _statusType == StatusType::Custom |
| 631 | || _statusType == StatusType::CustomActive) { |
| 632 | return; |
| 633 | } |
| 634 | _statusType = StatusType::LastSeen; |
| 635 | _statusValidTill = 0; |
| 636 | if (auto user = peer()->asUser()) { |
| 637 | if (!_savedMessagesStatus.isEmpty()) { |
| 638 | setStatusText(_savedMessagesStatus); |
| 639 | } else { |
| 640 | auto time = base::unixtime::now(); |
| 641 | setStatusText(Data::OnlineText(user, time)); |
| 642 | if (Data::OnlineTextActive(user, time)) { |
| 643 | _statusType = StatusType::Online; |
| 644 | } |
| 645 | _statusValidTill = crl::now() |
| 646 | + Data::OnlineChangeTimeout(user, time); |
| 647 | } |
| 648 | } else if (auto chat = peer()->asChat()) { |
| 649 | if (!chat->amIn()) { |
| 650 | setStatusText(tr::lng_chat_status_unaccessible(tr::now)); |
| 651 | } else if (chat->count > 0) { |
| 652 | setStatusText(tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->count)); |
| 653 | } else { |
| 654 | setStatusText(tr::lng_group_status(tr::now)); |
| 655 | } |
| 656 | } else if (peer()->isMegagroup()) { |
| 657 | setStatusText(tr::lng_group_status(tr::now)); |
| 658 | } else if (peer()->isChannel()) { |
| 659 | setStatusText(tr::lng_channel_status(tr::now)); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | crl::time PeerListRow::refreshStatusTime() const { |
| 664 | return _statusValidTill; |
no test coverage detected