Fixed UI freeze on certain notification events

This commit is contained in:
Marian Moravcik 2023-02-18 21:13:20 +01:00
parent 6578710c8d
commit 339883cff6
3 changed files with 9 additions and 9 deletions

View File

@ -284,10 +284,10 @@ def dispatcher(data):
if topic == 'series': if topic == 'series':
logging.debug(f'Event received from Sonarr for series: {series_title} ({series_year})') logging.debug(f'Event received from Sonarr for series: {series_title} ({series_year})')
update_one_series(series_id=media_id, action=action) update_one_series(series_id=media_id, action=action, send_event=False)
if episodesChanged: if episodesChanged:
# this will happen if a season monitored status is changed. # this will happen if a season monitored status is changed.
sync_episodes(series_id=media_id, send_event=True) sync_episodes(series_id=media_id, send_event=False)
elif topic == 'episode': elif topic == 'episode':
logging.debug(f'Event received from Sonarr for episode: {series_title} ({series_year}) - ' logging.debug(f'Event received from Sonarr for episode: {series_title} ({series_year}) - '
f'S{season_number:0>2}E{episode_number:0>2} - {episode_title}') f'S{season_number:0>2}E{episode_number:0>2} - {episode_title}')

View File

@ -200,7 +200,7 @@ def update_one_series(series_id, action):
except IntegrityError as e: except IntegrityError as e:
logging.error(f"BAZARR cannot update series {series['path']} because of {e}") logging.error(f"BAZARR cannot update series {series['path']} because of {e}")
else: else:
sync_episodes(series_id=int(series_id), send_event=True) sync_episodes(series_id=int(series_id), send_event=False)
event_stream(type='series', action='update', payload=int(series_id)) event_stream(type='series', action='update', payload=int(series_id))
logging.debug('BAZARR updated this series into the database:{}'.format(path_mappings.path_replace( logging.debug('BAZARR updated this series into the database:{}'.format(path_mappings.path_replace(
series['path']))) series['path'])))

View File

@ -10,7 +10,7 @@ import { notification } from "./notification";
class TaskDispatcher { class TaskDispatcher {
private running: boolean; private running: boolean;
private tasks: Record<string, Task.Callable[]> = {}; private tasks: Record<string, Task.Callable[]> = {};
private progress: Record<string, Site.Progress> = {}; private progress: Record<string, boolean> = {};
constructor() { constructor() {
this.running = false; this.running = false;
@ -110,10 +110,10 @@ class TaskDispatcher {
// TODO: FIX ME! // TODO: FIX ME!
item.value += 1; item.value += 1;
if (item.value >= item.count && this.progress[item.id] !== undefined) { if (item.value >= item.count && this.progress[item.id]) {
updateNotification(notification.progress.end(item.id, item.header)); updateNotification(notification.progress.end(item.id, item.header));
delete this.progress[item.id]; delete this.progress[item.id];
} else if (item.value > 1 && this.progress[item.id] !== undefined) { } else if (item.value > 1 && this.progress[item.id]) {
updateNotification( updateNotification(
notification.progress.update( notification.progress.update(
item.id, item.id,
@ -123,10 +123,10 @@ class TaskDispatcher {
item.count item.count
) )
); );
} else { } else if (item.value > 1 && this.progress[item.id] === undefined) {
showNotification(notification.progress.pending(item.id, item.header)); showNotification(notification.progress.pending(item.id, item.header));
this.progress[item.id] = item; this.progress[item.id] = true;
setTimeout(() => this.updateProgress(items), 1000); setTimeout(() => this.updateProgress([item]), 1000);
} }
}); });
} }