forked from cory/tildefriends
Mostly fiddling with the connections tab.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4021 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -30,6 +30,9 @@ tfrpc.register(async function getBroadcasts() {
|
||||
tfrpc.register(async function getConnections() {
|
||||
return ssb.connections();
|
||||
});
|
||||
tfrpc.register(async function closeConnection(id) {
|
||||
await ssb.closeConnection(id);
|
||||
});
|
||||
tfrpc.register(async function query(sql, args) {
|
||||
let result = [];
|
||||
await ssb.sqlStream(sql, args, function callback(row) {
|
||||
|
@ -11,7 +11,6 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Tilde Friends</h1>
|
||||
<tf-app/>
|
||||
<script>window.litDisableBundleWarning = true;</script>
|
||||
<script src="commonmark.min.js"></script>
|
||||
|
@ -136,6 +136,7 @@ class TfComposeElement extends LitElement {
|
||||
console.log('Would post:', message);
|
||||
tfrpc.rpc.appendMessage(this.whoami, message).then(function() {
|
||||
edit.value = '';
|
||||
self.mentions = {};
|
||||
self.changed();
|
||||
}).catch(function(error) {
|
||||
alert(error.message);
|
||||
|
@ -36,15 +36,38 @@ class TfTabConnectionsElement extends LitElement {
|
||||
this._emit_change();
|
||||
}
|
||||
|
||||
render_connection_summary(connection) {
|
||||
if (connection.address && connection.port) {
|
||||
return html`(<small>${connection.address}:${connection.port}</small>)`;
|
||||
} else {
|
||||
return JSON.stringify(connection);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let self = this;
|
||||
return html`
|
||||
<h2>New Connection</h2>
|
||||
<textarea id="code"></textarea>
|
||||
<input type="button" @click=${() => tfrpc.rpc.connect(self.renderRoot.getElementById('code').value)} value="Connect"></input>
|
||||
<h2>Broadcasts</h2>
|
||||
<ul>
|
||||
${this.broadcasts.map(x => html`<li><tf-user id=${x.pubkey} .users=${this.users}></tf-user></li>`)}
|
||||
${this.broadcasts.map(x => html`
|
||||
<li>
|
||||
<input type="button" @click=${() => tfrpc.rpc.connect(x)} value="Connect"></input>
|
||||
<tf-user id=${x.pubkey} .users=${this.users}></tf-user>
|
||||
${self.render_connection_summary(x)}
|
||||
</li>
|
||||
`)}
|
||||
</ul>
|
||||
<h2>Connections</h2>
|
||||
<ul>
|
||||
${this.connections.map(x => html`<li><tf-user id=${x} .users=${this.users}></tf-user></li>`)}
|
||||
${this.connections.map(x => html`
|
||||
<li>
|
||||
<input type="button" @click=${() => tfrpc.rpc.closeConnection(x)} value="Close"></input>
|
||||
<tf-user id=${x} .users=${this.users}></tf-user>
|
||||
</li>
|
||||
`)}
|
||||
</ul>
|
||||
<h2>Local Accounts</h2>
|
||||
<ul>
|
||||
|
@ -129,7 +129,7 @@ class TfTabNewsElement extends LitElement {
|
||||
let news = this.renderRoot?.getElementById('news');
|
||||
if (news) {
|
||||
console.log('injecting messages', news.messages);
|
||||
news.messages = [...this.unread, ...news.messages];
|
||||
news.messages = Object.values(Object.fromEntries([...this.unread, ...news.messages].map(x => [x.id, x])));
|
||||
this.dispatchEvent(new CustomEvent('refresh'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user