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:
		| @@ -1,5 +1,5 @@ | |||||||
| { | { | ||||||
|   "type": "tildefriends-app", |   "type": "tildefriends-app", | ||||||
|   "emoji": "📝", |   "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) { | 		`, [JSON.stringify(ids), max_rowid ?? -1, rowid, kind, parent], function(row) { | ||||||
| 			rows.push(row); | 			rows.push(row); | ||||||
| 		}); | 		}); | ||||||
|  | 		max_rowid = rowid; | ||||||
| 		for (let row of rows) { | 		for (let row of rows) { | ||||||
| 			if (await process_message(whoami, data, row, kind, parent)) { | 			if (await process_message(whoami, data, row, kind, parent)) { | ||||||
| 				modified = true; | 				modified = true; | ||||||
|   | |||||||
| @@ -43,6 +43,7 @@ class TfCollectionsAppElement extends LitElement { | |||||||
| 		let wikis; | 		let wikis; | ||||||
| 		while (true) | 		while (true) | ||||||
| 		{ | 		{ | ||||||
|  | 			console.log('read_wikis', max_rowid); | ||||||
| 			[max_rowid, wikis] = await tfrpc.rpc.collection(this.owner_ids, 'wiki', undefined, max_rowid, wikis); | 			[max_rowid, wikis] = await tfrpc.rpc.collection(this.owner_ids, 'wiki', undefined, max_rowid, wikis); | ||||||
| 			this.wikis = wikis; | 			this.wikis = wikis; | ||||||
| 			this.update_wiki(); | 			this.update_wiki(); | ||||||
| @@ -58,8 +59,10 @@ class TfCollectionsAppElement extends LitElement { | |||||||
| 		let wiki_docs; | 		let wiki_docs; | ||||||
| 		while (true) | 		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); | 			[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) { | 			if (this.wiki?.id !== start_id) { | ||||||
|  | 				console.log('ending read_wiki_docs'); | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
| 			this.wiki_docs = wiki_docs; | 			this.wiki_docs = wiki_docs; | ||||||
| @@ -130,23 +133,6 @@ class TfCollectionsAppElement extends LitElement { | |||||||
| 		this.update_hash(); | 		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() { | 	render() { | ||||||
| 		let self = this; | 		let self = this; | ||||||
| 		return html` | 		return html` | ||||||
| @@ -166,8 +152,7 @@ class TfCollectionsAppElement extends LitElement { | |||||||
| 			${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html` | 			${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html` | ||||||
| 				<tf-wiki-doc | 				<tf-wiki-doc | ||||||
| 					whoami=${this.whoami} | 					whoami=${this.whoami} | ||||||
| 					.value=${this.wiki_doc} | 					.value=${this.wiki_doc}></tf-wiki-doc> | ||||||
| 					@publish=${this.on_wiki_publish}></tf-wiki-doc> |  | ||||||
| 			` : undefined} | 			` : undefined} | ||||||
| 		`; | 		`; | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -38,27 +38,30 @@ class TfWikiDocElement extends LitElement { | |||||||
| 		this.is_editing = false; | 		this.is_editing = false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	async on_save_draft() { | 	async append_message(draft) { | ||||||
| 		let id = await tfrpc.rpc.store_blob(this.blob); | 		let id = await tfrpc.rpc.store_blob(this.blob); | ||||||
| 		this.dispatchEvent(new CustomEvent('publish', { | 		let message = { | ||||||
| 			bubbles: true, | 			type: 'wiki-doc', | ||||||
| 			detail: { | 			key: this.value.id, | ||||||
| 				id: id, | 			parent: this.value.parent, | ||||||
| 				draft: true, | 			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; | 		this.is_editing = false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	async on_save_draft() { | ||||||
|  | 		return this.append_message(true); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	async on_publish() { | 	async on_publish() { | ||||||
| 		let id = await tfrpc.rpc.store_blob(this.blob); | 		return this.append_message(false); | ||||||
| 		this.dispatchEvent(new CustomEvent('publish', { |  | ||||||
| 			bubbles: true, |  | ||||||
| 			detail: { |  | ||||||
| 				id: id, |  | ||||||
| 			}, |  | ||||||
| 		})); |  | ||||||
| 		this.is_editing = false; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	render() { | 	render() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user