d99kris / nchat

Terminal-based Telegram / WhatsApp client for Linux and macOS
MIT License
524 stars 40 forks source link

Contacts shown duplicated for WhatsApp after setup #170

Closed Disonantemus closed 6 months ago

Disonantemus commented 6 months ago

Description: I did try nchat 4 1st time today with whatsapp, 1st setup launch did ok, but when finally showing contacts and messages, 1d8 CPU cores got 100%, and nchat got non-responsive, then I did quit, restart, now I do have a working responsive nchat, but all my contacts are duplicated. If I restart again, contacts are still duplicated.

How to reproduce it:

  1. launch nchat.
  2. watch contact list, all are duplicated.
  3. show address book (^n).

Environment:


If I show address book (^n), I get something like this:

┌───────────────────── Select Contact ─────────────────────┐
│ . @ WhatsAppMd_+541143823353                             │
│ . @ WhatsAppMd_+54 11 4382 3353^[[D^[[                   │
│ . @ WhatsAppMd_+541143823353                             │
│ . @ WhatsAppMd_+54 11 4382 3353^[[D^[[                   │
│ 530×16✊💣💰💸💸 @ WhatsAppMd_+541143823353              │
│ 530×16✊💣💰💸💸 @ WhatsAppMd_+54 11 4382 3353^[[D^[[    │
│ 946011 @ WhatsAppMd_+54 11 4382 3353^[[D^[[              │
│ 946011 @ WhatsAppMd_+541143823353                        │

Note1: I did change phone numbers 4 privacy reasons, but you get the idea, contacts appear 2 times, one with phone number separated and one altogether.

Note2: There's also those trailing ^[[D^[[, that appears like a escape codes, that appear at the duplicated contact.


There's maybe another bug related to this, when pressing TAB to go next chat, sometimes you see next contact highlighted and return to previous, you get that when pressing TAB many times. Theories:

d99kris commented 6 months ago

Hi @Disonantemus - are you sure you only performed the setup (nchat -s) once?

In any case, as a workaround, you could try deleting the config directory (rm -rf ~/.nchat unless you have a custom path) and setup again. This time let nchat run for a while even if it appears hung. The whatsapp first sync takes a bit of time, on my system/connection about 15-20 secs, but others may be slower.

Based on the address book "screenshot" you shared, it appears that nchat has been set up twice for whatsapp, once for number +541143823353 and once for +54 11 4382 3353^[[D^[[ (effectively the same number). It's probably a bug that nchat allows that to happen (it could strip spaces and control characters), but in any case, the end result is that you are logged in twice with same account from nchat, so all your contacts are shown twice, and other things are probably not going to work well as well.

Disonantemus commented 6 months ago

d99kris commented 6 months ago

Thanks for the feedback, and good to hear it's working now.

Yes, I think you bring up some good points, I'll look into improving the setup. I'll leave this issue open for now until I've made some improvements.

d99kris commented 6 months ago

I've added some fixes (two commits above) to reduce the risk of running into the reported issue: