hippofish/src/client/app/desktop/views/pages/user/user.profile.vue

132 lines
2.8 KiB
Vue
Raw Normal View History

2018-02-14 16:32:13 +01:00
<template>
2018-02-20 17:39:51 +01:00
<div class="profile">
2018-05-27 06:49:09 +02:00
<div class="friend-form" v-if="$store.getters.isSignedIn && $store.state.i.id != user.id">
2018-02-14 16:32:13 +01:00
<mk-follow-button :user="user" size="big"/>
2018-04-14 18:04:40 +02:00
<p class="followed" v-if="user.isFollowed">%i18n:@follows-you%</p>
2018-04-26 09:10:01 +02:00
<p class="stalk" v-if="user.isFollowing">
<span v-if="user.isStalking">%i18n:@stalking% <a @click="unstalk">%fa:meh% %i18n:@unstalk%</a></span>
<span v-if="!user.isStalking"><a @click="stalk">%fa:user-secret% %i18n:@stalk%</a></span>
2018-04-19 05:43:25 +02:00
</p>
2018-02-14 16:32:13 +01:00
</div>
2018-04-26 09:10:01 +02:00
<div class="action-form">
<button class="mute ui" @click="user.isMuted ? unmute() : mute()">
<span v-if="user.isMuted">%fa:eye% %i18n:@unmute%</span>
<span v-if="!user.isMuted">%fa:eye-slash% %i18n:@mute%</span>
</button>
<button class="mute ui" @click="list">%fa:list% リストに追加</button>
</div>
2018-02-14 16:32:13 +01:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
2018-04-26 09:10:01 +02:00
import MkUserListsWindow from '../../components/user-lists-window.vue';
2018-02-14 16:32:13 +01:00
export default Vue.extend({
props: ['user'],
2018-06-23 16:18:39 +02:00
methods: {
2018-04-19 05:43:25 +02:00
stalk() {
(this as any).api('following/stalk', {
userId: this.user.id
}).then(() => {
this.user.isStalking = true;
}, () => {
alert('error');
});
},
unstalk() {
(this as any).api('following/unstalk', {
userId: this.user.id
}).then(() => {
this.user.isStalking = false;
}, () => {
alert('error');
});
},
2018-02-14 16:32:13 +01:00
mute() {
2018-02-18 04:35:18 +01:00
(this as any).api('mute/create', {
2018-03-29 07:48:47 +02:00
userId: this.user.id
2018-02-14 16:32:13 +01:00
}).then(() => {
2018-03-29 07:48:47 +02:00
this.user.isMuted = true;
2018-02-19 15:37:09 +01:00
}, () => {
2018-02-14 16:32:13 +01:00
alert('error');
});
},
unmute() {
2018-02-18 04:35:18 +01:00
(this as any).api('mute/delete', {
2018-03-29 07:48:47 +02:00
userId: this.user.id
2018-02-14 16:32:13 +01:00
}).then(() => {
2018-03-29 07:48:47 +02:00
this.user.isMuted = false;
2018-02-19 15:37:09 +01:00
}, () => {
2018-02-14 16:32:13 +01:00
alert('error');
});
2018-04-26 09:10:01 +02:00
},
list() {
const w = (this as any).os.new(MkUserListsWindow);
w.$once('choosen', async list => {
w.close();
await (this as any).api('users/lists/push', {
listId: list.id,
userId: this.user.id
});
(this as any).apis.dialog({
title: 'Done!',
text: `${this.user.name}${list.title}に追加しました。`
});
});
2018-02-14 16:32:13 +01:00
}
}
});
</script>
<style lang="stylus" scoped>
2018-06-20 12:55:34 +02:00
root(isDark)
background isDark ? #282C37 : #fff
2018-04-29 01:51:17 +02:00
border solid 1px rgba(#000, 0.075)
2018-02-14 16:32:13 +01:00
border-radius 6px
> *:first-child
border-top none !important
> .friend-form
padding 16px
2018-04-26 09:10:01 +02:00
text-align center
border-bottom solid 1px isDark ? #21242f : #eee
2018-02-14 16:32:13 +01:00
> .followed
margin 12px 0 0 0
padding 0
text-align center
line-height 24px
font-size 0.8em
color #71afc7
background #eefaff
border-radius 4px
2018-04-26 09:10:01 +02:00
> .stalk
margin 12px 0 0 0
> .action-form
padding 16px
text-align center
border-bottom solid 1px isDark ? #21242f : #eee
2018-04-26 09:10:01 +02:00
> *
width 100%
&:not(:last-child)
margin-bottom 12px
2018-06-20 12:55:34 +02:00
.profile[data-darkmode]
root(true)
.profile:not([data-darkmode])
root(false)
2018-02-14 16:32:13 +01:00
</style>