forked from cory/tildefriends
		
	Expose stored connections on the connections tab. Still half-baked, but I'm going to use this.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4132 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -30,6 +30,12 @@ tfrpc.register(async function getBroadcasts() { | ||||
| tfrpc.register(async function getConnections() { | ||||
| 	return ssb.connections(); | ||||
| }); | ||||
| tfrpc.register(async function getStoredConnections() { | ||||
| 	return ssb.storedConnections(); | ||||
| }); | ||||
| tfrpc.register(async function forgetStoredConnection(connection) { | ||||
| 	return ssb.forgetStoredConnection(connection); | ||||
| }); | ||||
| tfrpc.register(async function createTunnel(portal, target) { | ||||
| 	return ssb.createTunnel(portal, target); | ||||
| }); | ||||
|   | ||||
| @@ -7,6 +7,7 @@ class TfTabConnectionsElement extends LitElement { | ||||
| 			broadcasts: {type: Array}, | ||||
| 			identities: {type: Array}, | ||||
| 			connections: {type: Array}, | ||||
| 			stored_connections: {type: Array}, | ||||
| 			users: {type: Object}, | ||||
| 		} | ||||
| 	} | ||||
| @@ -17,10 +18,14 @@ class TfTabConnectionsElement extends LitElement { | ||||
| 		this.broadcasts = []; | ||||
| 		this.identities = []; | ||||
| 		this.connections = []; | ||||
| 		this.stored_connections = []; | ||||
| 		this.users = {}; | ||||
| 		tfrpc.rpc.getAllIdentities().then(function(identities) { | ||||
| 			self.identities = identities || []; | ||||
| 		}); | ||||
| 		tfrpc.rpc.getStoredConnections().then(function(connections) { | ||||
| 			self.stored_connections = connections || []; | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	render_connection_summary(connection) { | ||||
| @@ -69,6 +74,11 @@ class TfTabConnectionsElement extends LitElement { | ||||
| 		` | ||||
| 	} | ||||
|  | ||||
| 	async forget_stored_connection(connection) { | ||||
| 		await tfrpc.rpc.forgetStoredConnection(connection); | ||||
| 		this.stored_connections = (await tfrpc.rpc.getStoredConnections()) || []; | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		let self = this; | ||||
| 		return html` | ||||
| @@ -91,6 +101,16 @@ class TfTabConnectionsElement extends LitElement { | ||||
| 					</li> | ||||
| 				`)} | ||||
| 			</ul> | ||||
| 			<h2>Stored Connections (WIP)</h2> | ||||
| 			<ul> | ||||
| 				${this.stored_connections.map(x => html` | ||||
| 					<li> | ||||
| 						<input type="button" @click=${() => self.forget_stored_connection(x)} value="Forget"></input> | ||||
| 						<input type="button" @click=${() => tfrpc.rpc.connect(x)} value="Connect"></input> | ||||
| 						${x.address}:${x.port} <tf-user id=${x.pubkey} .users=${self.users}></tf-user> | ||||
| 					</li> | ||||
| 				`)} | ||||
| 			</ul> | ||||
| 			<h2>Local Accounts</h2> | ||||
| 			<ul> | ||||
| 				${this.identities.map(x => html`<li><tf-user id=${x} .users=${this.users}></tf-user></li>`)} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user