Compare commits
3 Commits
f7b3711d4f
...
4040d6aa08
Author | SHA1 | Date | |
---|---|---|---|
4040d6aa08 | |||
1c96f5c35e | |||
4d3e42812d |
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&n2E4F4hnQe0dz+NvcMlKl5pcAZ3a1NM7/iNyWng9fRQ=.sha256"
|
"previous": "&DJCofULiC7mj62IoWQGTveRUQvFrf9oL5BBaUhXQdf0=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -301,31 +301,35 @@ class TfMessageElement extends LitElement {
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expanded_key() {
|
||||||
|
return this.message?.id || this.messages?.map((x) => x.id).join(':');
|
||||||
|
}
|
||||||
|
|
||||||
set_expanded(expanded, tag) {
|
set_expanded(expanded, tag) {
|
||||||
|
let key = this.expanded_key();
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new CustomEvent('tf-expand', {
|
new CustomEvent('tf-expand', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
composed: true,
|
composed: true,
|
||||||
detail: {id: (this.message.id || '') + (tag || ''), expanded: expanded},
|
detail: {id: key + (tag || ''), expanded: expanded},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_expanded(tag) {
|
toggle_expanded(tag) {
|
||||||
this.set_expanded(
|
let key = this.expanded_key();
|
||||||
!this.expanded[(this.message.id || '') + (tag || '')],
|
this.set_expanded(!this.expanded[key + (tag || '')], tag);
|
||||||
tag
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_expanded(tag) {
|
is_expanded(tag) {
|
||||||
return this.expanded[(this.message.id || '') + (tag || '')];
|
let key = this.expanded_key();
|
||||||
|
return this.expanded[key + (tag || '')];
|
||||||
}
|
}
|
||||||
|
|
||||||
render_children() {
|
render_children() {
|
||||||
let self = this;
|
let self = this;
|
||||||
if (this.message.child_messages?.length) {
|
if (this.message.child_messages?.length) {
|
||||||
if (!this.expanded[this.message.id]) {
|
if (!this.expanded[this.expanded_key()]) {
|
||||||
return html`
|
return html`
|
||||||
<button
|
<button
|
||||||
class="w3-button w3-theme-d1 w3-block w3-bar"
|
class="w3-button w3-theme-d1 w3-block w3-bar"
|
||||||
@ -578,6 +582,44 @@ class TfMessageElement extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content_group_by_author() {
|
||||||
|
let sorted = this.message.messages
|
||||||
|
.map((x) => [
|
||||||
|
x.author,
|
||||||
|
x.content.blocking !== undefined
|
||||||
|
? x.content.blocking
|
||||||
|
? 'is blocking'
|
||||||
|
: 'is no longer blocking'
|
||||||
|
: x.content.following !== undefined
|
||||||
|
? x.content.following
|
||||||
|
? 'is following'
|
||||||
|
: 'is no longer following'
|
||||||
|
: '',
|
||||||
|
x.content.contact,
|
||||||
|
x,
|
||||||
|
])
|
||||||
|
.sort();
|
||||||
|
let result = [];
|
||||||
|
let last;
|
||||||
|
let group;
|
||||||
|
for (let row of sorted) {
|
||||||
|
if (last && last[0] == row[0] && last[1] == row[1]) {
|
||||||
|
group.push(row[2]);
|
||||||
|
} else {
|
||||||
|
if (group) {
|
||||||
|
result.push({author: last[0], action: last[1], users: group});
|
||||||
|
}
|
||||||
|
last = row;
|
||||||
|
group = [row[2]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (group) {
|
||||||
|
result.push({author: last[0], action: last[1], users: group});
|
||||||
|
}
|
||||||
|
console.log(this.message.messages, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let content = this.message?.content;
|
let content = this.message?.content;
|
||||||
if (this.message?.decrypted?.type == 'post') {
|
if (this.message?.decrypted?.type == 'post') {
|
||||||
@ -586,8 +628,10 @@ class TfMessageElement extends LitElement {
|
|||||||
let class_background = this.class_background();
|
let class_background = this.class_background();
|
||||||
let self = this;
|
let self = this;
|
||||||
if (this.message?.type === 'contact_group') {
|
if (this.message?.type === 'contact_group') {
|
||||||
return this.render_frame(
|
if (this.expanded[this.expanded_key()]) {
|
||||||
html` ${this.message.messages.map(
|
return this.render_frame(html`
|
||||||
|
<div class="w3-padding">
|
||||||
|
${this.message.messages.map(
|
||||||
(x) =>
|
(x) =>
|
||||||
html`<tf-message
|
html`<tf-message
|
||||||
.message=${x}
|
.message=${x}
|
||||||
@ -598,15 +642,51 @@ class TfMessageElement extends LitElement {
|
|||||||
channel=${this.channel}
|
channel=${this.channel}
|
||||||
channel_unread=${this.channel_unread}
|
channel_unread=${this.channel_unread}
|
||||||
></tf-message>`
|
></tf-message>`
|
||||||
)}`
|
)}
|
||||||
);
|
</div>
|
||||||
|
<button
|
||||||
|
class="w3-button w3-theme-d1 w3-block w3-bar"
|
||||||
|
style="box-sizing: border-box"
|
||||||
|
@click=${() => self.set_expanded(false)}
|
||||||
|
>
|
||||||
|
Collapse
|
||||||
|
</button>
|
||||||
|
`);
|
||||||
|
} else {
|
||||||
|
return this.render_frame(html`
|
||||||
|
<div class="w3-padding">
|
||||||
|
${this.content_group_by_author().map(
|
||||||
|
(x) => html`
|
||||||
|
<tf-user id=${x.author} .users=${this.users}></tf-user>
|
||||||
|
${x.action}
|
||||||
|
${x.users.map(
|
||||||
|
(y) => html`
|
||||||
|
<tf-user id=${y} .users=${this.users}></tf-user>
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
`
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="w3-button w3-theme-d1 w3-block w3-bar"
|
||||||
|
style="box-sizing: border-box"
|
||||||
|
@click=${() => self.set_expanded(true)}
|
||||||
|
>
|
||||||
|
Expand
|
||||||
|
</button>
|
||||||
|
`);
|
||||||
|
}
|
||||||
} else if (this.message.placeholder) {
|
} else if (this.message.placeholder) {
|
||||||
return this.render_frame(
|
return this.render_frame(
|
||||||
html`<div class="w3-padding">
|
html`<div>
|
||||||
<div class="w3-bar">
|
<div class="w3-bar">
|
||||||
<div class="w3-bar-item w3-panel w3-round-xlarge w3-theme-d1">
|
<a
|
||||||
|
class="w3-bar-item w3-panel w3-round-xlarge w3-theme-d1 w3-margin w3-button"
|
||||||
|
target="_top"
|
||||||
|
href=${'#' + encodeURIComponent(this.message?.id)}
|
||||||
|
>
|
||||||
This message is not currently available.
|
This message is not currently available.
|
||||||
</div>
|
</a>
|
||||||
<div class="w3-bar-item w3-right">
|
<div class="w3-bar-item w3-right">
|
||||||
<button class="w3-button w3-theme-d1" @click=${this.toggle_menu}>
|
<button class="w3-button w3-theme-d1" @click=${this.toggle_menu}>
|
||||||
%
|
%
|
||||||
@ -679,8 +759,9 @@ class TfMessageElement extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
} else if (content.type == 'contact') {
|
} else if (content.type == 'contact') {
|
||||||
return html`
|
return this.render_frame(html`
|
||||||
<div class="w3-padding">
|
<div class="w3-bar">
|
||||||
|
<div class="w3-bar-item">
|
||||||
<tf-user id=${this.message.author} .users=${this.users}></tf-user>
|
<tf-user id=${this.message.author} .users=${this.users}></tf-user>
|
||||||
is
|
is
|
||||||
${content.blocking === true
|
${content.blocking === true
|
||||||
@ -697,7 +778,41 @@ class TfMessageElement extends LitElement {
|
|||||||
.users=${this.users}
|
.users=${this.users}
|
||||||
></tf-user>
|
></tf-user>
|
||||||
</div>
|
</div>
|
||||||
`;
|
<div class="w3-bar-item w3-right">
|
||||||
|
<button class="w3-button w3-theme-d1" @click=${this.toggle_menu}>
|
||||||
|
%
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
class="w3-dropdown-content w3-bar-block w3-card-4 w3-theme-l1"
|
||||||
|
style="right: 48px"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
target="_top"
|
||||||
|
class="w3-button w3-bar-item"
|
||||||
|
href=${'#' + encodeURIComponent(this.message?.id)}
|
||||||
|
>View Message</a
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="w3-button w3-bar-item w3-border-bottom"
|
||||||
|
@click=${this.copy_id}
|
||||||
|
>
|
||||||
|
Copy ID
|
||||||
|
</button>
|
||||||
|
${this.drafts[this.message?.id] === undefined
|
||||||
|
? html`
|
||||||
|
<button
|
||||||
|
class="w3-button w3-bar-item"
|
||||||
|
@click=${this.show_reply}
|
||||||
|
>
|
||||||
|
↩️ Reply
|
||||||
|
</button>
|
||||||
|
`
|
||||||
|
: undefined}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
${this.render_votes()} ${this.render_actions()}
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
} else if (content.type == 'post') {
|
} else if (content.type == 'post') {
|
||||||
let self = this;
|
let self = this;
|
||||||
let body;
|
let body;
|
||||||
|
@ -166,7 +166,10 @@ class TfNewsElement extends LitElement {
|
|||||||
if (message?.content?.type === 'contact') {
|
if (message?.content?.type === 'contact') {
|
||||||
group.push(message);
|
group.push(message);
|
||||||
} else {
|
} else {
|
||||||
if (group.length > 0) {
|
if (group.length == 1) {
|
||||||
|
result.push(group[0]);
|
||||||
|
group = [];
|
||||||
|
} else if (group.length > 1) {
|
||||||
result.push({
|
result.push({
|
||||||
rowid: Math.max(...group.map((x) => x.rowid)),
|
rowid: Math.max(...group.map((x) => x.rowid)),
|
||||||
type: 'contact_group',
|
type: 'contact_group',
|
||||||
@ -177,7 +180,10 @@ class TfNewsElement extends LitElement {
|
|||||||
result.push(message);
|
result.push(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (group.length > 0) {
|
if (group.length == 1) {
|
||||||
|
result.push(group[0]);
|
||||||
|
group = [];
|
||||||
|
} else if (group.length > 1) {
|
||||||
result.push({
|
result.push({
|
||||||
rowid: Math.max(...group.map((x) => x.rowid)),
|
rowid: Math.max(...group.map((x) => x.rowid)),
|
||||||
type: 'contact_group',
|
type: 'contact_group',
|
||||||
|
@ -441,9 +441,14 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
return cache(html`
|
return cache(html`
|
||||||
<button class="w3-button w3-theme-d1" @click=${this.mark_all_read}>
|
${!this.hash.startsWith('#%')
|
||||||
|
? html`<button
|
||||||
|
class="w3-button w3-theme-d1"
|
||||||
|
@click=${this.mark_all_read}
|
||||||
|
>
|
||||||
Mark All Read
|
Mark All Read
|
||||||
</button>
|
</button>`
|
||||||
|
: undefined}
|
||||||
<tf-news
|
<tf-news
|
||||||
id="news"
|
id="news"
|
||||||
whoami=${this.whoami}
|
whoami=${this.whoami}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user