Skip to content

Commit

Permalink
use cached contacts on startup until receiving latest from chat service
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Sep 30, 2023
1 parent 7ae82f1 commit eaa357c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/common/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

#pragma once

#define NCHAT_VERSION "3.78"
#define NCHAT_VERSION "3.79"
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,7 @@ std::shared_ptr<Protocol> SetupProfile()
void ShowHelp()
{
std::cout <<
"nchat is a minimalistic terminal-based chat client with support for\n"
"telegram.\n"
"nchat is a terminal-based telegram / whatsapp client.\n"
"\n"
"Usage: nchat [OPTION]\n"
"\n"
Expand Down
5 changes: 2 additions & 3 deletions src/nchat.1
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
.TH NCHAT "1" "September 2023" "nchat v3.78" "User Commands"
.TH NCHAT "1" "September 2023" "nchat v3.79" "User Commands"
.SH NAME
nchat \- ncurses chat
.SH SYNOPSIS
.B nchat
[\fI\,OPTION\/\fR]
.SH DESCRIPTION
nchat is a minimalistic terminal\-based chat client with support for
telegram.
nchat is a terminal\-based telegram / whatsapp client.
.SS "Command-line Options:"
.TP
\fB\-d\fR, \fB\-\-confdir\fR <DIR>
Expand Down
11 changes: 10 additions & 1 deletion src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "emojilist.h"
#include "log.h"
#include "messagecache.h"
#include "uicolorconfig.h"
#include "uiconfig.h"
#include "uicontroller.h"
Expand Down Expand Up @@ -71,6 +72,14 @@ Ui::~Ui()

void Ui::Run()
{
std::unordered_map<std::string, std::shared_ptr<Protocol>>& protocols = m_Model->GetProtocols();

// retrieve cached contacts for use until receiving latest from chat service
for (auto& protocol : protocols)
{
MessageCache::FetchContacts(protocol.first);
}

LOG_INFO("entering ui loop");

curs_set(1);
Expand All @@ -85,7 +94,7 @@ void Ui::Run()

LOG_INFO("exiting ui loop");

std::unordered_map<std::string, std::shared_ptr<Protocol>>& protocols = m_Model->GetProtocols();
// set as offline before logging off
for (auto& protocol : protocols)
{
m_Model->SetStatusOnline(protocol.first, false);
Expand Down

0 comments on commit eaa357c

Please sign in to comment.