ssb: Load and show new messages as they arrive.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
This commit is contained in:
@ -7,7 +7,6 @@ class TfElement extends LitElement {
|
||||
return {
|
||||
whoami: {type: String},
|
||||
hash: {type: String},
|
||||
unread: {type: Array},
|
||||
tab: {type: String},
|
||||
broadcasts: {type: Array},
|
||||
connections: {type: Array},
|
||||
@ -28,7 +27,6 @@ class TfElement extends LitElement {
|
||||
super();
|
||||
let self = this;
|
||||
this.hash = '#';
|
||||
this.unread = [];
|
||||
this.tab = 'news';
|
||||
this.broadcasts = [];
|
||||
this.connections = [];
|
||||
@ -239,17 +237,13 @@ class TfElement extends LitElement {
|
||||
[JSON.stringify(this.following), id]
|
||||
);
|
||||
for (let message of messages) {
|
||||
if (message.author == this.whoami) {
|
||||
let content = JSON.parse(message.content);
|
||||
if (content?.type == 'channel') {
|
||||
this.load_channels();
|
||||
}
|
||||
if (
|
||||
message.author == this.whoami &&
|
||||
JSON.parse(message.content)?.type == 'channel'
|
||||
) {
|
||||
this.load_channels();
|
||||
}
|
||||
}
|
||||
if (messages && messages.length) {
|
||||
this.unread = [...this.unread, ...messages];
|
||||
this.unread = this.unread.slice(this.unread.length - 1024);
|
||||
}
|
||||
this.schedule_load_channels_latest();
|
||||
}
|
||||
|
||||
@ -363,6 +357,7 @@ class TfElement extends LitElement {
|
||||
|
||||
schedule_load_channels_latest() {
|
||||
if (!this.loading_channels_latest) {
|
||||
this.shadowRoot.getElementById('tf-tab-news')?.load_latest();
|
||||
this.load_channels_latest(this.following);
|
||||
} else if (!this.loading_channels_latest_scheduled) {
|
||||
this.loading_channels_latest_scheduled++;
|
||||
@ -449,8 +444,6 @@ class TfElement extends LitElement {
|
||||
whoami=${this.whoami}
|
||||
.users=${this.users}
|
||||
hash=${this.hash}
|
||||
.unread=${this.unread}
|
||||
@refresh=${() => (this.unread = [])}
|
||||
?loading=${this.loading}
|
||||
.channels=${this.channels}
|
||||
.channels_latest=${this.channels_latest}
|
||||
@ -567,7 +560,9 @@ class TfElement extends LitElement {
|
||||
class="w3-theme-dark"
|
||||
>
|
||||
<div style="flex: 0 0">${tabs}</div>
|
||||
<div style="flex: 1 1; overflow: scroll; contain: layout">${contents}</div>
|
||||
<div style="flex: 1 1; overflow: scroll; contain: layout">
|
||||
${contents}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user