Consolidate similar request tags in the connection list. #59
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
			
		||||
{
 | 
			
		||||
	"type": "tildefriends-app",
 | 
			
		||||
	"emoji": "🐌",
 | 
			
		||||
	"previous": "&cN1BLgsD5fU8QzkNbtKR/Ie1fO3miBq8FVSpgNqFbrc=.sha256"
 | 
			
		||||
	"previous": "&6dwXL1RKL8t/RSV0UHBflkMnM8f8SV9VFvBZFqhW6LI=.sha256"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -105,6 +105,14 @@ class TfTabConnectionsElement extends LitElement {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	render_connection(connection) {
 | 
			
		||||
		let requests = Object.values(connection.requests.reduce(function(accumulator, value) {
 | 
			
		||||
			let key = `${value.name}:${Math.sign(value.request_number)}`;
 | 
			
		||||
			if (!accumulator[key]) {
 | 
			
		||||
				accumulator[key] = Object.assign({count: 0}, value);
 | 
			
		||||
			}
 | 
			
		||||
			accumulator[key].count++;
 | 
			
		||||
			return accumulator;
 | 
			
		||||
		}, {}));
 | 
			
		||||
		return html`
 | 
			
		||||
			<button
 | 
			
		||||
				class="w3-button w3-theme-d1"
 | 
			
		||||
@@ -116,8 +124,8 @@ class TfTabConnectionsElement extends LitElement {
 | 
			
		||||
			${connection.tunnel !== undefined
 | 
			
		||||
				? '🚇'
 | 
			
		||||
				: html`(${connection.host}:${connection.port})`}
 | 
			
		||||
			<div>${connection.requests.map(x => html`
 | 
			
		||||
				<span class="w3-tag w3-small">${x.request_number > 0 ? '🟩' : '🟥'} ${x.name}</span>
 | 
			
		||||
			<div>${requests.map(x => html`
 | 
			
		||||
				<span class="w3-tag w3-small">${x.request_number > 0 ? '🟩' : '🟥'} ${x.name} <span class="w3-badge w3-white" style=${x.count > 1 ? undefined : 'display: none'}>${x.count}</span></span>
 | 
			
		||||
			`)}</div>
 | 
			
		||||
			<ul>
 | 
			
		||||
				${this.connections
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user