diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsLoader.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsLoader.kt index 4c115857b769..ae6202942279 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsLoader.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsLoader.kt @@ -27,7 +27,7 @@ class GithubPullRequestsLoader(private val progressManager: ProgressManager, private val LOG = logger() private val executor = AppExecutorUtil.createBoundedApplicationPoolExecutor("GitHub PR loading breaker", 1) - private var progressIndicator = EmptyProgressIndicator() + private var progressIndicator = createNonReusableIndicator() private var query: String = buildQuery(null) private var nextPageRequest: GithubApiRequest>? = createInitialRequest() private var isDisposed = false @@ -111,12 +111,7 @@ class GithubPullRequestsLoader(private val progressManager: ProgressManager, fun reset() { if (isDisposed) return progressIndicator.cancel() - progressIndicator = object : EmptyProgressIndicator() { - override fun start() { - checkCanceled() - super.start() - } - } + progressIndicator = createNonReusableIndicator() executor.execute { nextPageRequest = createInitialRequest() stateEventDispatcher.multicaster.loaderReset() @@ -124,6 +119,13 @@ class GithubPullRequestsLoader(private val progressManager: ProgressManager, } } + private fun createNonReusableIndicator(): ProgressIndicator = object : EmptyProgressIndicator() { + override fun start() { + checkCanceled() + super.start() + } + } + fun addStateListener(listener: StateListener, disposable: Disposable) = stateEventDispatcher.addListener(listener, disposable) override fun dispose() {