forked from cory/tildefriends
		
	Support removing editors, I think, and include wikis from the app owner and from the authenticated user.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4629 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| { | ||||
|   "type": "tildefriends-app", | ||||
|   "emoji": "📝", | ||||
|   "previous": "&Unu5AZjyD0RF/QzPh2/u7DuU8IPuSFSjYFkmiWAWcqk=.sha256" | ||||
|   "previous": "&G+R9QBUONLBiFGEecnE0w/qJPLOlj3WqtVUVemBdpbo=.sha256" | ||||
| } | ||||
| @@ -7,9 +7,9 @@ | ||||
| 		<tf-collections-app></tf-collections-app> | ||||
| 		<script src="commonmark.min.js"></script> | ||||
| 		<script>window.litDisableBundleWarning = true;</script> | ||||
| 		<script src="tf-collections-app.js" type="module"></script> | ||||
| 		<script src="tf-collection.js" type="module"></script> | ||||
| 		<script src="tf-id-picker.js" type="module"></script> | ||||
| 		<script src="tf-wiki-doc.js" type="module"></script> | ||||
| 		<script src="tf-wiki-app.js" type="module"></script> | ||||
| 	</body> | ||||
| </html> | ||||
| @@ -17,6 +17,7 @@ class TfCollectionsAppElement extends LitElement { | ||||
| 			hash: {type: String}, | ||||
| 
 | ||||
| 			adding_editor: {type: Boolean}, | ||||
| 			expand_editors: {type: Boolean}, | ||||
| 		}; | ||||
| 	} | ||||
| 
 | ||||
| @@ -37,7 +38,8 @@ class TfCollectionsAppElement extends LitElement { | ||||
| 		this.ids = await tfrpc.rpc.getIdentities(); | ||||
| 		this.owner_ids = await tfrpc.rpc.getOwnerIdentities(); | ||||
| 		this.whoami = await tfrpc.rpc.localStorageGet('collections_whoami'); | ||||
| 		this.following = Object.keys(await tfrpc.rpc.following([this.whoami], 2)).sort(); | ||||
| 		let ids = [...new Set([...this.owner_ids, this.whoami])].sort(); | ||||
| 		this.following = Object.keys(await tfrpc.rpc.following(ids, 2)).sort(); | ||||
| 
 | ||||
| 		await this.read_wikis(); | ||||
| 		await this.read_Wiki_docs(); | ||||
| @@ -168,6 +170,20 @@ class TfCollectionsAppElement extends LitElement { | ||||
| 		this.adding_editor = false; | ||||
| 	} | ||||
| 
 | ||||
| 	async on_remove_editor(id) { | ||||
| 		if (confirm(`Are you sure you want to remove ${id} as an editor?`)) { | ||||
| 			let editors = [...this.wiki.editors]; | ||||
| 			if (editors.indexOf(id) != -1) { | ||||
| 				editors = editors.filter(x => x !== id); | ||||
| 			} | ||||
| 			await tfrpc.rpc.appendMessage(this.whoami, { | ||||
| 				type: 'wiki', | ||||
| 				key: this.wiki.id, | ||||
| 				editors: editors, | ||||
| 			}); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	async on_wiki_tombstone(event) { | ||||
| 		await tfrpc.rpc.appendMessage(this.whoami, { | ||||
| 			type: 'wiki', | ||||
| @@ -244,8 +260,12 @@ class TfCollectionsAppElement extends LitElement { | ||||
| 					@rename=${this.on_wiki_doc_rename} | ||||
| 					@tombstone=${this.on_wiki_doc_tombstone} | ||||
| 					@change=${this.on_wiki_doc_changed}></tf-collection>`)} | ||||
| 				<div ?hidden=${!this.wiki?.editors}> | ||||
| 					Editors: ${this.wiki?.editors} | ||||
| 				<button @click=${() => self.expand_editors = !self.expand_editors}>${this.wiki?.editors?.length} editor${this.wiki?.editors?.length > 1 ? 's' : ''}</button> | ||||
| 				<div ?hidden=${!this.wiki?.editors || !this.expand_editors}> | ||||
| 					<div> | ||||
| 						<ul> | ||||
| 							${this.wiki?.editors.map(id => html`<li><button ?hidden=${id == this.whoami} @click=${() => self.on_remove_editor(id)}>x</button> ${id}</li>`)} | ||||
| 							<li> | ||||
| 								<button @click=${() => self.adding_editor = true} ?hidden=${this.wiki?.editors?.indexOf(this.whoami) == -1 || this.adding_editor}>+</button> | ||||
| 								<div ?hidden=${!this.adding_editor}> | ||||
| 									<label for="add_editor">Add Editor:</label> | ||||
| @@ -253,6 +273,9 @@ class TfCollectionsAppElement extends LitElement { | ||||
| 									<button @click=${this.on_add_editor}>Add Editor</button> | ||||
| 									<button @click=${() => self.adding_editor = false}>x</button> | ||||
| 								</div> | ||||
| 							</li> | ||||
| 						</ul> | ||||
| 					</div> | ||||
| 				</div> | ||||
| 			</div> | ||||
| 			${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html` | ||||
		Reference in New Issue
	
	Block a user