app/javascript/js/controllers/sidebar_controller.js in avo-3.11.2 vs app/javascript/js/controllers/sidebar_controller.js in avo-3.11.3

- old
+ new

@@ -85,12 +85,12 @@ toggleSidebar() { if (this.sidebarTarget.classList.contains('hidden')) { this.sidebarTarget.classList.remove('hidden') } this.mainAreaTarget.classList.toggle('sidebar-open') - const value = Cookies.get(this.cookieKey) - Cookies.set(this.cookieKey, value === '1' ? '0' : '1') + + Cookies.set(this.cookieKey, this.newValue(Cookies.get(this.cookieKey))) } toggleSidebarOnMobile() { if (this.mobileSidebarTarget.classList.contains('hidden')) { this.mainAreaTarget.classList.remove('sidebar-open') @@ -102,6 +102,15 @@ // transistion. this.mainAreaTarget.offsetHeight; } this.mainAreaTarget.classList.toggle('sidebar-open') } + + // private + newValue(oldValue) { + if (oldValue === undefined) { + return '0' + } + return oldValue === '1' ? '0' : '1' + } + }