Batch vue data updates, and sort the users list.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3719 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
62e9dfea90
commit
f7974d2cef
@ -1 +1 @@
|
|||||||
{"type":"tildefriends-app","files":{"app.js":"&LPDR4ZoE/qdPy9djmNFUfblXk7W1znMbwuAXp3/zWPI=.sha256","index.html":"&LGgeVc7llvfOU2gbnQZ60PGYCgcNjtEdHd1vjnJXLaU=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&uD6N8xUmrjXwIr95nkH/YjuZST6W1Q2MuJ8u6Vcmo6Q=.sha256","tf-message.js":"&KjVh7zASx0TZtZTsS6lJ7T70K9tyXcf+ink4vK7gSWI=.sha256","tf.js":"&r3w4aWGpCJ6J/x/K8hKAx6nohTuXHwVGvTDohJdnhiE=.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":"&LPDR4ZoE/qdPy9djmNFUfblXk7W1znMbwuAXp3/zWPI=.sha256","index.html":"&zwiRwroNQ1SnCsq97zB8dRiGwY4H+ii4ZtuKR385zdI=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&uD6N8xUmrjXwIr95nkH/YjuZST6W1Q2MuJ8u6Vcmo6Q=.sha256","tf-message.js":"&KjVh7zASx0TZtZTsS6lJ7T70K9tyXcf+ink4vK7gSWI=.sha256","tf.js":"&Kf578HPfGnoog7LmW2Nof8dQldS04Opl26CE5+nsFLA=.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"}}
|
@ -39,7 +39,7 @@
|
|||||||
<md-list-item v-for="connection in connections" v-bind:key="'connection-' + JSON.stringify(connection)"><tf-user :id="connection"></tf-user></md-list-item>
|
<md-list-item v-for="connection in connections" v-bind:key="'connection-' + JSON.stringify(connection)"><tf-user :id="connection"></tf-user></md-list-item>
|
||||||
<md-list-item @click="show_connect_dialog = true">Connect</md-list-item>
|
<md-list-item @click="show_connect_dialog = true">Connect</md-list-item>
|
||||||
<md-subheader>Users</md-subheader>
|
<md-subheader>Users</md-subheader>
|
||||||
<md-list-item v-for="user in Object.keys(users)" v-bind:key="'user-' + user"><tf-user v-bind:id="user"/></md-list-item>
|
<md-list-item v-for="user in Object.keys(users).sort((x, y) => (users[x].name || x).localeCompare(users[y].name || y))" v-bind:key="'user-' + user"><tf-user v-bind:id="user"/></md-list-item>
|
||||||
</md-list>
|
</md-list>
|
||||||
</md-app-drawer>
|
</md-app-drawer>
|
||||||
<md-app-toolbar class="md-secondary" v-show="unread > 0">
|
<md-app-toolbar class="md-secondary" v-show="unread > 0">
|
||||||
|
@ -16,7 +16,11 @@ var g_data = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var g_data_initial = JSON.parse(JSON.stringify(g_data));
|
var g_data_initial = JSON.parse(JSON.stringify(g_data));
|
||||||
window.addEventListener('message', function(event) {
|
var g_message_queue = [];
|
||||||
|
var g_process_pending = false;
|
||||||
|
|
||||||
|
function processMessages() {
|
||||||
|
for (let event of g_message_queue) {
|
||||||
var key = Object.keys(event.data)[0];
|
var key = Object.keys(event.data)[0];
|
||||||
if (key == 'message') {
|
if (key == 'message') {
|
||||||
event.data[key].children = [];
|
event.data[key].children = [];
|
||||||
@ -31,7 +35,6 @@ window.addEventListener('message', function(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
|
||||||
for (let message of g_data.messages) {
|
for (let message of g_data.messages) {
|
||||||
if (JSON.parse(message.content).root == event.data[key].id) {
|
if (JSON.parse(message.content).root == event.data[key].id) {
|
||||||
event.data[key].children.push(message);
|
event.data[key].children.push(message);
|
||||||
@ -40,7 +43,6 @@ window.addEventListener('message', function(event) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
g_data.messages.push(event.data[key]);
|
g_data.messages.push(event.data[key]);
|
||||||
g_data.messages.sort((x, y) => y.timestamp - x.timestamp);
|
g_data.messages.sort((x, y) => y.timestamp - x.timestamp);
|
||||||
@ -86,6 +88,17 @@ window.addEventListener('message', function(event) {
|
|||||||
} else {
|
} else {
|
||||||
g_data[key] = event.data[key];
|
g_data[key] = event.data[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
g_message_queue = [];
|
||||||
|
g_process_pending = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('message', function(event) {
|
||||||
|
g_message_queue.push(event);
|
||||||
|
if (!g_process_pending) {
|
||||||
|
g_process_pending = true;
|
||||||
|
setTimeout(processMessages, 250);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
Vue.use(VueMaterial.default);
|
Vue.use(VueMaterial.default);
|
||||||
|
Loading…
Reference in New Issue
Block a user