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

View file

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

View file

@ -50,7 +50,7 @@
<a :href="'//' + productLink">{{ productLink }}</a>
</template>
</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">
{{ $t("profile_info_popup.new_room") }}
</v-btn>

View file

@ -6,7 +6,7 @@
:showCloseButton="false"
>
<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>
</BottomSheet>
</template>

View file

@ -145,6 +145,14 @@ router.beforeEach((to, from, next) => {
const roomId = util.sanitizeRoomId(to.params.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

View file

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