add copy invite button to text clients

This commit is contained in:
Bruno Windels
2020-12-04 18:28:40 +01:00
parent 7333fba6a1
commit f42820e4ba
6 changed files with 66 additions and 47 deletions
+6 -7
View File
@@ -15,6 +15,8 @@ limitations under the License.
*/
import {TemplateView} from "../utils/TemplateView.js";
import {copyButton} from "../utils/copy.js";
import {text} from "../utils/html.js";
function formatPlatforms(platforms) {
return platforms.reduce((str, p, i, all) => {
@@ -60,17 +62,14 @@ class OpenClientView extends TemplateView {
}
class InstallClientView extends TemplateView {
copyToClipboard() {
}
render(t, vm) {
const children = [];
if (vm.textInstructions) {
const copy = t.button({className: "primary", onClick: evt => this.copyToClipboard(evt)}, "Copy");
children.push(t.p([vm.textInstructions, copy]));
children.push(t.p({}, vm.textInstructions));
if (vm.copyString) {
children.push(t.p(copyButton(t, () => vm.copyString, "Copy invite", "fullwidth primary")));
}
}
const actions = t.div({className: "actions"}, vm.actions.map(a => {
+5 -14
View File
@@ -16,6 +16,7 @@ limitations under the License.
import {isWebPlatform, isDesktopPlatform, Platform} from "../Platform.js";
import {ViewModel} from "../utils/ViewModel.js";
import {IdentifierKind} from "../Link.js";
export class ClientViewModel extends ViewModel {
constructor(options) {
@@ -102,6 +103,10 @@ export class ClientViewModel extends ViewModel {
return this._client.getLinkInstructions(this._proposedPlatform, this._link);
}
get copyString() {
return this._client.getCopyString(this._proposedPlatform, this._link);
}
get showDeepLinkInInstall() {
return this._clientCanIntercept && this.deepLink;
}
@@ -137,17 +142,3 @@ export class ClientViewModel extends ViewModel {
}
}
}
/*
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);
}
*/
+1
View File
@@ -70,6 +70,7 @@ export class Element {
}
getLinkInstructions(platform, link) {}
getCopyString(platform, link) {}
getName(platform) {
if (platform === Platform.DesktopWeb || platform === Platform.MobileWeb) {
+7
View File
@@ -39,5 +39,12 @@ export class Weechat {
}
}
getCopyString(platform, link) {
switch (link.kind) {
case LinkKind.User: return `/invite ${link.identifier}`;
case LinkKind.Room: return `/join ${link.identifier}`;
}
}
getInstallLinks(platform) {}
}