forked from cory/tildefriends
ssb: Use the cache of private messages we built for the unread notification to actually show private messages. Still needs some work, but it's something.
This commit is contained in:
parent
dddec489b9
commit
e5899fca58
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&zAW/4XKD1wcsEM12bkzZD0V7Wyne3OPpQne2rtncxXM=.sha256"
|
"previous": "&0ZtxnihH3oETfi0vhhEwc9O66SrjfiFcHDVBAIxICy0=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ class TfElement extends LitElement {
|
|||||||
channels_latest: {type: Object},
|
channels_latest: {type: Object},
|
||||||
guest: {type: Boolean},
|
guest: {type: Boolean},
|
||||||
url: {type: String},
|
url: {type: String},
|
||||||
|
private_messages: {type: Array},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +335,7 @@ class TfElement extends LitElement {
|
|||||||
JSON.stringify(cache)
|
JSON.stringify(cache)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return cache.latest;
|
return [cache.latest, cache.messages];
|
||||||
}
|
}
|
||||||
|
|
||||||
async load_channels_latest(following) {
|
async load_channels_latest(following) {
|
||||||
@ -378,9 +379,11 @@ class TfElement extends LitElement {
|
|||||||
start_time = new Date();
|
start_time = new Date();
|
||||||
latest_private.then(function (latest) {
|
latest_private.then(function (latest) {
|
||||||
self.channels_latest = Object.assign({}, self.channels_latest, {
|
self.channels_latest = Object.assign({}, self.channels_latest, {
|
||||||
'🔐': latest,
|
'🔐': latest[0],
|
||||||
});
|
});
|
||||||
console.log('private took', (new Date() - start_time) / 1000.0);
|
console.log('private took', (new Date() - start_time) / 1000.0);
|
||||||
|
console.log(latest);
|
||||||
|
self.private_messages = latest[1];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,6 +516,7 @@ class TfElement extends LitElement {
|
|||||||
.channels_unread=${this.channels_unread}
|
.channels_unread=${this.channels_unread}
|
||||||
@channelsetunread=${this.channel_set_unread}
|
@channelsetunread=${this.channel_set_unread}
|
||||||
.connections=${this.connections}
|
.connections=${this.connections}
|
||||||
|
.private_messages=${this.private_messages}
|
||||||
></tf-tab-news>
|
></tf-tab-news>
|
||||||
`;
|
`;
|
||||||
} else if (this.tab === 'connections') {
|
} else if (this.tab === 'connections') {
|
||||||
|
@ -17,6 +17,7 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
loading: {type: Number},
|
loading: {type: Number},
|
||||||
time_range: {type: Array},
|
time_range: {type: Array},
|
||||||
time_loading: {type: Array},
|
time_loading: {type: Array},
|
||||||
|
private_messages: {type: Array},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,13 +149,13 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
`
|
`
|
||||||
SELECT TRUE AS is_primary, messages.rowid, messages.id, previous, author, sequence, timestamp, hash, json(content) AS content, signature
|
SELECT TRUE AS is_primary, messages.rowid, messages.id, previous, author, sequence, timestamp, hash, json(content) AS content, signature
|
||||||
FROM messages
|
FROM messages
|
||||||
JOIN json_each(?1) AS following ON messages.author = following.value
|
JOIN json_each(?1) AS private_messages ON messages.id = private_messages.value
|
||||||
WHERE
|
WHERE
|
||||||
(?2 IS NULL OR (messages.timestamp >= ?2)) AND messages.timestamp < ?3 AND
|
(?2 IS NULL OR (messages.timestamp >= ?2)) AND messages.timestamp < ?3 AND
|
||||||
json(messages.content) LIKE '"%'
|
json(messages.content) LIKE '"%'
|
||||||
ORDER BY messages.sequence DESC LIMIT 20
|
ORDER BY messages.sequence DESC LIMIT 20
|
||||||
`,
|
`,
|
||||||
[JSON.stringify(this.following), start_time, end_time]
|
[JSON.stringify(this.private_messages), start_time, end_time]
|
||||||
);
|
);
|
||||||
result = (await this.decrypt(result)).filter((x) => x.decrypted);
|
result = (await this.decrypt(result)).filter((x) => x.decrypted);
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,6 +23,7 @@ class TfTabNewsElement extends LitElement {
|
|||||||
channels_unread: {type: Object},
|
channels_unread: {type: Object},
|
||||||
channels_latest: {type: Object},
|
channels_latest: {type: Object},
|
||||||
connections: {type: Array},
|
connections: {type: Array},
|
||||||
|
private_messages: {type: Array},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +338,7 @@ class TfTabNewsElement extends LitElement {
|
|||||||
@tf-expand=${this.on_expand}
|
@tf-expand=${this.on_expand}
|
||||||
.channels_unread=${this.channels_unread}
|
.channels_unread=${this.channels_unread}
|
||||||
.channels_latest=${this.channels_latest}
|
.channels_latest=${this.channels_latest}
|
||||||
|
.private_messages=${this.private_messages}
|
||||||
></tf-tab-news-feed>
|
></tf-tab-news-feed>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user