fchat-rising/chat/ChannelTagView.vue

38 lines
1.2 KiB
Vue
Raw Permalink Normal View History

2017-09-02 01:50:31 +00:00
<template>
2019-01-03 17:38:17 +00:00
<a href="#" @click.prevent="joinChannel()" :disabled="channel && channel.isJoined">
<span class="fa fa-hashtag"></span>
<template v-if="channel">{{channel.name}}<span class="bbcode-pseudo"> ({{channel.memberCount}})</span></template>
<template v-else>{{text}}</template>
</a>
2017-09-02 01:50:31 +00:00
</template>
<script lang="ts">
2019-01-03 17:38:17 +00:00
import {Component, Hook, Prop} from '@f-list/vue-ts';
2017-09-02 01:50:31 +00:00
import Vue from 'vue';
import core from './core';
import {Channel} from './interfaces';
@Component
export default class ChannelView extends Vue {
@Prop({required: true})
readonly id!: string;
2017-09-02 01:50:31 +00:00
@Prop({required: true})
readonly text!: string;
2017-09-02 01:50:31 +00:00
2019-01-03 17:38:17 +00:00
@Hook('mounted')
2018-04-16 23:14:13 +00:00
mounted(): void {
core.channels.requestChannelsIfNeeded(300000);
}
2017-09-02 01:50:31 +00:00
joinChannel(): void {
if(this.channel === undefined || !this.channel.isJoined)
core.channels.join(this.id);
2019-01-03 17:38:17 +00:00
const channel = core.conversations.byKey(`#${this.id}`);
if(channel !== undefined) channel.show();
2017-09-02 01:50:31 +00:00
}
get channel(): Channel.ListItem | undefined {
return core.channels.getChannelItem(this.id);
}
}
</script>