Skip to content

Commit 5413480

Browse files
Moving static data out of Element client file
1 parent 44a7ce8 commit 5413480

File tree

3 files changed

+59
-27
lines changed

3 files changed

+59
-27
lines changed

src/open/clients/Client.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Platform } from "../types.js";
2+
3+
export class Client {
4+
constructor(data) {
5+
this.data = data;
6+
}
7+
8+
get id() { return this.data.id; }
9+
10+
get platforms() { return this.data.platforms; }
11+
12+
get icon() { return "images/client-icons/"+this.data.icon; }
13+
get name() {return this.data.name; }
14+
get description() { return this.data.description; }
15+
get homepage() { return this.data.homepage; }
16+
get author() { return this.data.author; }
17+
getMaturity(platform) { return this.data.maturity; }
18+
19+
getLinkInstructions(platform, link) {}
20+
getCopyString(platform, link) {}
21+
getInstallLinks(platform) {
22+
var links = [];
23+
if (platform === Platform.iOS && this.platforms().includes(Platform.iOS) && this.data.applestorelink) {
24+
links.push(this.data.applestorelink);
25+
} else if (platform === Platform.Android && this.platforms.includes(Platform.Android)) {
26+
if (this.data.playstorelink) { links.push(this.data.playstorelink); }
27+
if (this.data.fdroidlink) { links.push(this.data.fdroidlink); }
28+
}
29+
else if (this.data.defaultInstallLink) { links.push(this.data.defaultInstallLink); }
30+
31+
return links;
32+
}
33+
34+
canInterceptMatrixToLinks(platform) { return false; }
35+
}

src/open/clients/Element.js

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import {Maturity, Platform, LinkKind,
18-
FDroidLink, AppleStoreLink, PlayStoreLink, WebsiteLink} from "../types.js";
17+
import {Platform, LinkKind} from "../types.js";
18+
import {Client} from "./Client.js";
19+
import {data} from "./ElementData.js";
1920

2021
const trustedWebInstances = [
2122
"app.element.io", // first one is the default one
@@ -29,24 +30,12 @@ const trustedWebInstances = [
2930
/**
3031
* Information on how to deep link to a given matrix client.
3132
*/
32-
export class Element {
33-
get id() { return "element.io"; }
34-
35-
get platforms() {
36-
return [
37-
Platform.Android, Platform.iOS,
38-
Platform.Windows, Platform.macOS, Platform.Linux,
39-
Platform.DesktopWeb
40-
];
33+
export class Element extends Client {
34+
constructor() {
35+
super(data);
4136
}
4237

43-
get icon() { return "images/client-icons/element.svg"; }
4438
get appleAssociatedAppId() { return "7J4U792NQT.im.vector.app"; }
45-
get name() {return "Element"; }
46-
get description() { return 'Fully-featured Matrix client, used by millions.'; }
47-
get homepage() { return "https://element.io"; }
48-
get author() { return "Element"; }
49-
getMaturity(platform) { return Maturity.Stable; }
5039

5140
getDeepLink(platform, link) {
5241
let fragmentPath;
@@ -85,16 +74,6 @@ export class Element {
8574
}
8675
}
8776

88-
getLinkInstructions(platform, link) {}
89-
getCopyString(platform, link) {}
90-
getInstallLinks(platform) {
91-
switch (platform) {
92-
case Platform.iOS: return [new AppleStoreLink('vector', 'id1083446067')];
93-
case Platform.Android: return [new PlayStoreLink('im.vector.app'), new FDroidLink('im.vector.app')];
94-
default: return [new WebsiteLink("https://element.io/get-started")];
95-
}
96-
}
97-
9877
canInterceptMatrixToLinks(platform) {
9978
return platform === Platform.Android;
10079
}

src/open/clients/ElementData.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {Maturity, Platform, FDroidLink, AppleStoreLink, PlayStoreLink, WebsiteLink, FlathubLink} from "../types.js";
2+
3+
export const data = {
4+
"id": "element.io",
5+
"platforms": [Platform.Android, Platform.iOS, Platform.Windows, Platform.macOS, Platform.Linux, Platform.DesktopWeb],
6+
"icon": "element.svg",
7+
"appleAssociatedAppId": "7J4U792NQT.im.vector.app",
8+
"name": "Element",
9+
"description": "Fully-featured Matrix client, used by millions.",
10+
"homepage": "https://element.io",
11+
"author": "Element",
12+
"maturity": Maturity.Stable,
13+
"applestorelink": new AppleStoreLink('vector', 'id1083446067'),
14+
"playstorelink": new PlayStoreLink('im.vector.app'),
15+
"fdroidlink": new FDroidLink('im.vector.app'),
16+
"flathublink": new FlathubLink('im.riot.Riot'),
17+
"defaultInstallLink": new WebsiteLink("https://element.io/get-started"),
18+
};

0 commit comments

Comments
 (0)