client metadata caching

This commit is contained in:
Jan Prochazka
2020-04-12 20:47:24 +02:00
parent cd645afd00
commit e9c03345c3
8 changed files with 88 additions and 18 deletions

View File

@@ -39,14 +39,14 @@ module.exports = {
} else {
res = await this.datastore.insert(connection);
}
socket.emit('connection-list-changed');
socket.emitChanged('connection-list-changed');
return res;
},
delete_meta: 'post',
async delete(connection) {
const res = await this.datastore.remove(_.pick(connection, '_id'));
socket.emit('connection-list-changed');
socket.emitChanged('connection-list-changed');
return res;
},

View File

@@ -13,7 +13,7 @@ module.exports = {
const existing = this.opened.find((x) => x.conid == conid && x.database == database);
if (!existing) return;
existing.structure = structure;
socket.emit(`database-structure-changed-${conid}-${database}`);
socket.emitChanged(`database-structure-changed-${conid}-${database}`);
},
handle_error(conid, database, props) {
const { error } = props;

View File

@@ -9,7 +9,7 @@ module.exports = {
const existing = this.opened.find(x => x.conid == conid);
if (!existing) return;
existing.databases = databases;
socket.emit(`database-list-changed-${conid}`);
socket.emitChanged(`database-list-changed-${conid}`);
},
handle_error(conid, { error }) {
console.log(`Error in server connection ${conid}: ${error}`);

View File

@@ -11,4 +11,9 @@ module.exports = {
console.log('EMIT:', message, data);
socket.emit(message, data);
},
emitChanged(key) {
console.log('EMIT_CHANGED:', key);
socket.emit(key);
socket.emit('clean-cache', key);
}
};