From ef74a1a660dddc88a6db0a2b1a24cc99e381e9bb Mon Sep 17 00:00:00 2001 From: jelveh Date: Sun, 28 Sep 2025 14:35:45 -0700 Subject: [PATCH] fix: prevent unnecessary updates on socket events Updated the `bindSocketEvents` method to check the `original_client_socket_id` before posting updates for 'cache.updated' and 'item.renamed' events. This prevents unnecessary updates when the event originates from the same client socket. --- src/puter-js/src/modules/FileSystem/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/puter-js/src/modules/FileSystem/index.js b/src/puter-js/src/modules/FileSystem/index.js index 0a3adfaa4..45295948b 100644 --- a/src/puter-js/src/modules/FileSystem/index.js +++ b/src/puter-js/src/modules/FileSystem/index.js @@ -113,8 +113,22 @@ export class PuterJSFileSystemModule extends AdvancedBase { } bindSocketEvents() { - this.socket.on('cache.updated', (item) => { - this.postUpdate(); + this.socket.on('cache.updated', (msg) => { + // check original_client_socket_id and if it matches this.socket.id, don't post update + if (msg.original_client_socket_id === this.socket.id) { + return; + }else{ + this.postUpdate(); + } + }); + + this.socket.on('item.renamed', (item) => { + // check original_client_socket_id and if it matches this.socket.id, don't post update + if (item.original_client_socket_id === this.socket.id) { + return; + }else{ + this.postUpdate(); + } }); this.socket.on('connect', () => {