Skip to content
Snippets Groups Projects
messaging-room.vue 1.21 KiB
Newer Older
こぴなたみぽ's avatar
wip
こぴなたみぽ committed
<template>
<mk-ui>
	<span slot="header">
syuilo's avatar
syuilo committed
		<template v-if="user">%fa:R comments%{{ user | userName }}</template>
こぴなたみぽ's avatar
wip
こぴなたみぽ committed
		<template v-else><mk-ellipsis/></template>
	</span>
syuilo's avatar
syuilo committed
	<mk-messaging-room v-if="!fetching" :user="user" :is-naked="true"/>
こぴなたみぽ's avatar
wip
こぴなたみぽ committed
</mk-ui>
</template>

<script lang="ts">
import Vue from 'vue';
Akihiko Odaki's avatar
Akihiko Odaki committed
import parseAcct from '../../../../../acct/parse';
こぴなたみぽ's avatar
wip
こぴなたみぽ committed
export default Vue.extend({
	data() {
		return {
			fetching: true,
syuilo's avatar
syuilo committed
			user: null,
			unwatchDarkmode: null
こぴなたみぽ's avatar
wip
こぴなたみぽ committed
		};
	},
syuilo's avatar
syuilo committed
	watch: {
		$route: 'fetch'
	},
	created() {
syuilo's avatar
syuilo committed
		const applyBg = v =>
			document.documentElement.style.setProperty('background', v ? '#191b22' : '#fff', 'important');

		this.$nextTick(() => applyBg(this.$store.state.device.darkmode));

		this.unwatchDarkmode = this.$store.watch(s => {
			return s.device.darkmode;
		}, applyBg);

syuilo's avatar
syuilo committed
		this.fetch();
	},
syuilo's avatar
syuilo committed
	beforeDestroy() {
		document.documentElement.style.removeProperty('background');
		this.unwatchDarkmode();
	},
syuilo's avatar
syuilo committed
	methods: {
		fetch() {
			this.fetching = true;
			(this as any).api('users/show', parseAcct(this.$route.params.user)).then(user => {
syuilo's avatar
syuilo committed
				this.user = user;
				this.fetching = false;
こぴなたみぽ's avatar
wip
こぴなたみぽ committed

syuilo's avatar
syuilo committed
				document.title = `%i18n:@messaging%: ${Vue.filter('userName')(this.user)} | Misskey`;
syuilo's avatar
syuilo committed
			});
		}
こぴなたみぽ's avatar
wip
こぴなたみぽ committed
	}
});
</script>