Compare commits
No commits in common. "4040d6aa0822287a16fafecb998cdde2c844496e" and "f7b3711d4fc18b22367771d1df5babdafb198fe3" have entirely different histories.
4040d6aa08
...
f7b3711d4f
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&DJCofULiC7mj62IoWQGTveRUQvFrf9oL5BBaUhXQdf0=.sha256"
|
"previous": "&n2E4F4hnQe0dz+NvcMlKl5pcAZ3a1NM7/iNyWng9fRQ=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -301,35 +301,31 @@ 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: key + (tag || ''), expanded: expanded},
|
detail: {id: (this.message.id || '') + (tag || ''), expanded: expanded},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_expanded(tag) {
|
toggle_expanded(tag) {
|
||||||
let key = this.expanded_key();
|
this.set_expanded(
|
||||||
this.set_expanded(!this.expanded[key + (tag || '')], tag);
|
!this.expanded[(this.message.id || '') + (tag || '')],
|
||||||
|
tag
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
is_expanded(tag) {
|
is_expanded(tag) {
|
||||||
let key = this.expanded_key();
|
return this.expanded[(this.message.id || '') + (tag || '')];
|
||||||
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.expanded_key()]) {
|
if (!this.expanded[this.message.id]) {
|
||||||
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"
|
||||||
@ -582,44 +578,6 @@ 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') {
|
||||||
@ -628,65 +586,27 @@ 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') {
|
||||||
if (this.expanded[this.expanded_key()]) {
|
return this.render_frame(
|
||||||
return this.render_frame(html`
|
html` ${this.message.messages.map(
|
||||||
<div class="w3-padding">
|
(x) =>
|
||||||
${this.message.messages.map(
|
html`<tf-message
|
||||||
(x) =>
|
.message=${x}
|
||||||
html`<tf-message
|
whoami=${this.whoami}
|
||||||
.message=${x}
|
.users=${this.users}
|
||||||
whoami=${this.whoami}
|
.drafts=${this.drafts}
|
||||||
.users=${this.users}
|
.expanded=${this.expanded}
|
||||||
.drafts=${this.drafts}
|
channel=${this.channel}
|
||||||
.expanded=${this.expanded}
|
channel_unread=${this.channel_unread}
|
||||||
channel=${this.channel}
|
></tf-message>`
|
||||||
channel_unread=${this.channel_unread}
|
)}`
|
||||||
></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>
|
html`<div class="w3-padding">
|
||||||
<div class="w3-bar">
|
<div class="w3-bar">
|
||||||
<a
|
<div class="w3-bar-item w3-panel w3-round-xlarge w3-theme-d1">
|
||||||
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.
|
||||||
</a>
|
</div>
|
||||||
<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}>
|
||||||
%
|
%
|
||||||
@ -759,60 +679,25 @@ class TfMessageElement extends LitElement {
|
|||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
} else if (content.type == 'contact') {
|
} else if (content.type == 'contact') {
|
||||||
return this.render_frame(html`
|
return html`
|
||||||
<div class="w3-bar">
|
<div class="w3-padding">
|
||||||
<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
|
? 'blocking'
|
||||||
? 'blocking'
|
: content.blocking === false
|
||||||
: content.blocking === false
|
? 'no longer blocking'
|
||||||
? 'no longer blocking'
|
: content.following === true
|
||||||
: content.following === true
|
? 'following'
|
||||||
? 'following'
|
: content.following === false
|
||||||
: content.following === false
|
? 'no longer following'
|
||||||
? 'no longer following'
|
: '?'}
|
||||||
: '?'}
|
<tf-user
|
||||||
<tf-user
|
id=${this.message.content.contact}
|
||||||
id=${this.message.content.contact}
|
.users=${this.users}
|
||||||
.users=${this.users}
|
></tf-user>
|
||||||
></tf-user>
|
|
||||||
</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>
|
</div>
|
||||||
`);
|
`;
|
||||||
} else if (content.type == 'post') {
|
} else if (content.type == 'post') {
|
||||||
let self = this;
|
let self = this;
|
||||||
let body;
|
let body;
|
||||||
|
@ -166,10 +166,7 @@ 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 == 1) {
|
if (group.length > 0) {
|
||||||
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',
|
||||||
@ -180,10 +177,7 @@ class TfNewsElement extends LitElement {
|
|||||||
result.push(message);
|
result.push(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (group.length == 1) {
|
if (group.length > 0) {
|
||||||
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,14 +441,9 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
return cache(html`
|
return cache(html`
|
||||||
${!this.hash.startsWith('#%')
|
<button class="w3-button w3-theme-d1" @click=${this.mark_all_read}>
|
||||||
? html`<button
|
Mark All Read
|
||||||
class="w3-button w3-theme-d1"
|
</button>
|
||||||
@click=${this.mark_all_read}
|
|
||||||
>
|
|
||||||
Mark All Read
|
|
||||||
</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