private NextState computeNextState(License newLicense) {
if (!editionInstaller.requiresInstallationChange(newLicense.getPluginKeys())) {
return new NextState(newLicense.getEditionKey(), NO_INSTALL);
+ // this won't refresh the update center (uses cached state). Preview is called while typing (must be fast)
+ // and anyway the status is refreshed when arriving at the marketplace page.
} else if (editionInstaller.isOffline()) {
return new NextState(newLicense.getEditionKey(), MANUAL_INSTALL);
} else {
uninstallPlugins(pluginsToRemove);
}
+ /**
+ * Check if the update center is disabled or unreachable. It uses the cached status (it doesn't refresh),
+ * to be a cost-free check.
+ */
public boolean isOffline() {
- return !updateCenterMatrixFactory.getUpdateCenter(true).isPresent();
+ return !updateCenterMatrixFactory.getUpdateCenter(false).isPresent();
}
public boolean requiresInstallationChange(Set<String> editionPluginKeys) {
@Test
public void is_offline() {
- when(updateCenterMatrixFactory.getUpdateCenter(true)).thenReturn(Optional.absent());
+ when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.absent());
assertThat(installer.isOffline()).isTrue();
}