automatically open the chat for direct message channels

This commit is contained in:
Florian Stinglmayr 2019-07-29 19:22:33 +02:00
parent c136dd76e4
commit f9db598e16
3 changed files with 27 additions and 6 deletions

View File

@ -130,7 +130,6 @@ are a few that would be nice to have:
* auto completion * auto completion
* man pages * man pages
* notification handling if guilds are edited * notification handling if guilds are edited
* notification handling if friends send you a message
* /markread support * /markread support
* handling for markdown, i.e. bold, italics, colours etc. * handling for markdown, i.e. bold, italics, colours etc.
* voice chat support * voice chat support

View File

@ -483,7 +483,10 @@ static void ncdc_mainwindow_handle_events(ncdc_mainwindow_t n)
return; return;
} }
dc_channel_t c = NULL;
dc_event_t e = NULL; dc_event_t e = NULL;
dc_message_t m = NULL;
char const *id = NULL;
e = dc_session_pop_event(current_session); e = dc_session_pop_event(current_session);
if (e == NULL) { if (e == NULL) {
@ -497,9 +500,28 @@ static void ncdc_mainwindow_handle_events(ncdc_mainwindow_t n)
ncdc_mainwindow_update_guilds(n); ncdc_mainwindow_update_guilds(n);
} break; } break;
case DC_EVENT_TYPE_MESSAGE_CREATE:
{
m = dc_message_from_json(dc_event_payload(e));
id = dc_message_channel_id(m);
goto_if_true(m == NULL || id == NULL, cleanup);
c = dc_session_channel_by_id(current_session, id);
goto_if_true(c == NULL, cleanup);
/* TODO: handle unmuted channels here
*/
if (dc_channel_is_dm(c)) {
ncdc_mainwindow_switch_or_add(n, c);
}
} break;
default: break; default: break;
} }
cleanup:
dc_unref(m);
dc_unref(e); dc_unref(e);
} }

View File

@ -1,11 +1,11 @@
* General * General
** TODO move key handling away from the thread the event_loop thread ** TODO move key handling away from the thread the event_loop thread
* Channels [2/4] * Channels [3/4]
** TODO Automatically open window for 1:1 and 1:N ** DONE Automatically open window for 1:1 and 1:N
** DONE send v6/api/channels/$ID/ack for "I read that shit" ** DONE send v6/api/channels/$ID/ack for "I read that shit"
** TODO add timestamps from messages ** TODO add timestamps from messages
** DONE add message sending ** DONE add message sending
* Guilds [0/3] * Guilds [2/3]
** TODO Guild support code ** DONE Guild support code
** TODO Guild view on the left pane ** DONE Guild view on the left pane
** TODO silence guild channels ** TODO silence guild channels