Small fixes

This commit is contained in:
crschnick 2023-02-21 09:58:39 +00:00
parent 0a23e950d9
commit 84a129191d
6 changed files with 18 additions and 6 deletions

View file

@ -127,7 +127,6 @@ public class AppPrefs {
// External editor
// ===============
final ObjectProperty<ExternalEditorType> externalEditor =
typed(new SimpleObjectProperty<>(), ExternalEditorType.class);
private final SingleSelectionField<ExternalEditorType> externalEditorControl = Field.ofSingleSelectionType(

View file

@ -82,8 +82,8 @@ public interface ExternalEditorType extends PrefsChoiceValue {
@Override
public void launch(Path file) throws Exception {
var customCommand = AppPrefs.get().customEditorCommand().getValue();
if (customCommand == null || customCommand.trim().isEmpty()) {
return;
if (customCommand == null || customCommand.isBlank()) {
throw new IllegalStateException("No custom editor command specified");
}
var format = customCommand.contains("$file") ? customCommand : customCommand + " $file";

View file

@ -153,8 +153,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
public void launch(String name, String command) throws Exception {
var custom = AppPrefs.get().customTerminalCommand().getValue();
if (custom == null || custom.isBlank()) {
ErrorEvent.fromMessage("No custom terminal command specified").reportable(false).handle();
return;
throw new IllegalStateException("No custom terminal command specified");
}
var format = custom.contains("$cmd") ? custom : custom + " $cmd";

View file

@ -218,7 +218,8 @@ public class AppUpdater {
var performedUpdate = new PerformedUpdate(
downloadedUpdate.getValue().getVersion(),
downloadedUpdate.getValue().getBody());
downloadedUpdate.getValue().getBody(),
downloadedUpdate.getValue().getVersion());
AppCache.update("performedUpdate", performedUpdate);
}
});
@ -290,6 +291,7 @@ public class AppUpdater {
public static class PerformedUpdate {
String name;
String rawDescription;
String newVersion;
}
@Value

View file

@ -2,7 +2,9 @@ package io.xpipe.app.update;
import io.xpipe.app.comp.base.MarkdownComp;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppWindowHelper;
import io.xpipe.app.issue.ErrorEvent;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
@ -12,6 +14,12 @@ public class UpdateChangelogAlert {
public static void showIfNeeded() {
var update = AppUpdater.get().getPerformedUpdate();
if (update != null && !update.getNewVersion().equals(AppProperties.get().getVersion())) {
ErrorEvent.fromMessage("Update did not succeed").handle();
return;
}
if (update == null || update.getRawDescription() == null) {
return;
}

View file

@ -10,6 +10,10 @@ public class TerminalHelper {
}
var type = AppPrefs.get().terminalType().getValue();
if (type == null) {
throw new IllegalStateException("No terminal has been configured to be used");
}
type.launch(title, command);
}
}