forked from andyburke/autonomous.contact
feature: reactions
This commit is contained in:
parent
b8467ec870
commit
7046bb0389
11 changed files with 371 additions and 133 deletions
|
|
@ -14,7 +14,7 @@
|
|||
". . content"
|
||||
". . newpost"
|
||||
". . replies";
|
||||
max-height: 6rem;
|
||||
max-height: 8rem;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--border-subtle);
|
||||
overflow-y: hidden;
|
||||
|
|
@ -111,6 +111,13 @@
|
|||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.post-container button[commandfor="eventactionspopover"] {
|
||||
position: absolute;
|
||||
bottom: 0.25rem;
|
||||
right: 0.25rem;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.post-container .new-post-container {
|
||||
grid-area: newpost;
|
||||
}
|
||||
|
|
@ -139,7 +146,7 @@
|
|||
id="posts-list"
|
||||
data-feed
|
||||
data-precheck="!!document.body.dataset.user && document.body.dataset.user.indexOf( 'topics.essays.read' ) !== -1"
|
||||
data-source="/api/topics/${ document.body.dataset.topic }/events?type=post&limit=100&sort=newest&wait=true&after_id=${ feed.__newest_id ?? 'post:able-able-able-able-able-able-able-able-able-able' }"
|
||||
data-source="/api/topics/${ document.body.dataset.topic }/events?type=post,reaction&limit=100&sort=newest&wait=true&after_id=${ feed.__newest_id ?? 'able-able-able-able-able-able-able-able-able-able' }"
|
||||
data-longpolling="true"
|
||||
data-reverse="true"
|
||||
data-insert="prepend"
|
||||
|
|
@ -157,17 +164,30 @@
|
|||
});
|
||||
|
||||
feed.__target_element = (item) => {
|
||||
return (
|
||||
document.querySelector(
|
||||
`.post-container[data-post_id='${item.parent_id}'] > .replies-container`,
|
||||
) ?? feed
|
||||
);
|
||||
let target = feed;
|
||||
switch (item.type) {
|
||||
case "reaction":
|
||||
target = document.querySelector(
|
||||
`.post-container[data-event_id='${item.parent_id}'] > .reactions-container`,
|
||||
);
|
||||
break;
|
||||
case "chat":
|
||||
default:
|
||||
target =
|
||||
document.querySelector(
|
||||
`.post-container[data-event_id='${item.parent_id}'] > .replies-container`,
|
||||
) ?? feed;
|
||||
break;
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
feed.__context = async (item) => {
|
||||
const post_datetime = datetime_to_local(item.timestamps.created);
|
||||
|
||||
return {
|
||||
event: item,
|
||||
post: item,
|
||||
creator: await USERS.get(item.creator_id),
|
||||
post_datetime,
|
||||
|
|
@ -215,10 +235,23 @@
|
|||
<div class="content-container">
|
||||
${htmlify(md_to_html(context.post.data.content))}
|
||||
</div>
|
||||
<div class="reactions-container"></div>
|
||||
<button class="icon more" commandfor="eventactionspopover"></button>
|
||||
<!-- #include file="./new_post.html" -->
|
||||
<div class="replies-container"></div>
|
||||
</div>
|
||||
</template>
|
||||
<template data-for_type="reaction">
|
||||
<div
|
||||
id="${context.event.id}"
|
||||
class="reaction-container"
|
||||
data-event_id="${context.event.id}"
|
||||
data-creator_id="${context.creator.id}"
|
||||
data-temp_id="${context.event.meta?.temp_id ?? ''}"
|
||||
>
|
||||
<span class="reaction">${ context.event.data.reaction }</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- #include file="./new_post.html" -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue