forked from cory/tildefriends
ssb: Split recent votes into their own sidebar item as an experiment. #122
This commit is contained in:
parent
7882fcbe8f
commit
45231d703d
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🦀",
|
"emoji": "🦀",
|
||||||
"previous": "&JfWdlllyfUCzLARI/4tNR1Xlfx8nN3ONBSCipVhGd6g=.sha256"
|
"previous": "&GMCcwEOE3VorFHqMCRi6aS1Ch7u1B7hzW6GH35RaaUI=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ class TfElement extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
next_channel(delta) {
|
next_channel(delta) {
|
||||||
let channel_names = ['', '@', '🔐', ...this.channels.map((x) => '#' + x)];
|
let channel_names = ['', '@', '🔐', '👍', ...this.channels.map((x) => '#' + x)];
|
||||||
let index = channel_names.indexOf(this.hash.substring(1));
|
let index = channel_names.indexOf(this.hash.substring(1));
|
||||||
index = index != -1 ? index + delta : 0;
|
index = index != -1 ? index + delta : 0;
|
||||||
tfrpc.rpc.setHash(
|
tfrpc.rpc.setHash(
|
||||||
@ -383,6 +383,12 @@ class TfElement extends LitElement {
|
|||||||
JOIN messages ON messages.rowid = messages_fts.rowid
|
JOIN messages ON messages.rowid = messages_fts.rowid
|
||||||
JOIN json_each(?2) AS following ON messages.author = following.value
|
JOIN json_each(?2) AS following ON messages.author = following.value
|
||||||
WHERE messages.author != ?4
|
WHERE messages.author != ?4
|
||||||
|
UNION
|
||||||
|
SELECT '👍' AS channel, MAX(messages.rowid) AS rowid FROM messages
|
||||||
|
JOIN json_each(?2) AS following ON messages.author = following.value
|
||||||
|
WHERE
|
||||||
|
messages.content ->> 'type' = 'vote' AND
|
||||||
|
messages.author != ?4
|
||||||
`,
|
`,
|
||||||
[
|
[
|
||||||
JSON.stringify(this.channels),
|
JSON.stringify(this.channels),
|
||||||
|
@ -214,6 +214,28 @@ class TfTabNewsFeedElement extends LitElement {
|
|||||||
[JSON.stringify(this.private_messages), 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 if (this.hash == '#👍') {
|
||||||
|
result = await tfrpc.rpc.query(
|
||||||
|
`
|
||||||
|
WITH votes AS (SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
|
FROM messages
|
||||||
|
JOIN json_each(?1) AS following ON messages.author = following.value
|
||||||
|
WHERE
|
||||||
|
messages.content ->> 'type' = 'vote' AND
|
||||||
|
(?2 IS NULL OR messages.timestamp >= ?2) AND messages.timestamp < ?3
|
||||||
|
ORDER BY timestamp DESC limit 20)
|
||||||
|
SELECT FALSE AS is_primary, messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
|
||||||
|
FROM votes
|
||||||
|
JOIN messages ON messages.id = votes.content ->> '$.vote.link'
|
||||||
|
UNION
|
||||||
|
SELECT TRUE AS is_primary, * FROM votes
|
||||||
|
`,
|
||||||
|
[
|
||||||
|
JSON.stringify(this.following),
|
||||||
|
start_time,
|
||||||
|
end_time,
|
||||||
|
]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let t0 = new Date();
|
let t0 = new Date();
|
||||||
let initial_messages = await tfrpc.rpc.query(
|
let initial_messages = await tfrpc.rpc.query(
|
||||||
|
@ -202,6 +202,12 @@ class TfTabNewsElement extends LitElement {
|
|||||||
style=${this.hash == '#@' ? 'font-weight: bold' : undefined}
|
style=${this.hash == '#@' ? 'font-weight: bold' : undefined}
|
||||||
>${this.unread_status('@')}@mentions</a
|
>${this.unread_status('@')}@mentions</a
|
||||||
>
|
>
|
||||||
|
<a
|
||||||
|
href="#👍"
|
||||||
|
class="w3-bar-item w3-button"
|
||||||
|
style=${this.hash == '#👍' ? 'font-weight: bold' : undefined}
|
||||||
|
>${this.unread_status('👍')}👍votes</a
|
||||||
|
>
|
||||||
<a
|
<a
|
||||||
href="#🔐"
|
href="#🔐"
|
||||||
class="w3-bar-item w3-button"
|
class="w3-bar-item w3-button"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user