Remove room creation option(s) if hide_add_room_on_home is set

This commit is contained in:
N-Pex 2023-10-31 09:51:57 +01:00
parent b5678a04e4
commit 86d5f0c250
6 changed files with 22 additions and 6 deletions

View file

@ -7,7 +7,7 @@
<v-container <v-container
fluid fluid
fill-height fill-height
v-if="loading" v-if="showLoadingScreen"
class="loading-container" class="loading-container"
> >
<v-row align="center" justify="center"> <v-row align="center" justify="center">
@ -23,7 +23,7 @@
<v-skeleton-loader <v-skeleton-loader
type="list-item-avatar-two-line, divider, list-item-three-line, card-heading" type="list-item-avatar-two-line, divider, list-item-three-line, card-heading"
v-if="loading" v-if="showLoadingScreen"
></v-skeleton-loader> ></v-skeleton-loader>
</v-main> </v-main>
</v-app> </v-app>
@ -132,6 +132,9 @@ export default {
}, },
}, },
computed: { computed: {
showLoadingScreen() {
return this.loading || !(this.$config.loaded);
},
notificationCount, notificationCount,
currentUser() { currentUser() {
return this.$store.state.auth.user; return this.$store.state.auth.user;

View file

@ -86,7 +86,7 @@
class="filled-button mt-4" class="filled-button mt-4"
>{{ $t("login.login") }}</v-btn >{{ $t("login.login") }}</v-btn
> >
<div class="mt-2 overline" v-if="showCreateRoomOption">{{ $t("login.or") }}</div> <div class="mt-2 overline" v-if="showCreateRoom">{{ $t("login.or") }}</div>
<v-btn <v-btn
id="btn-create-room" id="btn-create-room"
color="primary" color="primary"
@ -94,7 +94,7 @@
block block
@click.stop="handleCreateRoom" @click.stop="handleCreateRoom"
class="filled-button mt-2" class="filled-button mt-2"
v-if="showCreateRoomOption" v-if="showCreateRoom"
>{{ $t("login.create_room") }}</v-btn >{{ $t("login.create_room") }}</v-btn
> >
</v-form> </v-form>
@ -151,6 +151,9 @@ export default {
showCloseButton() { showCloseButton() {
return this.$navigation && this.$navigation.canPop(); return this.$navigation && this.$navigation.canPop();
}, },
showCreateRoom() {
return this.showCreateRoomOption && !this.$config.hide_add_room_on_home;
}
}, },
created() { created() {
if (this.loggedIn) { if (this.loggedIn) {

View file

@ -50,7 +50,7 @@
<a :href="'//' + productLink">{{ productLink }}</a> <a :href="'//' + productLink">{{ productLink }}</a>
</template> </template>
</i18n> </i18n>
<div class="text-end"> <div class="text-end" v-if="!$config.hide_add_room_on_home">
<v-btn id="btn-new-room" class="new_room" text @click="createRoom"> <v-btn id="btn-new-room" class="new_room" text @click="createRoom">
{{ $t("profile_info_popup.new_room") }} {{ $t("profile_info_popup.new_room") }}
</v-btn> </v-btn>

View file

@ -6,7 +6,7 @@
:showCloseButton="false" :showCloseButton="false"
> >
<div class="room-info-sheet" ref="roomInfoSheetContent"> <div class="room-info-sheet" ref="roomInfoSheetContent">
<room-list v-on:close="close" v-on:newroom="createRoom" :showCreate="true" /> <room-list v-on:close="close" v-on:newroom="createRoom" :showCreate="!$config.hide_add_room_on_home" />
</div> </div>
</BottomSheet> </BottomSheet>
</template> </template>

View file

@ -145,6 +145,14 @@ router.beforeEach((to, from, next) => {
const roomId = util.sanitizeRoomId(to.params.roomId); const roomId = util.sanitizeRoomId(to.params.roomId);
router.app.$matrix.setCurrentRoomId(roomId); router.app.$matrix.setCurrentRoomId(roomId);
} }
} else if (to.name == 'CreateRoom') {
return router.app.$config.promise.then((config) => {
if (config.hide_add_room_on_home) {
next('/');
} else {
next();
}
}).catch(err => { console.error(err); next('/'); });
} }
// trying to access a restricted page + not logged in // trying to access a restricted page + not logged in

View file

@ -1,6 +1,7 @@
export default { export default {
install(Vue, defaultServerFromLocation, onloaded) { install(Vue, defaultServerFromLocation, onloaded) {
var config = Vue.observable(require('@/assets/config.json')); var config = Vue.observable(require('@/assets/config.json'));
Vue.set(config, "loaded", false);
const getRuntimeConfig = () => { const getRuntimeConfig = () => {
return fetch('./config.json?ms=' + Date.now()).then((res) => res.json()).catch(err => { return fetch('./config.json?ms=' + Date.now()).then((res) => res.json()).catch(err => {
console.error("Failed to get config:", err); console.error("Failed to get config:", err);
@ -17,6 +18,7 @@ export default {
if (!json.defaultServer) { if (!json.defaultServer) {
Vue.set(config, "defaultServer", defaultServerFromLocation); Vue.set(config, "defaultServer", defaultServerFromLocation);
} }
Vue.set(config, "loaded", true);
// Tell callback we are done loading runtime config // Tell callback we are done loading runtime config
if (onloaded) { if (onloaded) {