Custom web instances #1

Merged
Domoel merged 5 commits from custom-web-instances into main 2025-03-29 00:19:32 +01:00
2 changed files with 36 additions and 0 deletions
Showing only changes of commit 06237b1b8b - Show all commits
+31
View File
@@ -112,10 +112,41 @@ class InstallClientView extends TemplateView {
}
}
export class SetCustomWebInstanceView extends TemplateView {
render(t, vm) {
return t.div({className: "SetCustomWebInstanceView"}, [
t.p([
"Use a custom web instance for the ", t.strong(vm.name), " client:",
]),
t.form({action: "#", id: "setCustomWebInstanceForm", onSubmit: evt => this._onSubmit(evt)}, [
t.label([
"Host name:",
t.input({
type: "text",
className: "line",
placeholder: "chat.example.org",
name: "instanceHostname",
})
])
])
]);
}
_onSubmit(evt) {
evt.preventDefault();
this.value.continueWithSelection(this._askEveryTimeChecked);
}
}
function showBack(t, vm) {
return t.p({className: {caption: true, "back": true, hidden: vm => !vm.showBack}}, [
`Continue with ${vm.name} · `,
t.button({className: "text", onClick: () => vm.back()}, "Change"),
t.span({hidden: vm => !vm.showSetWebInstance}, [
' · ',
t.button({className: "text", onClick: () => vm.setCustomWebInstance()}, "Use Custom Web Instance"),
])
]);
}
+5
View File
@@ -231,6 +231,10 @@ export class ClientViewModel extends ViewModel {
return !!this._clientListViewModel;
}
get showSetWebInstance() {
return !!this._client.supportsCustomInstances;
}
back() {
if (this._clientListViewModel) {
const vm = this._clientListViewModel;
@@ -239,6 +243,7 @@ export class ClientViewModel extends ViewModel {
// in the list with all clients, and also if we refresh, we get the list with
// all clients rather than having our "change client" click reverted.
this.preferences.setClient(undefined, undefined);
this.preferences.setPreferredWebInstance(this._client.id, undefined);
this._update();
this.emitChange();
vm.showAll();