Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit ced5678

Browse files
author
bhasher
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents e044fb9 + 5e23471 commit ced5678

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/app.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ nunjucks.configure(path.join(__dirname, 'views'), {
2828
});
2929

3030
// Adding middleware
31-
// TODO change logger for production mode
32-
app.use(logger('dev'));
33-
app.use(compression());
34-
app.use(minify());
31+
if (config.PRODUCTION) {
32+
app.use(logger('combined'));
33+
app.use(compression());
34+
app.use(minify());
35+
}
36+
else {
37+
app.use(logger('dev'));
38+
}
3539

36-
// Prometheus
40+
// Prometheus middleware
3741
if(config.METRICS){
3842
app.use(promBundle({
3943
includeMethod: true,

src/socket/socket.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ module.exports = function (wss) {
5353
Object.entries(rooms[data.room]).forEach(([, sock]) => {
5454
sock.send(JSON.stringify(data));
5555
});
56-
let documentContent = (await db.getDocument(data["room"])).content;
57-
documentContent = JSON.parse(documentContent);
58-
let document = new Document(documentContent);
59-
document.applyRequests(data.data);
60-
db.updateDocument(data["room"], JSON.stringify(document.documentContent));
56+
if (Object.entries(data.data).filter(([,el]) => el.type !== 'cursor-moves').length > 0) {
57+
let documentContent = (await db.getDocument(data["room"])).content;
58+
documentContent = JSON.parse(documentContent);
59+
let document = new Document(documentContent);
60+
document.applyRequests(data.data);
61+
db.updateDocument(data["room"], JSON.stringify(document.documentContent));
62+
}
6163
} catch (err) {
6264
throw new Error(err);
6365
}

0 commit comments

Comments
 (0)