Bring back buttons to attach apps.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4014 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-10-18 23:00:57 +00:00
parent 60d1ea9d39
commit 54ebd0e643
3 changed files with 60 additions and 1 deletions

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&XCpiJOtpMzQz5Zo+Hu9f3ppQON9PxFdV4XnS2Ae+Ye8=.sha256","lit-all.min.js":"&N4A12AsifdQgwdpII0SFtG513BfoLpmPjdJ9VTDftpg=.sha256","index.html":"&Vpp3ezlQiD5guf1P6yZhpcNMnO0u+uQoil3hNkwiIp4=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&oFY9wO4MnujgfGNGv4VggHc5V5JwX4C8csqKZ6KJYbE=.sha256","tf-id-picker.js":"&9BDffV4HY9FqhL7XI4it+UQJB4cYwbDNsY3S1cxy2vw=.sha256","tf-app.js":"&qqpOZHnkJQevhLGPUEJ7br2S/LNH+nQtC91vz3CrYrE=.sha256","tf-message.js":"&yo0PiAQLZ2NlYjwCm2VwWH4BZx71TsAQjpJ02RGNnf4=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&N2yKZwFnb2GbPeipgQtu6xFvezENNOgud9G7EhCQ/K0=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&VfFVhkWbMD9MdljdjPbSc5R1YYAj4z9C8W2Gxij65sc=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&pqYLDE/13PyEt2ceeFqvnwZ8NqWfPfpDBt4vP8SeHbs=.sha256","tf-styles.js":"&Zw90HptAvGwX/vBnEhRVfNrYjMSssFnnKpp8bzwXQH0=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&6ialbh/M2eBCDH6wFyoOHyDqG9QHbyIrzvRK+CgeyRc=.sha256","tf-tab-connections.js":"&jSnF/5NmgqxRze1XQAEGOW5mPzOV1/8aCyrDRZu34IQ=.sha256","tf-news.js":"&p9jlv5IEBe6Vi6cT/jAZ+GxOABqZue4DinCLiqN/V9I=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256"}} {"type":"tildefriends-app","files":{"app.js":"&0pjNvkWm12JIkr7z9az5bdGjrM1VhEiQawf7hnMhvwA=.sha256","lit-all.min.js":"&N4A12AsifdQgwdpII0SFtG513BfoLpmPjdJ9VTDftpg=.sha256","index.html":"&Vpp3ezlQiD5guf1P6yZhpcNMnO0u+uQoil3hNkwiIp4=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&oFY9wO4MnujgfGNGv4VggHc5V5JwX4C8csqKZ6KJYbE=.sha256","tf-id-picker.js":"&9BDffV4HY9FqhL7XI4it+UQJB4cYwbDNsY3S1cxy2vw=.sha256","tf-app.js":"&qqpOZHnkJQevhLGPUEJ7br2S/LNH+nQtC91vz3CrYrE=.sha256","tf-message.js":"&yo0PiAQLZ2NlYjwCm2VwWH4BZx71TsAQjpJ02RGNnf4=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&N2yKZwFnb2GbPeipgQtu6xFvezENNOgud9G7EhCQ/K0=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&oM+e4/FIA7X6bkap7m9XmO+tbUljHJxlXpJjnM9veG8=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&pqYLDE/13PyEt2ceeFqvnwZ8NqWfPfpDBt4vP8SeHbs=.sha256","tf-styles.js":"&Zw90HptAvGwX/vBnEhRVfNrYjMSssFnnKpp8bzwXQH0=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&6ialbh/M2eBCDH6wFyoOHyDqG9QHbyIrzvRK+CgeyRc=.sha256","tf-tab-connections.js":"&jSnF/5NmgqxRze1XQAEGOW5mPzOV1/8aCyrDRZu34IQ=.sha256","tf-news.js":"&p9jlv5IEBe6Vi6cT/jAZ+GxOABqZue4DinCLiqN/V9I=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256"}}

View File

@ -61,6 +61,12 @@ tfrpc.register(async function store_blob(blob) {
} }
return await ssb.blobStore(blob); return await ssb.blobStore(blob);
}); });
tfrpc.register(async function get_blob(id) {
return utf8Decode(await ssb.blobGet(id));
});
tfrpc.register(function apps() {
return core.apps();
});
ssb.addEventListener('broadcasts', async function() { ssb.addEventListener('broadcasts', async function() {
await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts()); await tfrpc.rpc.set('broadcasts', await ssb.getBroadcasts());
}); });

View File

@ -12,6 +12,7 @@ class TfComposeElement extends LitElement {
root: {type: String}, root: {type: String},
branch: {type: String}, branch: {type: String},
mentions: {type: Object}, mentions: {type: Object},
apps: {type: Object},
} }
} }
@ -23,6 +24,7 @@ class TfComposeElement extends LitElement {
this.root = undefined; this.root = undefined;
this.branch = undefined; this.branch = undefined;
this.mentions = {}; this.mentions = {};
this.apps = undefined;
} }
changed(event) { changed(event) {
@ -183,6 +185,55 @@ class TfComposeElement extends LitElement {
</div>`; </div>`;
} }
render_attach_app() {
let self = this;
async function attach_selected_app() {
let name = self.renderRoot.getElementById('select').value;
let id = self.apps[name];
let mentions = {};
mentions[id] = {
name: name,
link: id,
type: 'application/tildefriends',
};
if (name && id) {
let app = JSON.parse(await tfrpc.rpc.get_blob(id));
for (let entry of Object.entries(app.files)) {
mentions[entry[1]] = {
name: entry[0],
link: entry[1],
};
}
}
this.mentions = Object.assign(this.mentions || {}, mentions);
this.apps = null;
}
if (this.apps) {
return html`
<div>
<select id="select">
${Object.keys(self.apps).map(app => html`<option value=${app}>${app}</option>`)}
</select>
<input type="button" value="Attach" @click=${attach_selected_app}></input>
<input type="button" value="Cancel" @click=${() => this.apps = null}></input>
</div>
`;
}
}
render_attach_app_button() {
async function attach_app() {
this.apps = await tfrpc.rpc.apps();
}
if (!this.apps) {
return html`<input type="button" value="Attach App" @click=${attach_app}></input>`
} else {
return html`<input type="button" value="Discard App" @click=${() => this.apps = null}></input>`
}
}
render() { render() {
let self = this; let self = this;
let result = html` let result = html`
@ -191,8 +242,10 @@ class TfComposeElement extends LitElement {
<div id="preview" style="flex: 1 0 50%"></div> <div id="preview" style="flex: 1 0 50%"></div>
</div> </div>
${Object.values(this.mentions).map(x => self.render_mention(x))} ${Object.values(this.mentions).map(x => self.render_mention(x))}
${this.render_attach_app()}
<input type="button" value="Submit" @click=${this.submit}></input> <input type="button" value="Submit" @click=${this.submit}></input>
<input type="button" value="Attach" @click=${this.attach}></input> <input type="button" value="Attach" @click=${this.attach}></input>
${this.render_attach_app_button()}
<input type="button" value="Discard" @click=${this.discard}></input> <input type="button" value="Discard" @click=${this.discard}></input>
`; `;
return result; return result;