Oh, votes are slowing everything down. Batch them and simplify.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3648 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2021-01-20 02:20:40 +00:00
parent 03cf347394
commit 87747c0b6b
6 changed files with 35 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
Vue.component('tf-message', {
props: ['message', 'messages'],
props: ['message', 'messages', 'votes'],
data: function() { return { showRaw: false } },
computed: {
content_json: function() {
@@ -17,15 +17,10 @@ Vue.component('tf-message', {
} catch {}
});
},
votes: function() {
return [];
votes2: function() {
var id = this.message.id;
return this.votes.filter(function (x) {
try {
var j = JSON.parse(x.content);
return j.type == 'vote' && j.vote.link == id;
} catch {}
}).reduce(function (accum, value) {
var votes = this.votes[id] || [];
return votes.reduce(function (accum, value) {
var expression = JSON.parse(value.content).vote.expression;
if (!accum[expression]) {
accum[expression] = [];
@@ -79,9 +74,9 @@ Vue.component('tf-message', {
<div v-else-if="content_json && content_json.type == 'contact'"><tf-user :id="message.author"></tf-user> {{content_json.following ? '==&gt;' : '=/=&gt;'}} <tf-user :id="content_json.contact"></tf-user></div>
<div v-else>{{message.content}}</div>
</div>
<tf-message v-for="sub_message in sub_messages" v-bind:message="sub_message" v-bind:messages="messages" v-bind:key="sub_message.id"></tf-message>
<md-chip v-for="vote in Object.keys(votes)" v-bind:key="vote">
{{vote + (votes[vote].length > 1 ? ' (' + votes[vote].length + ')' : '')}}
<tf-message v-for="sub_message in sub_messages" v-bind:message="sub_message" v-bind:messages="messages" v-bind:votes="votes" v-bind:key="sub_message.id"></tf-message>
<md-chip v-for="vote in Object.keys(votes2)" v-bind:key="vote">
{{vote + (votes2[vote].length > 1 ? ' (' + votes2[vote].length + ')' : '')}}
</md-chip>
</md-app-content>
</md-app>`,