Support replying to a thread.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3726 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2021-12-31 19:01:53 +00:00
parent 4e359c3f5c
commit 3026443c1e
4 changed files with 15 additions and 1 deletions

View File

@ -1 +1 @@
{"type":"tildefriends-app","files":{"app.js":"&W9Hxi6cX37sg8daxdiuvZMLJj0FJLoVAYE65T/X6Yp8=.sha256","index.html":"&mQ2fDeVm6D6+pwmF/6K04H1q5saq/Fl6Cq23UKlvJls=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&KmUw2D8yehJU95RQ+8DWP69w/5wK7yWR6fUc5/LIpio=.sha256","tf-message.js":"&c7NMlMBi2UZE7ChUXd3h4ih0q2myuHhp3PpNUfBRvHM=.sha256","tf.js":"&I45p0703bQNAWq/5wFHdVrwM3z+5FL4K8QmDTfSnBAU=.sha256","commonmark.min.js":"&5x6ek3tFrKTZX6hXNNyFsjmhvrjmWpUkwuuaiyVV1Us=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256"}} {"type":"tildefriends-app","files":{"app.js":"&W9Hxi6cX37sg8daxdiuvZMLJj0FJLoVAYE65T/X6Yp8=.sha256","index.html":"&dyJyLJJqx+qcGXY9CYLY6Jxj/T/ZK+Z8ARa8MhLVhJI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&KmUw2D8yehJU95RQ+8DWP69w/5wK7yWR6fUc5/LIpio=.sha256","tf-message.js":"&oQggZN26PtRi4Ce9HY8TKVJ9jRrYWLRE5tN+3yHwEJE=.sha256","tf.js":"&xNEPeISBMcsMcE7o1XFrj5JT5z+UMEGPajLQYZYfh2k=.sha256","commonmark.min.js":"&5x6ek3tFrKTZX6hXNNyFsjmhvrjmWpUkwuuaiyVV1Us=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256"}}

View File

@ -53,6 +53,7 @@
<div class="md-title">What's up?</div> <div class="md-title">What's up?</div>
</md-card-header> </md-card-header>
<md-card-content> <md-card-content>
<md-chip v-if="reply_root || reply_branch" md-deletable @md-delete="reply_root = null; reply_branch = null">Replying in thread {{reply_root}} to message {{reply_branch}}</md-chip>
<md-chip v-for="link in Object.keys(mentions)" v-bind:key="link" md-deletable @md-delete="remove_from_mentions(link)"> <md-chip v-for="link in Object.keys(mentions)" v-bind:key="link" md-deletable @md-delete="remove_from_mentions(link)">
{{mentions[link].name}}: {{link}} {{mentions[link].name}}: {{link}}
</md-chip> </md-chip>

View File

@ -17,6 +17,10 @@ Vue.component('tf-message', {
var writer = new commonmark.HtmlRenderer(); var writer = new commonmark.HtmlRenderer();
return writer.render(reader.parse(md)); return writer.render(reader.parse(md));
}, },
set_reply: function() {
g_data.reply_root = this.content_json.root || this.message.id;
g_data.reply_branch = this.message.id;
}
}, },
template: `<md-app class="md-elevation-8" style="margin: 1em" v-if="!content_json || ['pub', 'vote'].indexOf(content_json.type) == -1"> template: `<md-app class="md-elevation-8" style="margin: 1em" v-if="!content_json || ['pub', 'vote'].indexOf(content_json.type) == -1">
<md-app-toolbar> <md-app-toolbar>
@ -30,6 +34,7 @@ Vue.component('tf-message', {
<md-menu-content> <md-menu-content>
<md-menu-item v-if="!showRaw" v-on:click="showRaw = true">View Raw</md-menu-item> <md-menu-item v-if="!showRaw" v-on:click="showRaw = true">View Raw</md-menu-item>
<md-menu-item v-else v-on:click="showRaw = false">View Message</md-menu-item> <md-menu-item v-else v-on:click="showRaw = false">View Message</md-menu-item>
<md-menu-item @click="set_reply()">Reply</md-menu-item>
</md-menu-content> </md-menu-content>
</md-menu> </md-menu>
</div> </div>

View File

@ -11,6 +11,8 @@ var g_data = {
pubs: [], pubs: [],
votes: {}, votes: {},
apps: {}, apps: {},
reply_root: null,
reply_branch: null,
mentions: {}, mentions: {},
unread: 0, unread: 0,
}; };
@ -121,12 +123,18 @@ window.addEventListener('load', function() {
type: 'post', type: 'post',
text: document.getElementById('post_text').value, text: document.getElementById('post_text').value,
}; };
if (g_data.reply_root || g_data.reply_branch) {
message.root = g_data.reply_root;
message.branch = g_data.reply_branch;
}
if (Object.keys(g_data.mentions).length) { if (Object.keys(g_data.mentions).length) {
message.mentions = Object.values(g_data.mentions); message.mentions = Object.values(g_data.mentions);
} }
window.parent.postMessage({appendMessage: message}, '*'); window.parent.postMessage({appendMessage: message}, '*');
document.getElementById('post_text').value = ''; document.getElementById('post_text').value = '';
Vue.set(g_data, mentions, {}); Vue.set(g_data, mentions, {});
g_data.reply_root = null;
g_data.reply_branch = null;
}, },
ssb_connect: function(connection) { ssb_connect: function(connection) {
window.parent.postMessage({connect: connection}, '*'); window.parent.postMessage({connect: connection}, '*');