Merge branch '591-more-work' into 'dev'

Remove global "auto_join_rooms" flag and use optional "/join" segments in invite links

See merge request keanuapp/keanuapp-weblite!310
This commit is contained in:
N Pex 2024-07-30 16:32:39 +00:00
commit a09bfccd4f
7 changed files with 14 additions and 34 deletions

View file

@ -53,7 +53,6 @@ The app loads runtime configutation from the server at "./config.json" and merge
* **accentColor** - The accent color of the app UI. Use a HTML-style color value string, like "#ff0080". * **accentColor** - The accent color of the app UI. Use a HTML-style color value string, like "#ff0080".
* **show_status_messages** - Whether to show only user joins/leaves and display name updates, or the full range of room status updates. Possible values are "never" (only the above), "moderators" (moderators will see all status updates) or "always" (everyone will see all status updates). Defaults to "always". * **show_status_messages** - Whether to show only user joins/leaves and display name updates, or the full range of room status updates. Possible values are "never" (only the above), "moderators" (moderators will see all status updates) or "always" (everyone will see all status updates). Defaults to "always".
* **maxSizeAutoDownloads** - Attachments smaller than this will be auto downloaded. Default is 10Mb. * **maxSizeAutoDownloads** - Attachments smaller than this will be auto downloaded. Default is 10Mb.
* **auto_join_rooms** - Whether to show the normal "join" screen or just auto join the user to the room link. Default to false.
### Sticker short codes - To enable sticker short codes, follow these steps: ### Sticker short codes - To enable sticker short codes, follow these steps:
* Run the "create sticker config" script using "npm run create-sticker-config <path-to-sticker-packs>" * Run the "create sticker config" script using "npm run create-sticker-config <path-to-sticker-packs>"

View file

@ -1055,7 +1055,7 @@ export default {
this.$navigation.push( this.$navigation.push(
{ {
name: "Join", name: "Join",
params: { roomId: util.sanitizeRoomId(this.roomAliasOrId) }, params: { roomId: util.sanitizeRoomId(this.roomAliasOrId), join: this.$route.params.join },
}, },
0 0
); );

View file

@ -306,7 +306,7 @@ export default {
return roomName ? roomName : ""; return roomName ? roomName : "";
}, },
getRoomInfo() { getRoomInfo() {
if (this.$config.auto_join_rooms) { if (this.$route.params.join) {
// Auto-join room // Auto-join room
this.waitingForRoomCreation = true; this.waitingForRoomCreation = true;
this.$nextTick(() => { this.$nextTick(() => {

View file

@ -1,14 +1,6 @@
<template> <template>
<div v-if="$config.auto_join_rooms && !roomCreatedByYou() && event.getSender() == $matrix.currentUserId" class="created-room-welcome-header" style="white-space: pre-line;">
{{ $t('room_welcome.info_auto_join',{room: room ? room.name : "",you: $matrix.currentUserDisplayName}) }}
<div class="ma-0">
<a href="#" text @click.prevent="viewProfile">
{{ $t("room_welcome.change") }}
</a>
</div>
</div>
<!-- Contact joined the chat --> <!-- Contact joined the chat -->
<div v-else class="messageJoin"> <div class="messageJoin">
{{ $t('message.user_joined',{user: eventSenderDisplayName(event)}) }} {{ $t('message.user_joined',{user: eventSenderDisplayName(event)}) }}
</div> </div>
</template> </template>
@ -18,19 +10,6 @@ import messageMixin from "./messageMixin";
export default { export default {
mixins: [messageMixin], mixins: [messageMixin],
methods: {
viewProfile() {
this.$navigation.push({ name: "Profile" }, 1);
},
roomCreatedByYou() {
const createEvent = this.room && this.room.currentState.getStateEvents("m.room.create", "");
if (createEvent) {
const creatorId = createEvent.getContent().creator;
return (creatorId == this.$matrix.currentUserId);
}
return false;
},
}
}; };
</script> </script>

View file

@ -1,4 +1,4 @@
import utils from "../plugins/utils"; import utils, { ROOM_TYPE_CHANNEL } from "../plugins/utils";
import roomTypeMixin from "./roomTypeMixin"; import roomTypeMixin from "./roomTypeMixin";
export default { export default {
@ -96,7 +96,8 @@ export default {
this.room.getCanonicalAlias(), this.room.getCanonicalAlias(),
this.room.roomId, this.room.roomId,
this.room.name, this.room.name,
utils.roomDisplayTypeToQueryParam(this.room, this.roomDisplayType) utils.roomDisplayTypeToQueryParam(this.room, this.roomDisplayType),
this.roomDisplayType == ROOM_TYPE_CHANNEL /* Auto join for channels */
); );
} }
return null; return null;

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="created-room-welcome-header"> <div class="created-room-welcome-header">
<div v-if="$config.auto_join_rooms" style="white-space: pre-line;"> <div style="white-space: pre-line;">
{{ $t('room_welcome.info_auto_join',{room: room ? room.name : "",you: $matrix.currentUserDisplayName}) }} {{ $t('room_welcome.info_auto_join',{room: room ? room.name : "",you: $matrix.currentUserDisplayName}) }}
<a href="#" text @click.prevent="viewProfile"> <a href="#" text @click.prevent="viewProfile">
{{ $t("room_welcome.change") }} {{ $t("room_welcome.change") }}

View file

@ -20,13 +20,13 @@ const routes = [
component: Home component: Home
}, },
{ {
path: '/room/:roomId?', path: '/room/:join(join/)?:roomId?',
name: 'Chat', name: 'Chat',
component: Chat, component: Chat,
meta: { meta: {
includeRoom: true, includeRoom: true,
includeFavicon: true includeFavicon: true
} },
}, },
{ {
path: '/info', path: '/info',
@ -73,7 +73,7 @@ const routes = [
props: true props: true
}, },
{ {
path: '/join/:roomId?', path: '/join/:join(join/)?:roomId?',
name: 'Join', name: 'Join',
component: Join component: Join
}, },
@ -170,7 +170,7 @@ router.beforeEach((to, from, next) => {
} }
}); });
router.getRoomLink = function (alias, roomId, roomName, mode) { router.getRoomLink = function (alias, roomId, roomName, mode, autojoin) {
let params = {}; let params = {};
if ((!alias || roomName.replace(/\s/g, "").toLowerCase() !== util.getRoomNameFromAlias(alias)) && roomName) { 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 // There is no longer a correlation between alias and room name, probably because room name has
@ -181,13 +181,14 @@ router.getRoomLink = function (alias, roomId, roomName, mode) {
// Optional mode given, append as "m" query param // Optional mode given, append as "m" query param
params["m"] = mode; params["m"] = mode;
} }
const autoJoinSegment = autojoin ? "join/" : "";
if (Object.entries(params).length > 0) { if (Object.entries(params).length > 0) {
const queryString = Object.entries(params) const queryString = Object.entries(params)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&') .join('&')
return window.location.origin + window.location.pathname + "?" + queryString + "#/room/" + encodeURIComponent(util.sanitizeRoomId(alias || roomId)); return window.location.origin + window.location.pathname + "?" + queryString + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId));
} }
return window.location.origin + window.location.pathname + "#/room/" + encodeURIComponent(util.sanitizeRoomId(alias || roomId)); return window.location.origin + window.location.pathname + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId));
} }
router.getDMLink = function (user, config) { router.getDMLink = function (user, config) {