[github] Clear all data on list refresh

This commit is contained in:
Ivan Semenov
2018-10-02 18:45:39 +03:00
parent d2717b2834
commit 2be320e7c0
4 changed files with 15 additions and 9 deletions
@@ -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)
@@ -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<GithubPullRequestsComponentFactory.GithubPullRequestsComponent>("org.jetbrains.plugins.github.pullrequest.component")
@JvmStatic
internal val PULL_REQUESTS_LIST_COMPONENT =
DataKey.create<GithubPullRequestsListComponent>("org.jetbrains.plugins.github.pullrequest.list.component")
@JvmStatic
val SELECTED_PULL_REQUEST = DataKey.create<GithubSearchedIssue>("org.jetbrains.plugins.github.pullrequest.selected")
@JvmStatic
val SELECTED_PULL_REQUEST_DATA_PROVIDER =
@@ -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()
}
}
@@ -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) {