Support "mirrors" array in the config file for link sharing
For issue #642
This commit is contained in:
parent
4648e4969c
commit
e3f7f1758f
9 changed files with 72 additions and 27 deletions
18
package-lock.json
generated
18
package-lock.json
generated
|
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"name": "keanuapp-weblite",
|
||||
"version": "0.1.49",
|
||||
"version": "0.1.51",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "keanuapp-weblite",
|
||||
"version": "0.1.49",
|
||||
"version": "0.1.51",
|
||||
"dependencies": {
|
||||
"@guardianproject/proofmode": "^0.3.2",
|
||||
"@guardianproject/proofmode": "^0.4.0",
|
||||
"@matrix-org/olm": "^3.2.12",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"aes-js": "^3.1.2",
|
||||
|
|
@ -942,9 +942,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@guardianproject/proofmode": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@guardianproject/proofmode/-/proofmode-0.3.2.tgz",
|
||||
"integrity": "sha512-p71l7hheUoAWYbq/t1WoP94n6Ug9PUnapNtUKytvY688+NgeFHjL7Uc8X/K+Li3ikztfm0kM30q5nbAOJU14Fw==",
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@guardianproject/proofmode/-/proofmode-0.4.0.tgz",
|
||||
"integrity": "sha512-k/zf7DoSF8ijoJ5QUpEA/O9/85P6sRUlTGAK/wHsZYwFkJiAWdDpy9D7muC9X5OtSeCUMFhaMo56lmyoetg6iA==",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@humanwhocodes/config-array": {
|
||||
|
|
@ -8523,9 +8523,9 @@
|
|||
}
|
||||
},
|
||||
"@guardianproject/proofmode": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@guardianproject/proofmode/-/proofmode-0.3.2.tgz",
|
||||
"integrity": "sha512-p71l7hheUoAWYbq/t1WoP94n6Ug9PUnapNtUKytvY688+NgeFHjL7Uc8X/K+Li3ikztfm0kM30q5nbAOJU14Fw=="
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@guardianproject/proofmode/-/proofmode-0.4.0.tgz",
|
||||
"integrity": "sha512-k/zf7DoSF8ijoJ5QUpEA/O9/85P6sRUlTGAK/wHsZYwFkJiAWdDpy9D7muC9X5OtSeCUMFhaMo56lmyoetg6iA=="
|
||||
},
|
||||
"@humanwhocodes/config-array": {
|
||||
"version": "0.5.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "keanuapp-weblite",
|
||||
"version": "0.1.51",
|
||||
"version": "0.1.52",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
"create-sticker-config": "node ./create_sticker_config.js $1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@guardianproject/proofmode": "^0.3.2",
|
||||
"@guardianproject/proofmode": "^0.4.0",
|
||||
"@matrix-org/olm": "^3.2.12",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"aes-js": "^3.1.2",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "keanuapp-weblite",
|
||||
"version": "0.1.50",
|
||||
"version": "0.1.51",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
"create-sticker-config": "node ./create_sticker_config.js $1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@guardianproject/proofmode": "^0.3.2",
|
||||
"@guardianproject/proofmode": "^0.4.0",
|
||||
"@matrix-org/olm": "^3.2.12",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"aes-js": "^3.1.2",
|
||||
|
|
|
|||
|
|
@ -53,5 +53,6 @@
|
|||
"experimental_read_only_room": true,
|
||||
"experimental_public_room": true,
|
||||
"show_status_messages": "never",
|
||||
"hide_add_room_on_home": false
|
||||
"hide_add_room_on_home": false,
|
||||
"mirrors": []
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
<v-card class="ma-3" v-show="locationLink" variant="flat">
|
||||
<v-container>
|
||||
<slot/>
|
||||
<v-row cols="12" class="qr-container ma-3">
|
||||
<v-row cols="12" class="qr-container mt-3 ml-3 mr-3">
|
||||
<v-col cols="auto">
|
||||
<canvas
|
||||
v-longTap:250="[
|
||||
|
|
@ -23,7 +23,26 @@
|
|||
<div class="link">{{ locationLink }}</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row align="center" class="mt-0 pt-0">
|
||||
<v-row v-if="mirrors.length > 0" justify="end" class="mt-3">
|
||||
<v-col cols="auto">
|
||||
<v-select
|
||||
:items="mirrors"
|
||||
v-model="currentMirror"
|
||||
:menu-props="{ auto: true }"
|
||||
hide-details
|
||||
single-line
|
||||
density="compact"
|
||||
bg-color="transparent"
|
||||
variant="solo"
|
||||
flat
|
||||
>
|
||||
<template v-slot:selection>
|
||||
<span style="font-size: 0.8rem">Use a mirror</span>
|
||||
</template>
|
||||
</v-select>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row align="center" class="mt-3 pt-0">
|
||||
<v-col align="center" class="mt-0 pt-0">
|
||||
<v-btn
|
||||
id="btn-copy-room-link"
|
||||
|
|
@ -50,6 +69,7 @@ export default {
|
|||
components: {
|
||||
QRCodePopup
|
||||
},
|
||||
emits: ['mirror-change'],
|
||||
props: {
|
||||
locationLink: {
|
||||
type: String
|
||||
|
|
@ -61,19 +81,32 @@ export default {
|
|||
i18nQrPopupTitleKey: {
|
||||
type: String,
|
||||
default: 'room_info.scan_code'
|
||||
},
|
||||
allowMirrors: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
locationLinkCopied: false,
|
||||
showFullScreenQR: false,
|
||||
currentMirror: "",
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
popupTitle() {
|
||||
return this.$t(this.i18nQrPopupTitleKey);
|
||||
},
|
||||
mirrors() {
|
||||
if (this.allowMirrors) {
|
||||
const m = this.$config.mirrors;
|
||||
if (m && Array.isArray(m) && m.length > 0) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
copyRoomLink() {
|
||||
|
|
@ -118,6 +151,11 @@ export default {
|
|||
handler() {
|
||||
this.updateQRCode();
|
||||
}
|
||||
},
|
||||
currentMirror: {
|
||||
handler(newVal) {
|
||||
this.$emit("mirror-change", newVal);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
</v-row>
|
||||
</v-container>
|
||||
|
||||
<copy-link :locationLink="directMessageLink" >
|
||||
<copy-link :locationLink="directMessageLink" :allowMirrors="true" @mirror-change="(mirror) => currentMirror = mirror">
|
||||
<v-card-title class="h2">{{ $t("room_info.direct_link") }}</v-card-title>
|
||||
<v-card-text>{{ $t("room_info.direct_link_desc") }}</v-card-text>
|
||||
</copy-link>
|
||||
|
|
@ -297,7 +297,8 @@ export default {
|
|||
isAvatarLoaded: true,
|
||||
loadValue: 0,
|
||||
newPasswordHasError: false,
|
||||
notificationDialog: false
|
||||
notificationDialog: false,
|
||||
currentMirror: null
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -306,7 +307,7 @@ export default {
|
|||
return this.$matrix.currentUser.user_id
|
||||
},
|
||||
directMessageLink() {
|
||||
return this.$router.getDMLink(this.$matrix.currentUser, this.$config);
|
||||
return this.$router.getDMLink(this.$matrix.currentUser, this.$config, this.currentMirror);
|
||||
},
|
||||
passwordsMatch() {
|
||||
return (
|
||||
|
|
@ -425,6 +426,7 @@ export default {
|
|||
if(this.globalNotification && this.windowNotificationPermission() !== 'granted') {
|
||||
this.onUpdateGlobalNotification(false);
|
||||
}
|
||||
this.currentMirror = null;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@
|
|||
{{ $t("room_info.created_by", { user: creator }) }}
|
||||
</div>
|
||||
</div>
|
||||
<copy-link :locationLink="publicRoomLink" i18nCopyLinkKey="copy_invite_link" />
|
||||
<copy-link :locationLink="publicRoomLink" i18nCopyLinkKey="copy_invite_link" :allowMirrors="true" @mirror-change="(mirror) => currentMirror = mirror" />
|
||||
|
||||
<v-card class="account ma-3" variant="flat">
|
||||
<v-card-title class="h2">{{ $t("room_info.permissions") }}</v-card-title>
|
||||
|
|
@ -419,7 +419,8 @@ export default {
|
|||
],
|
||||
SHOW_MEMBER_LIMIT: 5,
|
||||
exporting: false,
|
||||
activeMember: null
|
||||
activeMember: null,
|
||||
currentMirror: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
|
@ -427,6 +428,7 @@ export default {
|
|||
this.updateMembers();
|
||||
this.updateMessageRetention();
|
||||
this.user = this.$matrix.matrixClient.getUser(this.$matrix.currentUserId);
|
||||
this.currentMirror = null;
|
||||
|
||||
// Display build version
|
||||
this.buildVersion = buildVersion;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export default {
|
|||
isRoomTopicEditMode: false,
|
||||
roomTopicErrorMessage: null,
|
||||
messageRetentionDisplay: "",
|
||||
currentMirror: null,
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
|
|
@ -69,7 +70,8 @@ export default {
|
|||
this.room.name,
|
||||
utils.roomDisplayTypeToQueryParam(this.room, this.roomDisplayType),
|
||||
this.roomDisplayType == ROOM_TYPE_CHANNEL, /* Auto join for channels */
|
||||
this.roomJoinRule == "knock"
|
||||
this.roomJoinRule == "knock",
|
||||
this.currentMirror
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ router.beforeEach((to, from, next) => {
|
|||
}
|
||||
});
|
||||
|
||||
router.getRoomLink = function (alias, roomId, roomName, mode, autojoin, knock) {
|
||||
router.getRoomLink = function (alias, roomId, roomName, mode, autojoin, knock, mirror) {
|
||||
let params = {};
|
||||
if ((!alias || roomName.replace(/\s/g, "").toLowerCase() !== util.getRoomNameFromAlias(alias)) && roomName) {
|
||||
// There is no longer a correlation between alias and room name, probably because room name has
|
||||
|
|
@ -229,16 +229,16 @@ router.getRoomLink = function (alias, roomId, roomName, mode, autojoin, knock) {
|
|||
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
||||
.join('&')
|
||||
}
|
||||
return window.location.origin + window.location.pathname + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId)) + queryString;
|
||||
return (mirror ? (window.location.protocol + "//" + mirror) : window.location.origin) + window.location.pathname + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId)) + queryString;
|
||||
}
|
||||
|
||||
router.getDMLink = function (user, config) {
|
||||
router.getDMLink = function (user, config, mirror) {
|
||||
let userId = user.user_id;
|
||||
if (User.domainPart(userId) === config.defaultMatrixDomainPart && !config.useFullyQualifiedDMLinks) {
|
||||
// Using default server, don't include it in the link
|
||||
userId = User.localPart(user.user_id);
|
||||
}
|
||||
return `${window.location.origin + window.location.pathname}#/user/${encodeURIComponent(userId)}`
|
||||
return `${(mirror ? (window.location.protocol + "//" + mirror) : window.location.origin) + window.location.pathname}#/user/${encodeURIComponent(userId)}`
|
||||
}
|
||||
|
||||
export default router
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue