Skip to content

Commit

Permalink
fix:JobsLoadingModelListener
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla committed Apr 10, 2024
1 parent 5d600e5 commit 90ac9b1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class PostUrlAction(
getUrl(e.dataContext)?.let {
val request = GithubApi.postUrl(text, it, getData(e.dataContext))
val context = e.getRequiredData(ActionKeys.ACTION_DATA_CONTEXT)
val future = context.createDataProvider(request).request
val future = context.createDataProvider(request).processValue
future.thenApply {
afterPostUrl()
}
Expand Down
5 changes: 1 addition & 4 deletions src/main/kotlin/com/dsoftware/ghmanager/api/GithubApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ object GithubApi : GithubApiRequests.Entity("/repos") {
}


fun getJobsForWorkFlowRun(url: String): GithubApiRequest<WorkflowRunJobs>
// { throw GithubStatusCodeException("Not found", 404)
// }
= get<WorkflowRunJobs>(
fun getJobsForWorkFlowRun(url: String): GithubApiRequest<WorkflowRunJobs> = get<WorkflowRunJobs>(
url, "Get workflow-run jobs", pagination = GithubRequestPagination(1)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class JobsLoadingModelListener(
listenerDisposable = null

provider?.let {
jobsLoadingModel.future = it.request
jobsLoadingModel.future = it.processValue
val disposable = Disposer.newDisposable().apply {
Disposer.register(jobsLoadingModel, this)
}
it.addRunChangesListener(disposable,
object : DataProvider.DataProviderChangeListener {
override fun changed() {
jobsLoadingModel.future = it.request
jobsLoadingModel.future = it.processValue
}
})
listenerDisposable = disposable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class LogLoadingModelListener(
var listenerDisposable: Disposable? = null
logDataProvider.addAndInvokeListener { provider ->
logsLoadingModel.future = null
logsLoadingModel.future = provider?.request
logsLoadingModel.future = provider?.processValue
listenerDisposable = listenerDisposable?.let {
Disposer.dispose(it)
null
Expand All @@ -47,7 +47,7 @@ class LogLoadingModelListener(
it.addRunChangesListener(newDisposable,
object : DataProvider.DataProviderChangeListener {
override fun changed() {
logsLoadingModel.future = it.request
logsLoadingModel.future = it.processValue
}
})
listenerDisposable = newDisposable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.dsoftware.ghmanager.data.providers

import com.dsoftware.ghmanager.api.GhApiRequestExecutor
import com.dsoftware.ghmanager.api.GithubApi
import com.dsoftware.ghmanager.api.model.Job
import com.dsoftware.ghmanager.api.model.WorkflowRunJobs
import com.intellij.collaboration.async.CompletableFutureUtil.submitIOTask
import com.intellij.collaboration.util.ProgressIndicatorsProvider
import com.intellij.openapi.Disposable
Expand All @@ -20,7 +23,7 @@ open class DataProvider<T>(
private val progressManager = ProgressManager.getInstance()
private val indicatorsProvider: ProgressIndicatorsProvider = ProgressIndicatorsProvider()

private val processValue = progressManager.submitIOTask(indicatorsProvider, true) {
val processValue = progressManager.submitIOTask(indicatorsProvider, true) {
try {
LOG.info("Executing ${githubApiRequest.url}")
val request = githubApiRequest
Expand All @@ -35,9 +38,6 @@ open class DataProvider<T>(
}
}

val request
get() = processValue

fun url(): String = githubApiRequest.url

fun reload() {
Expand All @@ -55,4 +55,14 @@ open class DataProvider<T>(
companion object {
private val LOG = thisLogger()
}
}
}


class JobsDataProvider(requestExecutor: GhApiRequestExecutor, jobsUrl: String) : DataProvider<WorkflowRunJobs>(
requestExecutor, GithubApi.getJobsForWorkFlowRun(jobsUrl)
)


class LogDataProvider(requestExecutor: GhApiRequestExecutor, job: Job) : DataProvider<String>(
requestExecutor, GithubApi.getLogForSingleJob(job)
)

This file was deleted.

This file was deleted.

0 comments on commit 90ac9b1

Please sign in to comment.