diff --git a/client/lib/utils.js b/client/lib/utils.js index 265d589b2..a20d65f00 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -231,9 +231,21 @@ Utils = { window.location.reload(); }, setBoardView(view) { - currentUser = ReactiveCache.getCurrentUser(); + const currentUser = ReactiveCache.getCurrentUser(); + if (currentUser) { - ReactiveCache.getCurrentUser().setBoardView(view); + // Update localStorage first + window.localStorage.setItem('boardView', view); + + // Update user profile via Meteor method + Meteor.call('setBoardView', view, (error) => { + if (error) { + console.error('[setBoardView] Update failed:', error); + } else { + // Reload to apply the view change + Utils.reload(); + } + }); } else if (view === 'board-view-swimlanes') { window.localStorage.setItem('boardView', 'board-view-swimlanes'); //true Utils.reload(); diff --git a/models/users.js b/models/users.js index 3298132a9..417528272 100644 --- a/models/users.js +++ b/models/users.js @@ -1729,6 +1729,14 @@ Meteor.methods({ const user = ReactiveCache.getCurrentUser(); user.setMobileMode(enabled); }, + setBoardView(view) { + check(view, String); + const user = ReactiveCache.getCurrentUser(); + if (!user) { + throw new Meteor.Error('not-authorized', 'Must be logged in'); + } + user.setBoardView(view); + }, }); if (Meteor.isServer) {