Skip to content

Commit

Permalink
calendar eventView.js: Try to cancel scroll-to-row callback when
Browse files Browse the repository at this point in the history
set_events() is called.

This prevents some cjs/gobject warnings at startup.
  • Loading branch information
mtwebster committed Oct 3, 2023
1 parent 6e387ff commit d12ad84
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ class EventList {
this.selected_date = GLib.DateTime.new_now_local();
this.desktop_settings = desktop_settings;
this._no_events_timeout_id = 0;
this._scroll_to_idle_id = 0;
this._rows = [];
this._current_event_data_list_timestamp = 0;

Expand Down Expand Up @@ -740,6 +741,11 @@ class EventList {
}

set_events(event_data_list, delay_no_events_box) {
if (this._scroll_to_idle_id > 0) {
Mainloop.source_remove(this._scroll_to_idle_id);
this._scroll_to_idle_id = 0;
}

if (event_data_list !== null && event_data_list.timestamp === this._current_event_data_list_timestamp) {
this._rows.forEach((row) => {
row.update_variations();
Expand Down Expand Up @@ -811,7 +817,11 @@ class EventList {
this._rows.push(row);
}

Mainloop.idle_add(Lang.bind(this, function(row) {
if (scroll_to_row == null) {
return;
}

this._scroll_to_idle_id = Mainloop.idle_add(Lang.bind(this, function(row) {
let vscroll = this.events_scroll_box.get_vscroll_bar();

if (row != null) {
Expand All @@ -820,6 +830,9 @@ class EventList {
} else {
vscroll.get_adjustment().set_value(0);
}

this._scroll_to_idle_id = 0;
return GLib.SOURCE_REMOVE;
}, scroll_to_row));
}
}
Expand Down

0 comments on commit d12ad84

Please sign in to comment.