move "looks like not installed" in client view, and open & install stage
This commit is contained in:
@@ -31,19 +31,14 @@ export class PreviewView extends TemplateView {
|
||||
t.p(["Preview from ", vm => vm.previewDomain]),
|
||||
]),
|
||||
]),
|
||||
t.p({hidden: vm => !!vm.clientsViewModel}, t.button({onClick: () => vm.accept()}, vm => vm.acceptLabel)),
|
||||
t.p({className: {hidden: vm => !vm.canShowClients}}, t.button({
|
||||
className: "primary",
|
||||
onClick: () => vm.showClients()
|
||||
}, vm => vm.showClientsLabel)),
|
||||
t.mapView(vm => vm.clientsViewModel, childVM => childVM ? new ClientListView(childVM) : null),
|
||||
t.mapView(vm => vm.missingClientViewModel, childVM => childVM ? new MissingClientView(childVM) : null),
|
||||
t.mapView(vm => vm.preferredClientViewModel, childVM => childVM ? new ClientView(childVM) : null),
|
||||
t.p({className: {hidden: vm => !vm.preferredClientViewModel}}, vm => `This will open in ${vm.preferredClientViewModel?.name}`),
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class MissingClientView extends TemplateView {
|
||||
render(t, vm) {
|
||||
return t.div({className: "MissingClientView"}, [
|
||||
t.h3(`It looks like you don't have ${vm.name} installed.`),
|
||||
t.view(new ClientView(vm)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import {LinkKind} from "../Link.js";
|
||||
import {LinkKind, getLabelForLinkKind} from "../Link.js";
|
||||
import {ViewModel} from "../utils/ViewModel.js";
|
||||
import {resolveServer} from "./HomeServer.js";
|
||||
import {ClientListViewModel} from "../client/ClientListViewModel.js";
|
||||
@@ -35,7 +35,10 @@ export class PreviewViewModel extends ViewModel {
|
||||
this.previewDomain = null;
|
||||
this.clientsViewModel = null;
|
||||
this.acceptInstructions = null;
|
||||
this.missingClientViewModel = null;
|
||||
this.preferredClientViewModel = this._preferredClient ? new ClientViewModel(this.childOptions({
|
||||
client: this._preferredClient,
|
||||
link: this._link
|
||||
})) : null;
|
||||
}
|
||||
|
||||
async load() {
|
||||
@@ -71,31 +74,18 @@ export class PreviewViewModel extends ViewModel {
|
||||
return this._link.identifier;
|
||||
}
|
||||
|
||||
get acceptLabel() {
|
||||
if (this._preferredClient) {
|
||||
return `Open in ${this._preferredClient.getName(this.preferences.platform)}`;
|
||||
} else {
|
||||
return "Choose app";
|
||||
}
|
||||
get canShowClients() {
|
||||
return !(this.preferredClientViewModel || this.clientsViewModel);
|
||||
}
|
||||
|
||||
accept() {
|
||||
if (this._preferredClient) {
|
||||
if (this._preferredClient.getLinkSupport(this.preferences.platform, this._link)) {
|
||||
const deepLink = this._preferredClient.getDeepLink(this.preferences.platform, this._link);
|
||||
this.openLink(deepLink);
|
||||
const protocol = new URL(deepLink).protocol;
|
||||
const isWebProtocol = protocol === "http:" || protocol === "https:";
|
||||
if (!isWebProtocol) {
|
||||
this.missingClientViewModel = new ClientViewModel(this.childOptions({client: this._preferredClient, link: this._link}));
|
||||
}
|
||||
} else {
|
||||
this.acceptInstructions = this._preferredClient.getLinkInstructions(this.preferences.platform, this._link);
|
||||
}
|
||||
} else {
|
||||
get showClientsLabel() {
|
||||
return getLabelForLinkKind(this._link.kind);
|
||||
}
|
||||
|
||||
showClients() {
|
||||
if (!this._preferredClient) {
|
||||
this.clientsViewModel = new ClientListViewModel(this.childOptions({clients: this._clients, link: this._link}));
|
||||
// show client list
|
||||
this.emitChange();
|
||||
}
|
||||
this.emitChange();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user