zen-mode / Whatsapp-Zen-Mode

MIT License
7 stars 8 forks source link

Offline Mode #192

Closed liatzionimorad closed 2 years ago

liatzionimorad commented 2 years ago

Whatsapp is going to disable writing in flight mode on WhatsApp web so we want to simulate this state in zen mode: Define"flight mode" at this time phone is not affected in web: we operate as if flight mode- messages will be written but not sent to the user no new messages will be shownץ it is ok that not all functionality will exist like scrolling up in a chat

liatzionimorad commented 2 years ago

ZenMode Flight Mode (Liat) למה היום אפשר להכניס את הטלפון למצב טיסה, ואז לעבוד על וואטסאפ ווב, להוציא הרבה הודעות, בלי לקבל רעש של הודעות נכנסות. היכולת הזאת תכף הולכת לאיבוד עם הגרסה החדשה של וואטסאפ מה יש כפתור "מצב טיסה" בתור תפריט זן מוד (אחד התפריטים שלנו), שכשאני לוחץ עליו, אני מפסיק לקבל ולהוציא הודעות. ההודעות ממשיכות להגיע לטלפון כרגיל, אנחנו לא נוגעים לטלפון. אני עובד כרגיל, הודעות שאני "שולח" נכנסו לתור. מי ששולח לי רואה שזה הגיע כנראה לפלאפון עם וי אחד או שניים אפורים. הוא יראה שאני לא מחובר כרגע. זה בסדר אם פיצרים מסויימים של וואטסאפ ווב לא יעבדו, כגון לגלול למעלה בצט לעתיד (אפשר עקרונית להחריג אפילו קונטקים מסויימים שהם לא יהיו במצב טיסה ... אולי ... אבל זה לגמרי בונוס, לא מעניין כרגע) אופציות מימוש לשים טאב כאופליין אם יש איזו דרך ממש להוציא טאב אחד ספציפי - של הוואטסאפ שיתנהג כאילו הוא לא מחובר לאינטרנט. ואז לא היה צריך לשמור כל מיני תורים וסינכרונים. אני חושבת שזה היה עונה על הדרישות של כל הפיצר שאתה צריך. והדרך לבדוק את זה, היא להתנתק רגע מהאינטרנט ולראות אם וואטסאפ מתנהג כמו שאתה רוצה (יש לו את הקטע של הספירה של החיבור. זה לא הכי נוח)

ripper234 commented 2 years ago

As a user, I would like to put Whatsapp Web into "Offline mode", and work without getting any interruptions from incoming chats. While in offline mode, I want to write outgoing messages that will be put in a queue (just like when there is no internet access). When the user exits Offline Mode, these outgoing messages are all transmitted from the queue.

This basically behaves identical to how Whatsapp behaves today when the user puts his phone into Airplane Mode.

Note - in the next version of Whatsapp, every device will be independent. So putting the user's phone into airplane mode can no longer provide this Offline Mode functionality - this is the reason we're exploring developing this mode in the Zen Mode extension.

Note - the user's Whatsapp Web is basically isolated from Whatsapp servers/APIs while Offline Mode is enabled. Whatever the user does on his mobile device does not appear on Web (and is later synced).

liatzionimorad commented 2 years ago

Dev: [23:10, 10.4.2022] ⁦+7 904 335-45-59⁩: Description of the technical solution for Task 114. Offline Mode #192:

When Offline Mode is enabled, all connections should be disabled and new connections should not be created. To do this, we need to redefine WebSocket. Since all communication with the server happens through WebSocket, having gained control, we can isolate WhatsApp from the server. Disabling isolation will force WhatsApp to sync after a couple of tens of seconds. [23:10, 10.4.2022] ⁦+7 904 335-45-59⁩: Necessary:

  1. Add button to Zen menu
  2. Write a WebSocket disable module
  3. Connect blocker to WhatsApp
  4. Module testing [23:10, 10.4.2022] ⁦+7 904 335-45-59⁩: Estimate: 26 hr Optimistic estimate taking into account force majeure: 34 hr [23:10, 10.4.2022] ⁦+7 904 335-45-59⁩: Can we get started?
liatzionimorad commented 2 years ago

@sgino209 input : The add-on does NOT interact directly with Whatsapp server, but rather interacts with the WhatsappWeb webApp Options for achieving the desired goal:

  1. Enhance the webSocket (WhatsappWeb ↔︎ Whatsapp server) for isolation handling
  2. Generate AJAX calls for Whatsapp server for isolation enabling/disabling Messages queuing can be obtained with IndexedDB, which is already applied by the app Notes:
    • Options assume Whatsapp server supports isolation API ➔ need to be validated
    • Option 1 assumes the webSocket is 'accessible' for developers
    • Option 2 is less efficient (AJAX vs. webSocket) but might be easier to implement, and the calls themselves are relatively rare