Remove importing and export from the ssb app. I like it better as the separate sneaker app.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4294 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -12,7 +12,6 @@ class TfTabNewsElement extends LitElement {
|
||||
following: {type: Array},
|
||||
drafts: {type: Object},
|
||||
expanded: {type: Object},
|
||||
import_progress: {type: Object},
|
||||
};
|
||||
}
|
||||
|
||||
@ -29,7 +28,6 @@ class TfTabNewsElement extends LitElement {
|
||||
this.cache = {};
|
||||
this.drafts = {};
|
||||
this.expanded = {};
|
||||
this.import_progress = null;
|
||||
tfrpc.rpc.localStorageGet('drafts').then(function(d) {
|
||||
self.drafts = JSON.parse(d || '{}');
|
||||
});
|
||||
@ -104,50 +102,12 @@ class TfTabNewsElement extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
import_data() {
|
||||
let self = this;
|
||||
let input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.onchange = async function(event) {
|
||||
self.import_progress = {name: 'loading'};
|
||||
let zip = new JSZip();
|
||||
let file = await zip.loadAsync(event.target.files[0]);
|
||||
let progress = 0;
|
||||
let messages = JSON.parse(await file.file('messages.txt').async('string'));
|
||||
for (let message of messages) {
|
||||
self.import_progress = {name: 'messages', value: progress++, max: messages.length};
|
||||
await tfrpc.rpc.store_message(message);
|
||||
}
|
||||
let blobs = [];
|
||||
file.forEach(function(path, entry) {
|
||||
if (path != 'messages.txt' && !entry.dir) {
|
||||
blobs.push(entry);
|
||||
}
|
||||
});
|
||||
progress = 0;
|
||||
for (let blob of blobs) {
|
||||
self.import_progress = {name: 'blobs', value: progress++, max: blobs.length};
|
||||
console.log(await tfrpc.rpc.store_blob(await blob.async('arraybuffer')));
|
||||
}
|
||||
self.import_progress = undefined;
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
|
||||
render() {
|
||||
let profile = this.hash.startsWith('#@') ?
|
||||
html`<tf-profile id=${this.hash.substring(1)} whoami=${this.whoami} .users=${this.users}></tf-profile>` : undefined;
|
||||
let import_state = html`<input type="button" value="Import" @click=${this.import_data}></input>`;
|
||||
if (this.import_progress) {
|
||||
if (this.import_progress.max) {
|
||||
import_state = html`${this.import_progress.name} <progress value=${this.import_progress.value} max=${this.import_progress.max}></progress>`;
|
||||
} else {
|
||||
import_state = html`${this.import_progress.name} <progress></progress>`;
|
||||
}
|
||||
}
|
||||
return html`
|
||||
<div><input type="button" value=${this.new_messages_text()} @click=${this.show_more}></input></div>
|
||||
<a target="_top" href="#" ?hidden=${this.hash.length <= 1}>🏠Home</a> ${import_state}
|
||||
<a target="_top" href="#" ?hidden=${this.hash.length <= 1}>🏠Home</a>
|
||||
<div>Welcome, <tf-user id=${this.whoami} .users=${this.users}></tf-user>!</div>
|
||||
<div><tf-compose whoami=${this.whoami} .users=${this.users} .drafts=${this.drafts} @tf-draft=${this.draft}></tf-compose></div>
|
||||
${profile}
|
||||
|
Reference in New Issue
Block a user