diff --git a/apps/ssb.json b/apps/ssb.json
index 7e5943d5..333138a0 100644
--- a/apps/ssb.json
+++ b/apps/ssb.json
@@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🦀",
- "previous": "&IDzjVQjtPyhesUrl45qkZFjzWl0xVlj+2M/XXQRvXO0=.sha256"
+ "previous": "&01jXxJgs24zTcJk+csXeUWfm/MQ/+94Zy7K0r2OYmWw=.sha256"
}
diff --git a/apps/ssb/tf-message.js b/apps/ssb/tf-message.js
index 986fe696..fbacb5ef 100644
--- a/apps/ssb/tf-message.js
+++ b/apps/ssb/tf-message.js
@@ -644,6 +644,35 @@ class TfMessageElement extends LitElement {
return result;
}
+ channel_group_by_author() {
+ let sorted = this.message.messages
+ .map((x) => [
+ x.author,
+ x.content.subscribed ? 'subscribed to' : 'unsubscribed from',
+ x.content.channel,
+ 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], channels: group});
+ }
+ last = row;
+ group = [row[2]];
+ }
+ }
+ if (group) {
+ result.push({author: last[0], action: last[1], channels: group});
+ }
+ return result;
+ }
+
allow_unread() {
return (
this.channel == '@' ||
@@ -719,6 +748,55 @@ class TfMessageElement extends LitElement {
`);
}
+ } else if (this.message?.type === 'channel_group') {
+ if (this.expanded[this.expanded_key()]) {
+ return this.render_frame(html`
+
+ ${this.message.messages.map(
+ (x) =>
+ html``
+ )}
+
+
+ `);
+ } else {
+ return this.render_frame(html`
+
+ ${this.channel_group_by_author().map(
+ (x) => html`
+
+
+ ${x.action}
+ ${x.channels.map(
+ (y) => html` `
+ )}
+
+ `
+ )}
+
+
+ `);
+ }
} else if (this.message.placeholder) {
return this.render_frame(
html`
diff --git a/apps/ssb/tf-news.js b/apps/ssb/tf-news.js
index 6c89ef25..62ee2441 100644
--- a/apps/ssb/tf-news.js
+++ b/apps/ssb/tf-news.js
@@ -160,11 +160,29 @@ class TfNewsElement extends LitElement {
return recursive_sort(roots, true);
}
- group_following(messages) {
+ group_messages(messages) {
let result = [];
let group = [];
+ let type = undefined;
for (let message of messages) {
- if (message?.content?.type === 'contact') {
+ if (
+ message?.content?.type === 'contact' ||
+ message?.content?.type === 'channel'
+ ) {
+ if (type && message.content.type !== type) {
+ if (group.length == 1) {
+ result.push(group[0]);
+ group = [];
+ } else if (group.length > 1) {
+ result.push({
+ rowid: Math.max(...group.map((x) => x.rowid)),
+ type: `${type}_group`,
+ messages: group,
+ });
+ group = [];
+ }
+ }
+ type = message.content.type;
group.push(message);
} else {
if (group.length == 1) {
@@ -173,12 +191,13 @@ class TfNewsElement extends LitElement {
} else if (group.length > 1) {
result.push({
rowid: Math.max(...group.map((x) => x.rowid)),
- type: 'contact_group',
+ type: `${type}_group`,
messages: group,
});
group = [];
}
result.push(message);
+ type = undefined;
}
}
if (group.length == 1) {
@@ -187,7 +206,7 @@ class TfNewsElement extends LitElement {
} else if (group.length > 1) {
result.push({
rowid: Math.max(...group.map((x) => x.rowid)),
- type: 'contact_group',
+ type: `${type}_group`,
messages: group,
});
}
@@ -200,7 +219,7 @@ class TfNewsElement extends LitElement {
load_and_render(messages) {
let messages_by_id = this.process_messages(messages);
- let final_messages = this.group_following(
+ let final_messages = this.group_messages(
this.finalize_messages(messages_by_id)
);
let unread_rowid = -1;