dag/completion: debounce GitLogCompletionModel updates
commit1b9c245f1d8826d1d9d4c849a3dbd7b80f521e17
authorDavid Aguilar <davvid@gmail.com>
Sat, 25 Feb 2023 10:07:01 +0000 (25 02:07 -0800)
committerDavid Aguilar <davvid@gmail.com>
Sat, 25 Feb 2023 10:07:18 +0000 (25 02:07 -0800)
tree0adfb234ca88389320be2a6d9fd361b10594e252
parent97d358eab0eebd317a496d89080b78ab9cf7d06c
dag/completion: debounce GitLogCompletionModel updates

Gather paths using a background thread to avoid locking up the UI
during startup. Prevent updates that are in close succession from
retriggering the same path gathering operation.

This happens during startup because both the "refs_updated" and
the "updated" signal from the model trigger the "model_updated"
signal in the completion model. Both of these signals are
emitted during application startup when the model is first
updated.

This causes gather_paths() to be called twice, once for each
model signal, which is wasteful and slows down startup.

Use a time-based guard to prevent background tasks from
being spawned when there paths are already being gathered.

Signed-off-by: David Aguilar <davvid@gmail.com>
cola/widgets/completion.py