From 5c2f2b0684437e1648e0ee3eaa2b6fba762bb3c9 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Jul 2021 14:19:05 +0100 Subject: [PATCH 1/6] Allow well-known to fail, it is optional after all --- src/preview/HomeServer.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/preview/HomeServer.js b/src/preview/HomeServer.js index 3cb91fc..a3ae289 100644 --- a/src/preview/HomeServer.js +++ b/src/preview/HomeServer.js @@ -24,13 +24,17 @@ export async function resolveServer(request, baseURL) { baseURL = `https://${baseURL}`; } { - const {status, body} = await request(`${baseURL}/.well-known/matrix/client`, {method: "GET"}).response(); - if (status === 200) { - const proposedBaseURL = body?.['m.homeserver']?.base_url; - if (typeof proposedBaseURL === "string") { - baseURL = noTrailingSlash(proposedBaseURL); - } - } + try { + const {status, body} = await request(`${baseURL}/.well-known/matrix/client`, {method: "GET"}).response(); + if (status === 200) { + const proposedBaseURL = body?.['m.homeserver']?.base_url; + if (typeof proposedBaseURL === "string") { + baseURL = noTrailingSlash(proposedBaseURL); + } + } + } catch (e) { + console.warn("Failed to fetch ${baseURL}/.well-known/matrix/client", e); + } } { const {status} = await request(`${baseURL}/_matrix/client/versions`, {method: "GET"}).response(); From eb9ebaf28e9cd4676fd70298f56ef5ca1f138edd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Jul 2021 14:19:15 +0100 Subject: [PATCH 2/6] Print port in serve-local script --- scripts/serve-local.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/serve-local.js b/scripts/serve-local.js index 08e500d..8c73331 100644 --- a/scripts/serve-local.js +++ b/scripts/serve-local.js @@ -45,3 +45,4 @@ const server = http.createServer(function onRequest (req, res) { // Listen server.listen(5000); +console.log("Listening on port 5000"); From 4bc70d99f4590079e31d46dae2fb5ee1a6887766 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Jul 2021 14:19:31 +0100 Subject: [PATCH 3/6] gitignore .idea --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index df36431..e804636 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules build *.tar.gz +/.idea From 7d2dd5cc68e0f030c2f5661ea399755f1dfcbaed Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 14 Jul 2021 14:29:13 +0100 Subject: [PATCH 4/6] Print port in serve-local script --- src/preview/HomeServer.js | 11 +++++++++++ src/preview/PreviewViewModel.js | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/preview/HomeServer.js b/src/preview/HomeServer.js index a3ae289..6123d92 100644 --- a/src/preview/HomeServer.js +++ b/src/preview/HomeServer.js @@ -56,6 +56,17 @@ export class HomeServer { return body; } + // MSC3266 implementation + async getRoomSummary(roomIdOrAlias, viaServers) { + let query; + if (viaServers.length > 0) { + query = "?" + viaServers.map(server => `via=${encodeURIComponent(server)}`).join('&'); + } + const {body, status} = await this._request(`${this.baseURL}/_matrix/client/unstable/im.nheko.summary/rooms/${encodeURIComponent(roomIdOrAlias)}/summary${query}`).response(); + if (status !== 200) return; + return body; + } + async findPublicRoomById(roomId) { const {body, status} = await this._request(`${this.baseURL}/_matrix/client/r0/directory/list/room/${encodeURIComponent(roomId)}`).response(); if (status !== 200 || body.visibility !== "public") { diff --git a/src/preview/PreviewViewModel.js b/src/preview/PreviewViewModel.js index 50843e6..bc507cc 100644 --- a/src/preview/PreviewViewModel.js +++ b/src/preview/PreviewViewModel.js @@ -88,14 +88,21 @@ export class PreviewViewModel extends ViewModel { async _loadRoomPreview(homeserver, link) { let publicRoom; - if (link.identifierKind === IdentifierKind.RoomId) { - publicRoom = await homeserver.findPublicRoomById(link.identifier); - } else if (link.identifierKind === IdentifierKind.RoomAlias) { - const roomId = await homeserver.getRoomIdFromAlias(link.identifier); - if (roomId) { - publicRoom = await homeserver.findPublicRoomById(roomId); - } - } + if (link.identifierKind === IdentifierKind.RoomId || link.identifierKind === IdentifierKind.RoomAlias) { + publicRoom = await homeserver.getRoomSummary(link.identifier, link.servers); + } + + if (!publicRoom) { + if (link.identifierKind === IdentifierKind.RoomId) { + publicRoom = await homeserver.findPublicRoomById(link.identifier); + } else if (link.identifierKind === IdentifierKind.RoomAlias) { + const roomId = await homeserver.getRoomIdFromAlias(link.identifier); + if (roomId) { + publicRoom = await homeserver.findPublicRoomById(roomId); + } + } + } + this.name = publicRoom?.name || publicRoom?.canonical_alias || link.identifier; this.avatarUrl = publicRoom?.avatar_url ? homeserver.mxcUrlThumbnail(publicRoom.avatar_url, 64, 64, "crop") : From 9caf2ce268008655f4b4b87d7a46a4d5c0a78875 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 15 Jul 2021 15:36:30 +0100 Subject: [PATCH 5/6] Use alternative border radius when previewing a space --- css/preview.css | 4 ++++ src/preview/PreviewView.js | 2 +- src/preview/PreviewViewModel.js | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/css/preview.css b/css/preview.css index 05b569b..aed7111 100644 --- a/css/preview.css +++ b/css/preview.css @@ -22,6 +22,10 @@ height: 64px; } +.PreviewView .mxSpace .avatar { + border-radius: 12px; +} + .PreviewView .defaultAvatar { width: 64px; height: 64px; diff --git a/src/preview/PreviewView.js b/src/preview/PreviewView.js index 0fedfb6..96ed2c2 100644 --- a/src/preview/PreviewView.js +++ b/src/preview/PreviewView.js @@ -51,7 +51,7 @@ class LoadedPreviewView extends TemplateView { return t.div({className: "defaultAvatar"}); } }); - return t.div([ + return t.div({className: vm.isSpaceRoom ? "mxSpace" : undefined}, [ t.div({className: "avatarContainer"}, avatar), t.h1(vm => vm.name), t.p({className: {identifier: true, hidden: vm => !vm.identifier}}, vm => vm.identifier), diff --git a/src/preview/PreviewViewModel.js b/src/preview/PreviewViewModel.js index bc507cc..4599ab2 100644 --- a/src/preview/PreviewViewModel.js +++ b/src/preview/PreviewViewModel.js @@ -34,6 +34,7 @@ export class PreviewViewModel extends ViewModel { this.topic = null; this.domain = null; this.failed = false; + this.isSpaceRoom = false; } async load() { @@ -110,6 +111,7 @@ export class PreviewViewModel extends ViewModel { this.memberCount = publicRoom?.num_joined_members; this.topic = publicRoom?.topic; this.identifier = publicRoom?.canonical_alias || link.identifier; + this.isSpaceRoom = publicRoom?.room_type === "m.space"; if (this.identifier === this.name) { this.identifier = null; } From acd881385c0643957de963eb5e82765a65552986 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 23 Jul 2021 12:25:21 +0100 Subject: [PATCH 6/6] Mass Tabs -> Spaces conversion --- css/main.css | 52 +++---- images/client-icons/fluffychat.svg | 66 ++++---- index.html | 18 +-- scripts/serve-local.js | 22 +-- src/Link.js | 198 ++++++++++++------------ src/Platform.js | 20 +-- src/Preferences.js | 58 +++---- src/RootView.js | 34 ++-- src/RootViewModel.js | 66 ++++---- src/create/CreateLinkView.js | 40 ++--- src/create/CreateLinkViewModel.js | 8 +- src/main.js | 28 ++-- src/open/ClientListView.js | 80 +++++----- src/open/ClientListViewModel.js | 108 ++++++------- src/open/ClientView.js | 78 +++++----- src/open/ClientViewModel.js | 154 +++++++++--------- src/open/OpenLinkView.js | 10 +- src/open/OpenLinkViewModel.js | 38 ++--- src/open/ServerConsentView.js | 4 +- src/open/ServerConsentViewModel.js | 6 +- src/open/clients/Element.js | 94 +++++------ src/open/clients/Fractal.js | 20 +-- src/open/clients/Nheko.js | 78 +++++----- src/open/clients/Weechat.js | 28 ++-- src/open/clients/index.js | 18 +-- src/open/types.js | 10 +- src/policy/LoadServerPolicyView.js | 10 +- src/policy/LoadServerPolicyViewModel.js | 8 +- src/preview/HomeServer.js | 92 +++++------ src/preview/PreviewView.js | 18 +-- src/preview/PreviewViewModel.js | 114 +++++++------- 31 files changed, 789 insertions(+), 789 deletions(-) diff --git a/css/main.css b/css/main.css index f953250..283adef 100644 --- a/css/main.css +++ b/css/main.css @@ -21,31 +21,31 @@ limitations under the License. @import url('open.css'); :root { - --app-background: #f4f4f4; - --background: #ffffff; - --foreground: #000000; - --font: #333333; - --grey: #666666; - --accent: #0098d4; - --error: #d6001c; - --link: #0098d4; - --borders: #f4f4f4; + --app-background: #f4f4f4; + --background: #ffffff; + --foreground: #000000; + --font: #333333; + --grey: #666666; + --accent: #0098d4; + --error: #d6001c; + --link: #0098d4; + --borders: #f4f4f4; --lightgrey: #E6E6E6; --spinner-stroke-size: 2px; } html { - margin: 0; - padding: 0; + margin: 0; + padding: 0; } body { - background-color: var(--app-background); - background-image: url('../images/background.svg'); + background-color: var(--app-background); + background-image: url('../images/background.svg'); background-attachment: fixed; - background-repeat: no-repeat; - background-size: auto; - background-position: center -50px; + background-repeat: no-repeat; + background-size: auto; + background-position: center -50px; height: 100%; width: 100%; font-size: 14px; @@ -89,12 +89,12 @@ input[type="checkbox"], input[type="radio"] { .RootView { margin: 0 auto; - max-width: 480px; - width: 100%; + max-width: 480px; + width: 100%; } .card { - background-color: var(--background); + background-color: var(--background); border-radius: 16px; box-shadow: 0px 18px 24px rgba(0, 0, 0, 0.06); } @@ -104,20 +104,20 @@ input[type="checkbox"], input[type="radio"] { } .hidden { - display: none !important; + display: none !important; } @media screen and (max-width: 480px) { body { - background-image: none; - background-color: var(--background); - padding: 0; + background-image: none; + background-color: var(--background); + padding: 0; } .card { - border-radius: unset; - box-shadow: unset; + border-radius: unset; + box-shadow: unset; } } @@ -141,7 +141,7 @@ input[type="checkbox"], input[type="radio"] { } a, button.text { - color: var(--link); + color: var(--link); } button.text { diff --git a/images/client-icons/fluffychat.svg b/images/client-icons/fluffychat.svg index a3a9516..934ebd9 100644 --- a/images/client-icons/fluffychat.svg +++ b/images/client-icons/fluffychat.svg @@ -1,43 +1,43 @@ + viewBox="0 0 181.4 181.9" style="enable-background:new 0 0 181.4 181.9;" xml:space="preserve"> - + - - - - - - - - - - + + + + + + + + + + diff --git a/index.html b/index.html index 7f5fdc8..dda600c 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,17 @@ - - You're invited to talk on Matrix - - - + + You're invited to talk on Matrix + + + - +