diff --git a/apps/wiki.json b/apps/wiki.json index 1328130d..fa107554 100644 --- a/apps/wiki.json +++ b/apps/wiki.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "📝", - "previous": "&dWRvF06sP9/nrZmGjF+px+KFPEjT6bg2/u7vENWvUyM=.sha256" + "previous": "&Unu5AZjyD0RF/QzPh2/u7DuU8IPuSFSjYFkmiWAWcqk=.sha256" } \ No newline at end of file diff --git a/apps/wiki/app.js b/apps/wiki/app.js index 187a9675..42c4239f 100644 --- a/apps/wiki/app.js +++ b/apps/wiki/app.js @@ -32,6 +32,7 @@ tfrpc.register(async function following(ids, depth) { }); tfrpc.register(async function appendMessage(id, message) { + print('APPENDING', message); return ssb.appendMessageWithIdentity(id, message); }); @@ -123,6 +124,9 @@ async function process_message(whoami, collection, message, kind, parent) { } } else { collection[message.id] = Object.assign(content, {id: message.id}); + if (!collection[message.id].editors) { + collection[message.id].editors = [message.author]; + } } return true; } diff --git a/apps/wiki/tf-collections-app.js b/apps/wiki/tf-collections-app.js index 90183328..ad3a1638 100644 --- a/apps/wiki/tf-collections-app.js +++ b/apps/wiki/tf-collections-app.js @@ -7,6 +7,7 @@ class TfCollectionsAppElement extends LitElement { ids: {type: Array}, owner_ids: {type: Array}, whoami: {type: String}, + following: {type: Array}, wikis: {type: Object}, wiki_docs: {type: Object}, @@ -14,6 +15,8 @@ class TfCollectionsAppElement extends LitElement { wiki: {type: Object}, wiki_doc: {type: Object}, hash: {type: String}, + + adding_editor: {type: Boolean}, }; } @@ -21,6 +24,7 @@ class TfCollectionsAppElement extends LitElement { super(); this.ids = []; this.owner_ids = []; + this.following = []; this.load(); let self = this; tfrpc.register(function hash_changed(hash) { @@ -33,6 +37,7 @@ 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(); await this.read_wikis(); await this.read_Wiki_docs(); @@ -45,8 +50,7 @@ class TfCollectionsAppElement extends LitElement { while (true) { console.log('read_wikis', this.whoami); - let following = Object.keys(await tfrpc.rpc.following([this.whoami], 2)).sort(); - [max_rowid, wikis] = await tfrpc.rpc.collection(following, 'wiki', undefined, max_rowid, wikis, false); + [max_rowid, wikis] = await tfrpc.rpc.collection(this.following, 'wiki', undefined, max_rowid, wikis, false); console.log('read ->', wikis); if (this.whoami !== start_whoami) { break; @@ -129,6 +133,7 @@ class TfCollectionsAppElement extends LitElement { this.wiki = event.detail.value; this.wiki_doc = undefined; this.wiki_docs = undefined; + this.adding_editor = false; this.update_hash(); this.read_wiki_docs(); } @@ -148,6 +153,21 @@ class TfCollectionsAppElement extends LitElement { }); } + async on_add_editor(event) { + let id = this.shadowRoot.getElementById('add_editor').value; + let editors = [...this.wiki.editors]; + if (editors.indexOf(id) == -1) { + editors.push(id); + editors.sort(); + } + await tfrpc.rpc.appendMessage(this.whoami, { + type: 'wiki', + key: this.wiki.id, + editors: editors, + }); + this.adding_editor = false; + } + async on_wiki_tombstone(event) { await tfrpc.rpc.appendMessage(this.whoami, { type: 'wiki', @@ -224,6 +244,16 @@ class TfCollectionsAppElement extends LitElement { @rename=${this.on_wiki_doc_rename} @tombstone=${this.on_wiki_doc_tombstone} @change=${this.on_wiki_doc_changed}>`)} +
+ Editors: ${this.wiki?.editors} + +
+ + + + +
+
${this.wiki_doc && this.wiki_doc.parent === this.wiki?.id ? html`