forked from cory/tildefriends
Fix a death spiral.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4612 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
280dee0438
commit
dfe5d51d04
@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "📝",
|
||||
"previous": "&5DCHb4dlFnAlInCiIb1v7XG+w/t11fVwbpqM8aVLEfQ=.sha256"
|
||||
"previous": "&263ro6L8r7tRcrC7LjvY59gC72DlEM/nehd6s7S08sQ=.sha256"
|
||||
}
|
@ -153,6 +153,7 @@ tfrpc.register(async function collection(ids, kind, parent, max_rowid, data) {
|
||||
`, [JSON.stringify(ids), max_rowid ?? -1, rowid, kind, parent], function(row) {
|
||||
rows.push(row);
|
||||
});
|
||||
max_rowid = rowid;
|
||||
for (let row of rows) {
|
||||
if (await process_message(whoami, data, row, kind, parent)) {
|
||||
modified = true;
|
||||
|
@ -43,6 +43,7 @@ class TfCollectionsAppElement extends LitElement {
|
||||
let wikis;
|
||||
while (true)
|
||||
{
|
||||
console.log('read_wikis', max_rowid);
|
||||
[max_rowid, wikis] = await tfrpc.rpc.collection(this.owner_ids, 'wiki', undefined, max_rowid, wikis);
|
||||
this.wikis = wikis;
|
||||
this.update_wiki();
|
||||
@ -58,8 +59,10 @@ class TfCollectionsAppElement extends LitElement {
|
||||
let wiki_docs;
|
||||
while (true)
|
||||
{
|
||||
console.log('read_wiki_docs', max_rowid);
|
||||
[max_rowid, wiki_docs] = await tfrpc.rpc.collection(this.owner_ids, 'wiki-doc', this.wiki?.id, max_rowid, wiki_docs);
|
||||
if (this.wiki?.id !== start_id) {
|
||||
console.log('ending read_wiki_docs');
|
||||
break;
|
||||
}
|
||||
this.wiki_docs = wiki_docs;
|
||||
@ -130,23 +133,6 @@ class TfCollectionsAppElement extends LitElement {
|
||||
this.update_hash();
|
||||
}
|
||||
|
||||
async on_wiki_publish(event) {
|
||||
let blob_id = event.detail.id;
|
||||
let message = {
|
||||
type: 'wiki-doc',
|
||||
key: this.wiki_doc.id,
|
||||
parent: this.wiki_doc.parent,
|
||||
blob: blob_id,
|
||||
};
|
||||
if (event.detail.draft) {
|
||||
message.recps = this.wiki_doc.editors;
|
||||
print(message);
|
||||
message = await tfrpc.rpc.encrypt(this.whoami, this.wiki_doc.editors, JSON.stringify(message));
|
||||
}
|
||||
print(message);
|
||||
await tfrpc.rpc.appendMessage(this.whoami, message);
|
||||
}
|
||||
|
||||
render() {
|
||||
let self = this;
|
||||
return html`
|
||||
@ -166,8 +152,7 @@ class TfCollectionsAppElement extends LitElement {
|
||||
${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html`
|
||||
<tf-wiki-doc
|
||||
whoami=${this.whoami}
|
||||
.value=${this.wiki_doc}
|
||||
@publish=${this.on_wiki_publish}></tf-wiki-doc>
|
||||
.value=${this.wiki_doc}></tf-wiki-doc>
|
||||
` : undefined}
|
||||
`;
|
||||
}
|
||||
|
@ -38,27 +38,30 @@ class TfWikiDocElement extends LitElement {
|
||||
this.is_editing = false;
|
||||
}
|
||||
|
||||
async on_save_draft() {
|
||||
async append_message(draft) {
|
||||
let id = await tfrpc.rpc.store_blob(this.blob);
|
||||
this.dispatchEvent(new CustomEvent('publish', {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
id: id,
|
||||
draft: true,
|
||||
},
|
||||
}));
|
||||
let message = {
|
||||
type: 'wiki-doc',
|
||||
key: this.value.id,
|
||||
parent: this.value.parent,
|
||||
blob: id,
|
||||
};
|
||||
if (draft) {
|
||||
message.recps = this.value.editors;
|
||||
print(message);
|
||||
message = await tfrpc.rpc.encrypt(this.whoami, this.value.editors, JSON.stringify(message));
|
||||
}
|
||||
print(message);
|
||||
await tfrpc.rpc.appendMessage(this.whoami, message);
|
||||
this.is_editing = false;
|
||||
}
|
||||
|
||||
async on_save_draft() {
|
||||
return this.append_message(true);
|
||||
}
|
||||
|
||||
async on_publish() {
|
||||
let id = await tfrpc.rpc.store_blob(this.blob);
|
||||
this.dispatchEvent(new CustomEvent('publish', {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
id: id,
|
||||
},
|
||||
}));
|
||||
this.is_editing = false;
|
||||
return this.append_message(false);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
Loading…
Reference in New Issue
Block a user