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:
2021-12-31 19:01:53 +00:00
parent 4e359c3f5c
commit 3026443c1e
4 changed files with 15 additions and 1 deletions

View File

@ -53,6 +53,7 @@
<div class="md-title">What's up?</div>
</md-card-header>
<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)">
{{mentions[link].name}}: {{link}}
</md-chip>

View File

@ -17,6 +17,10 @@ Vue.component('tf-message', {
var writer = new commonmark.HtmlRenderer();
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">
<md-app-toolbar>
@ -30,6 +34,7 @@ Vue.component('tf-message', {
<md-menu-content>
<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 @click="set_reply()">Reply</md-menu-item>
</md-menu-content>
</md-menu>
</div>

View File

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