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:
		@@ -1,5 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
	"type": "tildefriends-app",
 | 
			
		||||
	"emoji": "🦀",
 | 
			
		||||
	"previous": "&zAW/4XKD1wcsEM12bkzZD0V7Wyne3OPpQne2rtncxXM=.sha256"
 | 
			
		||||
	"previous": "&0ZtxnihH3oETfi0vhhEwc9O66SrjfiFcHDVBAIxICy0=.sha256"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@ class TfElement extends LitElement {
 | 
			
		||||
			channels_latest: {type: Object},
 | 
			
		||||
			guest: {type: Boolean},
 | 
			
		||||
			url: {type: String},
 | 
			
		||||
			private_messages: {type: Array},
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -334,7 +335,7 @@ class TfElement extends LitElement {
 | 
			
		||||
				JSON.stringify(cache)
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
		return cache.latest;
 | 
			
		||||
		return [cache.latest, cache.messages];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	async load_channels_latest(following) {
 | 
			
		||||
@@ -378,9 +379,11 @@ class TfElement extends LitElement {
 | 
			
		||||
		start_time = new Date();
 | 
			
		||||
		latest_private.then(function (latest) {
 | 
			
		||||
			self.channels_latest = Object.assign({}, self.channels_latest, {
 | 
			
		||||
				'🔐': latest,
 | 
			
		||||
				'🔐': latest[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}
 | 
			
		||||
					@channelsetunread=${this.channel_set_unread}
 | 
			
		||||
					.connections=${this.connections}
 | 
			
		||||
					.private_messages=${this.private_messages}
 | 
			
		||||
				></tf-tab-news>
 | 
			
		||||
			`;
 | 
			
		||||
		} else if (this.tab === 'connections') {
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,7 @@ class TfTabNewsFeedElement extends LitElement {
 | 
			
		||||
			loading: {type: Number},
 | 
			
		||||
			time_range: {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
 | 
			
		||||
					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
 | 
			
		||||
						(?2 IS NULL OR (messages.timestamp >= ?2)) AND messages.timestamp < ?3 AND
 | 
			
		||||
						json(messages.content) LIKE '"%'
 | 
			
		||||
					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);
 | 
			
		||||
		} else {
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ class TfTabNewsElement extends LitElement {
 | 
			
		||||
			channels_unread: {type: Object},
 | 
			
		||||
			channels_latest: {type: Object},
 | 
			
		||||
			connections: {type: Array},
 | 
			
		||||
			private_messages: {type: Array},
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -337,6 +338,7 @@ class TfTabNewsElement extends LitElement {
 | 
			
		||||
						@tf-expand=${this.on_expand}
 | 
			
		||||
						.channels_unread=${this.channels_unread}
 | 
			
		||||
						.channels_latest=${this.channels_latest}
 | 
			
		||||
						.private_messages=${this.private_messages}
 | 
			
		||||
					></tf-tab-news-feed>
 | 
			
		||||
				</div>
 | 
			
		||||
			</div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user