From 2be320e7c0c980853bd30ddb0932db1e68e0fd51 Mon Sep 17 00:00:00 2001 From: Ivan Semenov Date: Tue, 2 Oct 2018 17:40:49 +0300 Subject: [PATCH] [github] Clear all data on list refresh --- .../pullrequest/GithubPullRequestsComponentFactory.kt | 7 ++++++- .../github/pullrequest/action/GithubPullRequestKeys.kt | 4 ---- .../action/GithubPullRequestRefreshListAction.kt | 6 +++--- .../pullrequest/data/GithubPullRequestsDataLoader.kt | 7 ++++++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GithubPullRequestsComponentFactory.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GithubPullRequestsComponentFactory.kt index 19593e615264..fe73ff0fc369 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GithubPullRequestsComponentFactory.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/GithubPullRequestsComponentFactory.kt @@ -103,6 +103,12 @@ internal class GithubPullRequestsComponentFactory(private val project: Project, }, preview) } + @CalledInAwt + fun refreshAllPullRequests() { + list.refresh() + dataLoader.invalidateAllData() + } + //TODO: refresh in list @CalledInAwt fun refreshPullRequest(number: Long) { @@ -118,7 +124,6 @@ internal class GithubPullRequestsComponentFactory(private val project: Project, GithubPullRequestKeys.SERVER_PATH.`is`(dataId) -> account.server GithubPullRequestKeys.API_REQUEST_EXECUTOR.`is`(dataId) -> requestExecutor GithubPullRequestKeys.PULL_REQUESTS_COMPONENT.`is`(dataId) -> this - GithubPullRequestKeys.PULL_REQUESTS_LIST_COMPONENT.`is`(dataId) -> list GithubPullRequestKeys.SELECTED_PULL_REQUEST.`is`(dataId) -> list.selectionModel.current GithubPullRequestKeys.SELECTED_PULL_REQUEST_DATA_PROVIDER.`is`(dataId) -> list.selectionModel.current?.let(dataLoader::getDataProvider) diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestKeys.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestKeys.kt index 76f48e1d833f..daccf6fc02e2 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestKeys.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestKeys.kt @@ -10,7 +10,6 @@ import org.jetbrains.plugins.github.api.data.GithubRepoDetailed import org.jetbrains.plugins.github.api.data.GithubSearchedIssue import org.jetbrains.plugins.github.pullrequest.GithubPullRequestsComponentFactory import org.jetbrains.plugins.github.pullrequest.data.GithubPullRequestsDataLoader -import org.jetbrains.plugins.github.pullrequest.ui.GithubPullRequestsListComponent object GithubPullRequestKeys { @JvmStatic @@ -20,9 +19,6 @@ object GithubPullRequestKeys { internal val PULL_REQUESTS_COMPONENT = DataKey.create("org.jetbrains.plugins.github.pullrequest.component") @JvmStatic - internal val PULL_REQUESTS_LIST_COMPONENT = - DataKey.create("org.jetbrains.plugins.github.pullrequest.list.component") - @JvmStatic val SELECTED_PULL_REQUEST = DataKey.create("org.jetbrains.plugins.github.pullrequest.selected") @JvmStatic val SELECTED_PULL_REQUEST_DATA_PROVIDER = diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestRefreshListAction.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestRefreshListAction.kt index 3f8402b6261a..f259c8c8bcd2 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestRefreshListAction.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/action/GithubPullRequestRefreshListAction.kt @@ -8,11 +8,11 @@ import com.intellij.openapi.project.DumbAwareAction class GithubPullRequestRefreshListAction : DumbAwareAction("Refresh", null, AllIcons.Actions.Refresh) { override fun update(e: AnActionEvent) { - val loader = e.getData(GithubPullRequestKeys.PULL_REQUESTS_LIST_COMPONENT) - e.presentation.isEnabled = loader != null + val component = e.getData(GithubPullRequestKeys.PULL_REQUESTS_COMPONENT) + e.presentation.isEnabled = component != null } override fun actionPerformed(e: AnActionEvent) { - e.getRequiredData(GithubPullRequestKeys.PULL_REQUESTS_LIST_COMPONENT).refresh() + e.getRequiredData(GithubPullRequestKeys.PULL_REQUESTS_COMPONENT).refreshAllPullRequests() } } \ No newline at end of file diff --git a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsDataLoader.kt b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsDataLoader.kt index e5fe10345bec..9e130014ebf8 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsDataLoader.kt +++ b/plugins/github/src/org/jetbrains/plugins/github/pullrequest/data/GithubPullRequestsDataLoader.kt @@ -46,7 +46,7 @@ class GithubPullRequestsDataLoader(private val project: Project, private val invalidationEventDispatcher = EventDispatcher.create(ProviderChangedListener::class.java) init { - LowMemoryWatcher.register(Runnable { cache.invalidateAll() }, this) + LowMemoryWatcher.register(Runnable { invalidateAllData() }, this) } @CalledInAwt @@ -54,6 +54,11 @@ class GithubPullRequestsDataLoader(private val project: Project, cache.invalidate(number) } + @CalledInAwt + fun invalidateAllData() { + cache.invalidateAll() + } + @CalledInAwt fun getDataProvider(githubSearchedIssue: GithubSearchedIssue): DataProvider { return cache.get(githubSearchedIssue.number) {