Chat view page

FossilOrigin-Name: 028f7856fcfe76360d66dd7d23c6e641d941d5d512ef806ebc84dd5c92176982
This commit is contained in:
nekobit 2022-07-06 07:02:42 +00:00
parent 80ce3e38bc
commit db83718dde
3 changed files with 33 additions and 7 deletions

6
dist/treebird20.css vendored
View file

@ -301,7 +301,7 @@ table.present th, table.present td
.e-error
{
display: block;
background-color: #fcb0b0;
background: linear-gradient(#fba0a0, #fcb0b0);
color: #000;
border: 1px solid #bb1c1f;
padding: 15px;
@ -317,9 +317,9 @@ table.present th, table.present td
.e-notice
{
display: block;
background-color: #ddeeff;
background: linear-gradient(#ddeeff, #ccddff);
color: #000;
border: 1px solid #66ccff;
border: 1px solid #80ccff;
padding: 15px;
font-weight: bold;
}

View file

@ -28,6 +28,7 @@
#include "../static/chat.ctmpl"
#include "../static/chats_page.ctmpl"
#include "../static/message.ctmpl"
#include "../static/chat_view.ctmpl"
struct construct_message_args
{
@ -165,7 +166,7 @@ void content_chat_view(struct session* ssn, mastodont_t* api, char** data)
struct mstdnt_storage storage = { 0 }, storage_chat = { 0 };
struct mstdnt_chat chat;
struct mstdnt_storage acct_storage = { 0 };
// char* chats_page = NULL;
char* chats_page = NULL;
char* messages_html = NULL;
struct mstdnt_chats_args args = {
@ -177,7 +178,6 @@ void content_chat_view(struct session* ssn, mastodont_t* api, char** data)
.limit = 20,
};
if (mastodont_get_chat_messages(api, &m_args, data[0],
&args, &storage, &messages, &messages_len) ||
mastodont_get_chat(api, &m_args, data[0],
@ -190,11 +190,21 @@ void content_chat_view(struct session* ssn, mastodont_t* api, char** data)
if (!messages_html)
messages_html = construct_error("This is the start of something new...", E_NOTICE, 1, NULL);
/* messages_html = construct_chats_view(chats_html, NULL); */
struct chat_view_template tmpl = {
.prefix = config_url_prefix,
.avatar = chat.account.avatar,
.acct = chat.account.acct,
.messages = messages_html
};
chats_page = tmpl_gen_chat_view(&tmpl, NULL);
}
struct base_page b = {
.category = BASE_CAT_CHATS,
.content = messages_html,
.content = chats_page,
.sidebar_left = NULL
};
@ -203,7 +213,8 @@ void content_chat_view(struct session* ssn, mastodont_t* api, char** data)
// Cleanup
mastodont_storage_cleanup(&storage);
//free(chats_page);
mastodont_storage_cleanup(&acct_storage);
free(chats_page);
free(messages_html);
// TOOD cleanup chats
}

15
static/chat_view.tmpl Normal file
View file

@ -0,0 +1,15 @@
<div class="page-header">
<span class="page-header-button">&larr;</span>
<img src="{{ %s : avatar }}" class="page-header-image">
<a href="{{ %s : prefix }}/@{{%s:acct}}" class="page-header-title">{{ %s : acct }}</a>
</div>
<div class="chat-view">
{{ %s : messages }}
<table class="chatbox ui-table">
<tr>
<td>
<textarea></textarea>
</td>
</tr>
</table>
</div>