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

@@ -10,7 +10,7 @@ var g_data = {
show_user_dialog: null,
connect: null,
pubs: [],
votes: [],
votes: {},
apps: {},
share_app: null,
};
@@ -38,6 +38,14 @@ window.addEventListener('message', function(event) {
g_data.pubs = event.data.pubs;
} else if (key == 'apps') {
g_data.apps = event.data.apps;
} else if (key == 'votes') {
event.data.votes.forEach(function(vote) {
var link = JSON.parse(vote.content).vote.link;
if (!g_data.votes[link]) {
Vue.set(g_data.votes, link, []);
}
g_data.votes[link].push(vote);
});
} else if (key == 'clear') {
Object.keys(g_data_initial).forEach(function(key) {
Vue.set(g_data, key, JSON.parse(JSON.stringify(g_data_initial[key])));