From f0f1df937c44984a801f51ba49a97be3fdfcb31e Mon Sep 17 00:00:00 2001 From: dwithana Date: Tue, 20 Feb 2024 10:37:18 -0500 Subject: [PATCH] Enable create timeline and create thumbnail buttons on timeout --- app/views/media_objects/_thumbnail.html.erb | 11 +++++++++++ app/views/media_objects/_timeline.html.erb | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/views/media_objects/_thumbnail.html.erb b/app/views/media_objects/_thumbnail.html.erb index 4512344d44..2310c1a2b7 100644 --- a/app/views/media_objects/_thumbnail.html.erb +++ b/app/views/media_objects/_thumbnail.html.erb @@ -61,6 +61,17 @@ Unless required by applicable law or agreed to in writing, software distributed } clearInterval(timeCheck); }); + /* + Browsers on MacOS sometimes miss the 'loadedmetadata' event resulting in a disabled add to playlist button indefinitely. + This timeout enables the add to playlist button, when this happens. It checks the button's state and enables it as needed. + */ + setTimeout(() => { + let thumbnailBtn = document.getElementById('create-thumbnail-btn'); + if (thumbnailBtn && thumbnailBtn.disabled) { + thumbnailBtn.disabled = false; + } + clearInterval(timeCheck); + }, 500); } $('#thumbnailModal').on('show.bs.modal', function(e) { diff --git a/app/views/media_objects/_timeline.html.erb b/app/views/media_objects/_timeline.html.erb index 1d546e0a32..f5f3f22f27 100644 --- a/app/views/media_objects/_timeline.html.erb +++ b/app/views/media_objects/_timeline.html.erb @@ -51,11 +51,22 @@ $(document).ready(function() { if(player && player != undefined) { player.player.on('loadedmetadata', () => { let timelineBtn = document.getElementById('timelineBtn'); - if(timelineBtn) { + if (timelineBtn) { timelineBtn.disabled = false; } clearInterval(timeCheck); }); + /* + Browsers on MacOS sometimes miss the 'loadedmetadata' event resulting in a disabled add to playlist button indefinitely. + This timeout enables the add to playlist button, when this happens. It checks the button's state and enables it as needed. + */ + setTimeout(() => { + let timelineBtn = document.getElementById('timelineBtn'); + if (timelineBtn && timelineBtn.disabled) { + timelineBtn.disabled = false; + } + clearInterval(timeCheck); + }, 500); } $('#timelineModal').on('shown.bs.modal', function (e) {