2018-06-24 13:08:48 +09:00
|
|
|
<template>
|
2018-09-28 14:26:20 +09:00
|
|
|
<div class="syxhndwprovvuqhmyvveewmbqayniwkv" v-if="!fetching">
|
2019-01-19 08:28:46 +09:00
|
|
|
<div class="signed-in-as">
|
2019-01-19 08:45:12 +09:00
|
|
|
<mfm :text="$t('signed-in-as').replace('{}', myName)" :should-break="false" :plain-text="true" :custom-emojis="$store.state.i.emojis"/>
|
2019-01-19 08:28:46 +09:00
|
|
|
</div>
|
2018-06-24 13:08:48 +09:00
|
|
|
<main>
|
|
|
|
<div class="banner" :style="bannerStyle"></div>
|
|
|
|
<mk-avatar class="avatar" :user="user" :disable-preview="true"/>
|
|
|
|
<div class="body">
|
2018-12-06 10:02:04 +09:00
|
|
|
<router-link :to="user | userPage" class="name">
|
2018-12-06 11:18:13 +09:00
|
|
|
<mk-user-name :user="user"/>
|
2018-12-06 10:02:04 +09:00
|
|
|
</router-link>
|
2018-06-24 13:08:48 +09:00
|
|
|
<span class="username">@{{ user | acct }}</span>
|
|
|
|
<div class="description">
|
2019-02-17 23:41:47 +09:00
|
|
|
<mfm v-if="user.description" :text="user.description" :is-note="false" :author="user" :i="$store.state.i" :custom-emojis="user.emojis"/>
|
2018-06-24 13:08:48 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
<button
|
|
|
|
:class="{ wait: followWait, active: user.isFollowing || user.hasPendingFollowRequestFromYou }"
|
|
|
|
@click="onClick"
|
|
|
|
:disabled="followWait">
|
|
|
|
<template v-if="!followWait">
|
2018-11-09 03:44:35 +09:00
|
|
|
<template v-if="user.hasPendingFollowRequestFromYou && user.isLocked"><fa icon="hourglass-half"/> {{ $t('request-pending') }}</template>
|
2018-12-21 02:30:49 +09:00
|
|
|
<template v-else-if="user.hasPendingFollowRequestFromYou && !user.isLocked"><fa icon="spinner"/> {{ $t('follow-processing') }}</template>
|
2018-11-09 03:44:35 +09:00
|
|
|
<template v-else-if="user.isFollowing"><fa icon="minus"/> {{ $t('following') }}</template>
|
|
|
|
<template v-else-if="!user.isFollowing && user.isLocked"><fa icon="plus"/> {{ $t('follow-request') }}</template>
|
|
|
|
<template v-else-if="!user.isFollowing && !user.isLocked"><fa icon="plus"/> {{ $t('follow') }}</template>
|
2018-06-24 13:08:48 +09:00
|
|
|
</template>
|
2018-11-13 22:45:28 +09:00
|
|
|
<template v-else><fa icon="spinner" pulse fixed-width/></template>
|
2018-06-24 13:08:48 +09:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-09 03:44:35 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-07-07 19:19:00 +09:00
|
|
|
import parseAcct from '../../../../../misc/acct/parse';
|
2018-06-24 13:08:48 +09:00
|
|
|
import Progress from '../../../common/scripts/loading';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n('common/views/pages/follow.vue'),
|
2018-06-24 13:08:48 +09:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
user: null,
|
|
|
|
followWait: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
myName(): string {
|
|
|
|
return Vue.filter('userName')(this.$store.state.i);
|
|
|
|
},
|
|
|
|
|
|
|
|
bannerStyle(): any {
|
|
|
|
if (this.user.bannerUrl == null) return {};
|
|
|
|
return {
|
2019-04-08 19:56:42 +09:00
|
|
|
backgroundColor: this.user.bannerColor,
|
2018-06-24 13:08:48 +09:00
|
|
|
backgroundImage: `url(${ this.user.bannerUrl })`
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
const acct = new URL(location.href).searchParams.get('acct');
|
|
|
|
this.fetching = true;
|
|
|
|
Progress.start();
|
2018-11-09 08:13:34 +09:00
|
|
|
this.$root.api('users/show', parseAcct(acct)).then(user => {
|
2018-06-24 13:08:48 +09:00
|
|
|
this.user = user;
|
|
|
|
this.fetching = false;
|
|
|
|
Progress.done();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async onClick() {
|
|
|
|
this.followWait = true;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (this.user.isFollowing) {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.user = await this.$root.api('following/delete', {
|
2018-06-24 13:08:48 +09:00
|
|
|
userId: this.user.id
|
|
|
|
});
|
|
|
|
} else {
|
2018-09-04 18:33:16 +09:00
|
|
|
if (this.user.hasPendingFollowRequestFromYou) {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.user = await this.$root.api('following/requests/cancel', {
|
2018-06-24 13:08:48 +09:00
|
|
|
userId: this.user.id
|
|
|
|
});
|
|
|
|
} else if (this.user.isLocked) {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.user = await this.$root.api('following/create', {
|
2018-06-24 13:08:48 +09:00
|
|
|
userId: this.user.id
|
|
|
|
});
|
|
|
|
} else {
|
2018-11-09 08:13:34 +09:00
|
|
|
this.user = await this.$root.api('following/create', {
|
2018-06-24 13:08:48 +09:00
|
|
|
userId: this.user.id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
} finally {
|
|
|
|
this.followWait = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 19:59:19 +09:00
|
|
|
.syxhndwprovvuqhmyvveewmbqayniwkv
|
2018-06-24 13:08:48 +09:00
|
|
|
padding 32px
|
|
|
|
max-width 500px
|
|
|
|
margin 0 auto
|
|
|
|
text-align center
|
2018-09-28 19:59:19 +09:00
|
|
|
color var(--text)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
2018-09-26 20:28:13 +09:00
|
|
|
$bg = var(--face)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
@media (max-width 400px)
|
|
|
|
padding 16px
|
|
|
|
|
|
|
|
> .signed-in-as
|
|
|
|
margin-bottom 16px
|
|
|
|
font-size 14px
|
2019-01-19 08:28:46 +09:00
|
|
|
font-weight bold
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
> main
|
|
|
|
margin-bottom 16px
|
|
|
|
background $bg
|
|
|
|
border-radius 8px
|
|
|
|
box-shadow 0 4px 12px rgba(#000, 0.1)
|
|
|
|
overflow hidden
|
|
|
|
|
|
|
|
> .banner
|
|
|
|
height 128px
|
|
|
|
background-position center
|
|
|
|
background-size cover
|
|
|
|
|
|
|
|
> .avatar
|
|
|
|
display block
|
|
|
|
margin -50px auto 0 auto
|
|
|
|
width 100px
|
|
|
|
height 100px
|
|
|
|
border-radius 100%
|
|
|
|
border solid 4px $bg
|
|
|
|
|
|
|
|
> .body
|
|
|
|
padding 4px 32px 32px 32px
|
|
|
|
|
|
|
|
@media (max-width 400px)
|
|
|
|
padding 4px 16px 16px 16px
|
|
|
|
|
|
|
|
> .name
|
|
|
|
font-size 20px
|
|
|
|
font-weight bold
|
|
|
|
|
|
|
|
> .username
|
|
|
|
display block
|
|
|
|
opacity 0.7
|
|
|
|
|
|
|
|
> .description
|
|
|
|
margin-top 16px
|
|
|
|
|
|
|
|
> button
|
|
|
|
display block
|
|
|
|
user-select none
|
|
|
|
cursor pointer
|
|
|
|
padding 10px 16px
|
|
|
|
margin 0
|
|
|
|
width 100%
|
|
|
|
min-width 150px
|
|
|
|
font-size 14px
|
|
|
|
font-weight bold
|
2018-09-26 20:19:35 +09:00
|
|
|
color var(--primary)
|
2018-06-24 13:08:48 +09:00
|
|
|
background transparent
|
|
|
|
outline none
|
2018-09-26 20:19:35 +09:00
|
|
|
border solid 1px var(--primary)
|
2018-06-24 13:08:48 +09:00
|
|
|
border-radius 36px
|
|
|
|
|
|
|
|
&:hover
|
2018-09-26 20:19:35 +09:00
|
|
|
background var(--primaryAlpha01)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
&:active
|
2018-09-26 20:19:35 +09:00
|
|
|
background var(--primaryAlpha02)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
&.active
|
2018-09-26 20:19:35 +09:00
|
|
|
color var(--primaryForeground)
|
|
|
|
background var(--primary)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
&:hover
|
2018-09-26 20:19:35 +09:00
|
|
|
background var(--primaryLighten10)
|
|
|
|
border-color var(--primaryLighten10)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
&:active
|
2018-09-26 20:19:35 +09:00
|
|
|
background var(--primaryDarken10)
|
|
|
|
border-color var(--primaryDarken10)
|
2018-06-24 13:08:48 +09:00
|
|
|
|
|
|
|
&.wait
|
|
|
|
cursor wait !important
|
|
|
|
opacity 0.7
|
|
|
|
|
|
|
|
*
|
|
|
|
pointer-events none
|
|
|
|
|
|
|
|
</style>
|