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

150 lines
3.3 KiB
Vue
Raw Normal View History

2018-02-14 17:32:13 +02:00
<template>
<div class="profile" v-if="$store.getters.isSignedIn">
<div class="friend-form" v-if="$store.state.i.id != user.id">
2018-02-14 17:32:13 +02:00
<mk-follow-button :user="user" size="big"/>
2018-04-14 19:04:40 +03:00
<p class="followed" v-if="user.isFollowed">%i18n:@follows-you%</p>
2018-04-26 10:10:01 +03:00
<p class="stalk" v-if="user.isFollowing">
<span v-if="user.isStalking">%i18n:@stalking% <a @click="unstalk"><fa icon="meh"/> %i18n:@unstalk%</a></span>
<span v-if="!user.isStalking"><a @click="stalk"><fa icon="user-secret"/> %i18n:@stalk%</a></span>
2018-04-19 06:43:25 +03:00
</p>
2018-02-14 17:32:13 +02:00
</div>
2018-04-26 10:10:01 +03:00
<div class="action-form">
2018-10-20 09:37:17 +03:00
<ui-button @click="user.isMuted ? unmute() : mute()" v-if="$store.state.i.id != user.id">
<span v-if="user.isMuted"><fa icon="eye"/> %i18n:@unmute%</span>
<span v-else><fa icon="eye-slash"/> %i18n:@mute%</span>
2018-10-20 09:37:17 +03:00
</ui-button>
<ui-button @click="user.isBlocking ? unblock() : block()" v-if="$store.state.i.id != user.id">
<span v-if="user.isBlocking"><fa icon="user"/> %i18n:@unblock%</span>
<span v-else><fa icon="user-slash"/> %i18n:@block%</span>
</ui-button>
<ui-button @click="list"><fa icon="list"/> %i18n:@push-to-a-list%</ui-button>
2018-04-26 10:10:01 +03:00
</div>
2018-02-14 17:32:13 +02:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
2018-04-26 10:10:01 +03:00
import MkUserListsWindow from '../../components/user-lists-window.vue';
2018-02-14 17:32:13 +02:00
export default Vue.extend({
props: ['user'],
2018-06-23 17:18:39 +03:00
methods: {
2018-04-19 06:43:25 +03: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 17:32:13 +02:00
mute() {
2018-02-18 05:35:18 +02:00
(this as any).api('mute/create', {
2018-03-29 08:48:47 +03:00
userId: this.user.id
2018-02-14 17:32:13 +02:00
}).then(() => {
2018-03-29 08:48:47 +03:00
this.user.isMuted = true;
2018-02-19 16:37:09 +02:00
}, () => {
2018-02-14 17:32:13 +02:00
alert('error');
});
},
unmute() {
2018-02-18 05:35:18 +02:00
(this as any).api('mute/delete', {
2018-03-29 08:48:47 +03:00
userId: this.user.id
2018-02-14 17:32:13 +02:00
}).then(() => {
2018-03-29 08:48:47 +03:00
this.user.isMuted = false;
2018-02-19 16:37:09 +02:00
}, () => {
2018-02-14 17:32:13 +02:00
alert('error');
});
2018-04-26 10:10:01 +03:00
},
block() {
if (!window.confirm('%i18n:@block-confirm%')) return;
(this as any).api('blocking/create', {
userId: this.user.id
}).then(() => {
this.user.isBlocking = true;
}, () => {
alert('error');
});
},
unblock() {
(this as any).api('blocking/delete', {
userId: this.user.id
}).then(() => {
this.user.isBlocking = false;
}, () => {
alert('error');
});
},
2018-04-26 10:10:01 +03: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!',
2018-08-06 21:20:26 +03:00
text: '%i18n:@list-pushed%'.replace('{user}', this.user.name).replace('{list}', list.title)
2018-04-26 10:10:01 +03:00
});
});
2018-02-14 17:32:13 +02:00
}
}
});
</script>
<style lang="stylus" scoped>
2018-09-28 08:26:20 +03:00
.profile
2018-09-26 14:28:13 +03:00
background var(--face)
2018-09-22 14:39:12 +03:00
box-shadow var(--shadow)
border-radius var(--round)
2018-02-14 17:32:13 +02:00
> *:first-child
border-top none !important
> .friend-form
padding 16px
2018-04-26 10:10:01 +03:00
text-align center
2018-09-28 08:26:20 +03:00
border-bottom solid 1px var(--faceDivider)
2018-02-14 17:32:13 +02: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 10:10:01 +03:00
> .stalk
margin 12px 0 0 0
> .action-form
padding 16px
text-align center
> *
width 100%
&:not(:last-child)
margin-bottom 12px
2018-02-14 17:32:13 +02:00
</style>