Contacts improvement
FossilOrigin-Name: 2322ec181715393e20da17a234610d61189d082cf32e09b61d79aeaca0e7615b
This commit is contained in:
parent
54363270ff
commit
97bd6b561d
7 changed files with 113 additions and 23 deletions
4
dist/js/main.js
vendored
4
dist/js/main.js
vendored
|
@ -134,8 +134,8 @@ function change_count_text(val, sum)
|
|||
|
||||
function interact_action(status, type)
|
||||
{
|
||||
let like = status.querySelector(".like");
|
||||
let repeat = status.querySelector(".repeat");
|
||||
let like = status.querySelector(".statbtn .like");
|
||||
let repeat = status.querySelector(".statbtn .repeat");
|
||||
|
||||
let svg;
|
||||
if (type.value === "like" || type.value === "unlike")
|
||||
|
|
44
dist/treebird20.css
vendored
44
dist/treebird20.css
vendored
|
@ -38,6 +38,7 @@ ul
|
|||
|
||||
#main-page
|
||||
{
|
||||
position: relative;
|
||||
margin: 8px;
|
||||
margin-top: 0;
|
||||
width: 1000px;
|
||||
|
@ -46,6 +47,7 @@ ul
|
|||
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
|
||||
border: 1px solid rgba(200, 200, 200, 0.7);
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hidden,
|
||||
|
@ -662,7 +664,12 @@ svg.in-reply-to-icon
|
|||
{
|
||||
color: #808080;
|
||||
font-size: 12px;
|
||||
padding: 2px 0 2px 0;
|
||||
padding: 4px 0 2px 0;
|
||||
}
|
||||
|
||||
.notification-compact .notification-content.is-mention
|
||||
{
|
||||
color: #101010;
|
||||
}
|
||||
|
||||
.notification-compact .notification-stats
|
||||
|
@ -740,7 +747,7 @@ svg.in-reply-to-icon
|
|||
border-spacing: 0px;
|
||||
}
|
||||
|
||||
.status-hide:checked + .status .status-table
|
||||
.status-hide:checked + .status
|
||||
{
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
@ -1237,7 +1244,7 @@ p}
|
|||
display: inline-block;
|
||||
position: relative;
|
||||
left: 155px;
|
||||
top: 185px;
|
||||
top: 192px;
|
||||
font-weight: bold;
|
||||
text-shadow: 0px 2px 6px #000;
|
||||
}
|
||||
|
@ -2046,6 +2053,23 @@ input[type=checkbox].hidden:not(:checked) + .list-edit-content
|
|||
}
|
||||
|
||||
/* Chats */
|
||||
.contact
|
||||
{
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.contact-right
|
||||
{
|
||||
padding: 4px;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.last-message
|
||||
{
|
||||
margin-top: 6px;
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
.message-container
|
||||
{
|
||||
position: relative;
|
||||
|
@ -2157,6 +2181,18 @@ input[type=checkbox].hidden:not(:checked) + .list-edit-content
|
|||
border-color: transparent transparent transparent #ffc7c7;
|
||||
}
|
||||
|
||||
.empty-chat-text
|
||||
{
|
||||
font-style: italic;
|
||||
color: #404040;
|
||||
}
|
||||
|
||||
.empty-chat-text:after
|
||||
{
|
||||
content: "...";
|
||||
}
|
||||
|
||||
|
||||
.chat-view
|
||||
{
|
||||
overflow: auto;
|
||||
|
@ -2447,7 +2483,7 @@ input[type=submit].chatbox-btn
|
|||
|
||||
#rightbar
|
||||
{
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
height: 100%;
|
||||
z-index: 100;
|
||||
|
|
|
@ -39,29 +39,74 @@ struct construct_message_args
|
|||
size_t msg_size; // Read messages backwards
|
||||
};
|
||||
|
||||
char* construct_chat(struct mstdnt_chat* chat, size_t* size)
|
||||
struct construct_chats_args
|
||||
{
|
||||
mastodont_t* api;
|
||||
struct mstdnt_args* args;
|
||||
struct mstdnt_chat* chats;
|
||||
};
|
||||
|
||||
char* construct_chat(mastodont_t* api,
|
||||
struct mstdnt_args* m_args,
|
||||
struct mstdnt_chat* chat,
|
||||
size_t* size)
|
||||
{
|
||||
char* result;
|
||||
char* msg_id = NULL;
|
||||
char* last_message = "<span class=\"empty-chat-text\">Chat created</span>";
|
||||
|
||||
// Get latest message
|
||||
struct mstdnt_storage storage = { 0 };
|
||||
struct mstdnt_message* messages = NULL;
|
||||
size_t messages_len = 0;
|
||||
|
||||
struct mstdnt_chats_args args = {
|
||||
.with_muted = MSTDNT_TRUE,
|
||||
.offset = 0,
|
||||
.limit = 1,
|
||||
};
|
||||
|
||||
if (mastodont_get_chat_messages(api, m_args, chat->id, &args, &storage,
|
||||
&messages, &messages_len) == 0 && messages_len == 1)
|
||||
{
|
||||
last_message = messages[0].content;
|
||||
msg_id = messages[0].id;
|
||||
}
|
||||
|
||||
struct chat_template data = {
|
||||
.id = chat->id,
|
||||
.prefix = config_url_prefix,
|
||||
.acct = chat->account.acct,
|
||||
.avatar = chat->account.avatar,
|
||||
.display_name = chat->account.display_name,
|
||||
.last_message = "",
|
||||
.message_id = msg_id,
|
||||
.last_message = last_message,
|
||||
};
|
||||
result = tmpl_gen_chat(&data, size);
|
||||
mastodont_storage_cleanup(&storage);
|
||||
// TODO cleanup messages
|
||||
return result;
|
||||
}
|
||||
|
||||
static char* construct_chat_voidwrap(void* passed, size_t index, size_t* res)
|
||||
{
|
||||
return construct_chat((struct mstdnt_chat*)passed + index, res);
|
||||
struct construct_chats_args* args = passed;
|
||||
return construct_chat(args->api, args->args, args->chats + index, res);
|
||||
}
|
||||
|
||||
char* construct_chats(struct mstdnt_chat* chats, size_t size, size_t* ret_size)
|
||||
char* construct_chats(mastodont_t* api,
|
||||
struct mstdnt_args* m_args,
|
||||
struct mstdnt_chat* chats,
|
||||
size_t size,
|
||||
size_t* ret_size)
|
||||
{
|
||||
return construct_func_strings(construct_chat_voidwrap, chats, size, ret_size);
|
||||
struct construct_chats_args args = {
|
||||
.api = api,
|
||||
.args = m_args,
|
||||
.chats = chats,
|
||||
};
|
||||
|
||||
return construct_func_strings(construct_chat_voidwrap, &args, size, ret_size);
|
||||
}
|
||||
|
||||
char* construct_message(struct mstdnt_message* msg,
|
||||
|
@ -135,7 +180,7 @@ void content_chats(struct session* ssn, mastodont_t* api, char** data)
|
|||
chats_page = construct_error(storage.error, E_ERROR, 1, NULL);
|
||||
}
|
||||
else {
|
||||
chats_html = construct_chats(chats, chats_len, NULL);
|
||||
chats_html = construct_chats(api, &m_args, chats, chats_len, NULL);
|
||||
if (!chats_html)
|
||||
chats_html = construct_error("No chats", E_NOTICE, 1, NULL);
|
||||
chats_page = construct_chats_view(chats_html, NULL);
|
||||
|
@ -207,6 +252,7 @@ char* construct_chat_view(struct session* ssn, mastodont_t* api, char* id, size_
|
|||
mastodont_storage_cleanup(&storage);
|
||||
mastodont_storage_cleanup(&acct_storage);
|
||||
free(messages_html);
|
||||
// TODO cleanup messages
|
||||
return chats_page;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,15 @@
|
|||
#include <mastodont.h>
|
||||
#include "session.h"
|
||||
|
||||
char* construct_chat(struct mstdnt_chat* chat, size_t* size);
|
||||
char* construct_chats(struct mstdnt_chat* chats, size_t size, size_t* ret_size);
|
||||
char* construct_chat(mastodont_t* api,
|
||||
struct mstdnt_args* m_args,
|
||||
struct mstdnt_chat* chat,
|
||||
size_t* size);
|
||||
char* construct_chats(mastodont_t* api,
|
||||
struct mstdnt_args* m_args,
|
||||
struct mstdnt_chat* chats,
|
||||
size_t size,
|
||||
size_t* ret_size);
|
||||
char* construct_chats_view(char* lists_string, size_t* size);
|
||||
// Message
|
||||
char* construct_message(struct mstdnt_message* message,
|
||||
|
|
|
@ -126,6 +126,8 @@ char* construct_notification_compact(struct session* ssn,
|
|||
.display_name = display_name,
|
||||
.action = type_str,
|
||||
.notif_svg = type_svg,
|
||||
.is_status = (notif->type == MSTDNT_NOTIFICATION_STATUS ||
|
||||
notif->type == MSTDNT_NOTIFICATION_MENTION ? "is-mention" : NULL),
|
||||
/* Might show follower address */
|
||||
.content = (notif->type == MSTDNT_NOTIFICATION_FOLLOW ?
|
||||
notif->account->acct : status_format),
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<a href="{{%s:prefix}}/chats/{{%s:id}}">
|
||||
<table class="account-stub">
|
||||
<a href="{{%s:prefix}}/chats/{{%s:id}}#{{%s:message_id}}">
|
||||
<table class="contact">
|
||||
<tr>
|
||||
<td class="pfp-td">
|
||||
<img src="{{%s:avatar}}">
|
||||
</td>
|
||||
<td class="account-stub-info-wrapper">
|
||||
<div class="account-stub-info">
|
||||
<div class="account-stub-top">
|
||||
<span class="username">{{%s:display_name}}</span>
|
||||
<span class="instance-info">@{{%s:acct}}</span>
|
||||
<td class="contact-right-td">
|
||||
<div class="contact-right">
|
||||
<div class="contact-info">
|
||||
<span class="username" title="{{%s:acct}}">{{%s:display_name}}</span>
|
||||
</div>
|
||||
<div class="account-stub-bottom">
|
||||
<div class="last-message">
|
||||
<span class="chat-msg-preview">{{ %s : last_message }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<span class="action">{{%s:action}}</span>
|
||||
</span> {{%s:notif_svg}}
|
||||
</div>
|
||||
<div class="notification-content">{{%s:content}}</div>
|
||||
<div class="notification-content {{%s:is_status}}">{{%s:content}}</div>
|
||||
<div class="notification-stats">{{%s:stats}}</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue