xynxynxyn / terminal-discord

NOT MAINTAINED Simple terminal client for discord with a minimal look and UI
MIT License
169 stars 16 forks source link

"&$&no_send" on top of every history #16

Closed ekzyis closed 5 years ago

ekzyis commented 6 years ago

When entering a channel, on top of the history there is always the NO_SEND string (introduced in https://github.com/xynxynxyn/terminal-discord/commit/a573a9adc914769a7ace99ade6d55a9859888b9a due to https://github.com/xynxynxyn/terminal-discord/issues/11).

Most of the times, when entering a channel with a big enough history, it gets unnoticed but when entering an empty channel, this output could be really confusing for the user.

ekzyis commented 6 years ago

Editing function history() to

    .then(m => {
      messages = m.array().reverse();
-     update();
+     messages.forEach(m => show_message(m));
    });

solves the most noticable issue when opening an empty channel, since then all messages will just be shown without using update() which uses rl.write(NO_SEND) to achieve persistence of user input after new arriving messages.

We don't need (or do we?) update() in history() since we only want to print the history in history() without thinking about current user input since that is already handled by the working together of update(), rl.on('line', {}) and client.on("message", {})

Changing printing of &$&no_send in a new history after a new message arrived (from another member of from the user himself) cannot be changed as easily like in history() since rl.write(NO_SEND) in update() was crucial to solving #11.

https://github.com/xynxynxyn/terminal-discord/blob/b046b4cd3027068fd3adebf780b360616896fe94/index.js#L348-L360

xynxynxyn commented 5 years ago

This should be fixed in https://github.com/xynxynxyn/terminal-discord/commit/a1a5e70baf451ed1c12c74b0672c66371282ed6c.