Fixed interaction with modal dialogs to prevent browser race conditions when touchscreen events are involved

This commit is contained in:
Fabio Manganiello 2019-01-13 23:45:03 +01:00
parent 740063c23b
commit f38b2db273
4 changed files with 18 additions and 6 deletions

View file

@ -4,6 +4,7 @@ $(document).ready(function() {
openedWebsocket, openedWebsocket,
dateTimeInterval, dateTimeInterval,
websocketTimeoutId, websocketTimeoutId,
modalFadingInTimeoutId,
websocketReconnectMsecs = 30000, websocketReconnectMsecs = 30000,
eventListeners = []; eventListeners = [];
@ -155,6 +156,10 @@ $(document).ready(function() {
var top = 40 + $(window).scrollTop(); var top = 40 + $(window).scrollTop();
$container.css('margin-top', top + 'px'); $container.css('margin-top', top + 'px');
modalFadingInTimeoutId = setTimeout(function() {
modalFadingInTimeoutId = undefined;
}, 100);
$modal.fadeIn(); $modal.fadeIn();
}); });
}; };
@ -171,7 +176,9 @@ $(document).ready(function() {
if (!$source.parents('.modal').length if (!$source.parents('.modal').length
&& !$source.data('modal') && !$source.data('modal')
&& !$source.data('dismiss-modal')) { && !$source.data('dismiss-modal')) {
$('.modal').filter(':visible').fadeOut(); if (!modalFadingInTimeoutId) {
$('.modal').filter(':visible').fadeOut();
}
} }
}); });
}; };

View file

@ -1,5 +1,6 @@
$(document).ready(function() { $(document).ready(function() {
var seekInterval, var seekInterval,
longPressTimeout,
curPath = [], curPath = [],
curTrackUpdateHandler, curTrackUpdateHandler,
curTrackElapsed = { curTrackElapsed = {
@ -225,8 +226,10 @@ $(document).ready(function() {
}); });
} }
clearTimeout(longPressTimeout); if (longPressTimeout) {
longPressTimeout = undefined; clearTimeout(longPressTimeout);
longPressTimeout = undefined;
}
}; };
var updatePlaylist = function(tracks) { var updatePlaylist = function(tracks) {

View file

@ -308,7 +308,7 @@ $(document).ready(function() {
}); });
}); });
$container.on('click touch', '.snapcast-host-settings', function(evt) { $container.on('mousedown touchstart', '.snapcast-host-settings', function(evt) {
var host = $(this).parents('.snapcast-host-container').data('host'); var host = $(this).parents('.snapcast-host-container').data('host');
var hostName = $(this).parents('.snapcast-host-container').data('name'); var hostName = $(this).parents('.snapcast-host-container').data('name');
var $modal = $($(this).data('modal')); var $modal = $($(this).data('modal'));
@ -324,7 +324,7 @@ $(document).ready(function() {
} }
}); });
$container.on('click touch', '.snapcast-group-settings', function(evt) { $container.on('mousedown touchstart', '.snapcast-group-settings', function(evt) {
var host = $(this).parents('.snapcast-host-container').data('host'); var host = $(this).parents('.snapcast-host-container').data('host');
var groupId = $(this).parents('.snapcast-group-container').data('id'); var groupId = $(this).parents('.snapcast-group-container').data('id');
var groupName = $(this).parents('.snapcast-group-container').data('name'); var groupName = $(this).parents('.snapcast-group-container').data('name');
@ -375,7 +375,7 @@ $(document).ready(function() {
.find('select[name=stream]').html($streams.html()); .find('select[name=stream]').html($streams.html());
}); });
$container.on('click touch', '.snapcast-client-settings', function(evt) { $container.on('mousedown touchstart', '.snapcast-client-settings', function(evt) {
var host = $(this).parents('.snapcast-host-container').data('host'); var host = $(this).parents('.snapcast-host-container').data('host');
var clientId = $(this).parents('.snapcast-client-container').data('id'); var clientId = $(this).parents('.snapcast-client-container').data('id');
var clientName = $(this).parents('.snapcast-client-container').data('name'); var clientName = $(this).parents('.snapcast-client-container').data('name');

View file

@ -18,7 +18,9 @@ class UtilsPlugin(Plugin):
_interval_hndl_idx = 0 _interval_hndl_idx = 0
_interval_hndl_idx_lock = threading.RLock() _interval_hndl_idx_lock = threading.RLock()
_pending_timeouts = {}
_pending_intervals = {} _pending_intervals = {}
_pending_timemouts_lock = threading.RLock()
_pending_intervals_lock = threading.RLock() _pending_intervals_lock = threading.RLock()
@action @action