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
* man pages
* notification handling if guilds are edited
* notification handling if friends send you a message
* /markread support
* handling for markdown, i.e. bold, italics, colours etc.
* voice chat support

View File

@ -483,7 +483,10 @@ static void ncdc_mainwindow_handle_events(ncdc_mainwindow_t n)
return;
}
dc_channel_t c = NULL;
dc_event_t e = NULL;
dc_message_t m = NULL;
char const *id = NULL;
e = dc_session_pop_event(current_session);
if (e == NULL) {
@ -497,9 +500,28 @@ static void ncdc_mainwindow_handle_events(ncdc_mainwindow_t n)
ncdc_mainwindow_update_guilds(n);
} 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;
}
cleanup:
dc_unref(m);
dc_unref(e);
}

View File

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