mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git: don't wait for the log refresh to show the Update Project notification if custom filters are not set
For simplicity, consider only the Path filter: it will be moved to the Settings in one of next commits, and will be the only preserved filter. If there is no Paths filter, we don't need the up-to-date VisiblePack to show the notification. Therefore collect only the necessary information (available at once from Git), and show the notification. If user presses the "View Commits" link fast, he'll have to wait until the log is refreshed and filtered. If there is a Path filter, then we'll have to wait, because the number of commits matching the filter is unavailable until the VisiblePack is ready. Partial fix of IDEA-216137. GitOrigin-RevId: d55d22d2faecf5c844fcced7c2639d3f1ed101aa
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3bfaa47895
commit
853c7d92a7
@@ -53,21 +53,34 @@ class GitUpdateInfoAsLog(private val project: Project,
|
||||
fun buildAndShowNotification() {
|
||||
notificationShown = false
|
||||
VcsLogContentUtil.runWhenLogIsReady(project) { log, logManager ->
|
||||
val listener = object : DataPackChangeListener {
|
||||
override fun onDataPackChange(dataPack: DataPack) {
|
||||
showNotificationIfRangesAreReachable(log, dataPack, logManager, this)
|
||||
}
|
||||
if (!isPathFilterSet()) { // if no preserved filters are set, we don't need the log to show the notification
|
||||
showTabAndNotificationAfterCalculations(logManager)
|
||||
}
|
||||
else {
|
||||
waitForLogRefreshAndShowNotification(log, logManager)
|
||||
}
|
||||
|
||||
log.dataManager?.addDataPackChangeListener(listener)
|
||||
|
||||
GuiUtils.invokeLaterIfNeeded({
|
||||
// the log may be refreshed before we subscribe to the listener
|
||||
showNotificationIfRangesAreReachable(log, logManager.dataManager.dataPack, logManager, listener)
|
||||
}, ModalityState.defaultModalityState())
|
||||
}
|
||||
}
|
||||
|
||||
private fun waitForLogRefreshAndShowNotification(log: VcsProjectLog, logManager: VcsLogManager) {
|
||||
val listener = object : DataPackChangeListener {
|
||||
override fun onDataPackChange(dataPack: DataPack) {
|
||||
showNotificationIfRangesAreReachable(log, dataPack, logManager, this)
|
||||
}
|
||||
}
|
||||
|
||||
log.dataManager?.addDataPackChangeListener(listener)
|
||||
|
||||
GuiUtils.invokeLaterIfNeeded({
|
||||
// the log may be refreshed before we subscribe to the listener
|
||||
showNotificationIfRangesAreReachable(log, logManager.dataManager.dataPack, logManager, listener)
|
||||
}, ModalityState.defaultModalityState())
|
||||
}
|
||||
|
||||
private fun isPathFilterSet() : Boolean {
|
||||
return project.service<GitUpdateProjectInfoLogProperties>().getFilterValues(STRUCTURE_FILTER.name) != null
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
private fun showNotificationIfRangesAreReachable(log: VcsProjectLog,
|
||||
dataPack: DataPack,
|
||||
@@ -120,7 +133,7 @@ class GitUpdateInfoAsLog(private val project: Project,
|
||||
// null for initial filters means that filters will be loaded from properties: saved filters + the range filter which we've just set
|
||||
val logUi = VcsLogUiImpl(logId, logData, logManager.colorManager, properties, refresher, null)
|
||||
|
||||
val listener = MyVisiblePackChangeListener(logUi, updatedFilesCount, updateCommitsCount, properties.havePresetFilters())
|
||||
val listener = MyVisiblePackChangeListener(logUi, updatedFilesCount, updateCommitsCount, isPathFilterSet())
|
||||
refresher.addVisiblePackChangeListener(listener)
|
||||
return logUi
|
||||
}
|
||||
@@ -141,11 +154,6 @@ class GitUpdateInfoAsLog(private val project: Project,
|
||||
mainProperties.saveFilterValues(filterName, values)
|
||||
}
|
||||
}
|
||||
|
||||
fun havePresetFilters(): Boolean {
|
||||
val filters = mainProperties.state.FILTERS
|
||||
return if (filters[RANGE_FILTER.name] != null) filters.size > 1 else filters.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
private fun calcUpdatedCommitsCount(): Int {
|
||||
|
||||
Reference in New Issue
Block a user