1
0
Fork 0
pixelfed/resources/assets/js/components/Timeline.vue

1310 lines
43 KiB
Vue
Raw Normal View History

2018-12-09 22:58:37 +00:00
<template>
<div class="container" style="">
<div class="row">
<div :class="[modes.distractionFree ? 'col-md-8 col-lg-8 offset-md-2 px-0 my-sm-3 timeline order-2 order-md-1':'col-md-8 col-lg-8 px-0 my-sm-3 timeline order-2 order-md-1']">
2019-04-30 04:04:42 +00:00
<div style="padding-top:10px;">
<div v-if="loading" class="text-center">
<div class="spinner-border" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
2019-05-05 02:53:36 +00:00
<div :data-status-id="status.id" v-for="(status, index) in feed" :key="`${index}-${status.id}`">
2019-07-21 05:30:51 +00:00
<div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
2019-05-05 02:53:36 +00:00
<div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
<h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
<span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
</div>
2019-05-05 18:33:10 +00:00
<div class="card-body row mx-0">
2019-05-05 02:53:36 +00:00
<div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
<div class="card">
<div class="card-body text-center pt-3">
<p class="mb-0">
<a :href="'/'+rec.username">
<img :src="rec.avatar" class="img-fluid rounded-circle cursor-pointer" width="45px" height="45px">
</a>
</p>
<div class="py-3">
<p class="font-weight-bold text-dark cursor-pointer mb-0">
<a :href="'/'+rec.username" class="text-decoration-none text-dark">
{{rec.username}}
</a>
</p>
<p class="small text-muted mb-0">{{rec.message}}</p>
</div>
<p class="mb-0">
<a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
</p>
</div>
</div>
2019-04-30 04:04:42 +00:00
</div>
2018-12-09 22:58:37 +00:00
</div>
</div>
2019-07-09 04:03:56 +00:00
2019-07-21 05:30:51 +00:00
<div v-if="index == 4 && showHashtagPosts && hashtagPosts.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
2019-07-09 04:03:56 +00:00
<div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
<span></span>
<h6 class="text-muted font-weight-bold mb-0"><a :href="'/discover/tags/'+hashtagPostsName+'?src=tr'">#{{hashtagPostsName}}</a></h6>
<span class="cursor-pointer text-muted" v-on:click="showHashtagPosts = false"><i class="fas fa-times"></i></span>
</div>
<div class="card-body row mx-0">
<div v-for="(tag, index) in hashtagPosts" class="col-4 p-0 p-sm-2 p-md-3 hashtag-post-square">
<a class="card info-overlay card-md-border-0" :href="tag.status.url">
<div :class="[tag.status.filter ? 'square ' + tag.status.filter : 'square']">
<div class="square-content" :style="'background-image: url('+tag.status.thumb+')'"></div>
<div class="info-overlay-text">
<h5 class="text-white m-auto font-weight-bold">
<span class="pr-4">
<span class="far fa-heart fa-lg pr-1"></span> {{tag.status.like_count}}
</span>
<span>
<span class="fas fa-retweet fa-lg pr-1"></span> {{tag.status.share_count}}
</span>
</h5>
</div>
</div>
</a>
</div>
</div>
</div>
2019-09-04 01:37:33 +00:00
2019-07-21 05:30:51 +00:00
<div class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
2019-05-09 03:19:08 +00:00
<div v-if="!modes.distractionFree" class="card-header d-inline-flex align-items-center bg-white">
2019-05-05 02:53:36 +00:00
<img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
2019-09-04 01:37:33 +00:00
<div class="pl-2">
<!-- <a class="d-block username font-weight-bold text-dark" v-bind:href="status.account.url" style="line-height:0.5;"> -->
<a class="username font-weight-bold text-dark text-decoration-none" v-bind:href="status.account.url">
{{status.account.username}}
</a>
2019-09-06 03:50:58 +00:00
<span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
2019-09-09 04:06:23 +00:00
<i class="fas fa-certificate text-danger fa-stack-1x"></i>
<i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
2019-09-06 03:32:40 +00:00
</span>
2019-09-04 01:37:33 +00:00
<span v-if="scope != 'home' && status.account.id != profile.id && status.account.relationship">
<span class="px-1"></span>
<span :class="'font-weight-bold cursor-pointer ' + [status.account.relationship.following == true ? 'text-muted' : 'text-primary']" @click="followAction(status)">{{status.account.relationship.following == true ? 'Following' : 'Follow'}}</span>
</span>
<a v-if="status.place" class="d-block small text-decoration-none" :href="'/discover/places/'+status.place.id+'/'+status.place.slug" style="color:#718096">{{status.place.name}}, {{status.place.country}}</a>
</div>
2019-05-05 02:53:36 +00:00
<div class="text-right" style="flex-grow:1;">
2019-08-05 05:07:41 +00:00
<button class="btn btn-link text-dark py-0" type="button" @click="ctxMenu(status)">
2019-09-04 01:37:33 +00:00
<span class="fas fa-ellipsis-h text-lighter"></span>
2019-05-05 02:53:36 +00:00
</button>
2019-08-05 05:07:41 +00:00
<!-- <div class="dropdown-menu dropdown-menu-right">
2019-05-05 02:53:36 +00:00
<a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
<!-- <a class="dropdown-item font-weight-bold" href="#">Share</a>
2019-08-05 05:07:41 +00:00
<a class="dropdown-item font-weight-bold" href="#">Embed</a> ->
2019-05-05 02:53:36 +00:00
<span v-if="statusOwner(status) == false">
<a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
<a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
<a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
</span>
<span v-if="statusOwner(status) == true">
<a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
</span>
<span v-if="profile.is_admin == true && modes.mod == true">
<div class="dropdown-divider"></div>
<a v-if="!statusOwner(status)" class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">Mod Tools</h6>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')">
<p class="mb-0" data-toggle="tooltip" data-placement="bottom" title="Adds a CW to every post made by this account.">Enforce CW</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')">
<p class="mb-0" title="Do not transform mentions, hashtags or urls into HTML.">No Autolinking</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')">
<p class="mb-0" title="Removes account from public/network timelines.">Unlisted Posts</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'disable')">
<p class="mb-0" title="Temporarily disable account until next time user log in.">Disable Account</p>
</a>
<a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')">
<p class="mb-0" title="This prevents any new interactions, without deleting existing data.">Suspend Account</p>
</a>
2018-12-09 22:58:37 +00:00
2019-05-05 02:53:36 +00:00
</span>
2019-08-05 05:07:41 +00:00
</div> -->
2019-05-05 02:53:36 +00:00
</div>
2019-04-30 04:04:42 +00:00
</div>
2019-10-16 05:58:55 +00:00
<div class="postPresenterContainer" style="background: #000;">
2019-05-05 02:53:36 +00:00
<div v-if="status.pf_type === 'photo'" class="w-100">
<photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
</div>
2018-12-09 22:58:37 +00:00
2019-05-05 02:53:36 +00:00
<div v-else-if="status.pf_type === 'video'" class="w-100">
<video-presenter :status="status"></video-presenter>
</div>
2018-12-09 22:58:37 +00:00
2019-05-05 02:53:36 +00:00
<div v-else-if="status.pf_type === 'photo:album'" class="w-100">
<photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
</div>
2019-05-05 02:53:36 +00:00
<div v-else-if="status.pf_type === 'video:album'" class="w-100">
<video-album-presenter :status="status"></video-album-presenter>
</div>
2019-05-05 02:53:36 +00:00
<div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
<mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
</div>
2018-12-09 22:58:37 +00:00
2019-05-05 02:53:36 +00:00
<div v-else class="w-100">
<p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
</div>
2019-04-30 04:04:42 +00:00
</div>
2018-12-09 22:58:37 +00:00
2019-05-05 02:53:36 +00:00
<div class="card-body">
2019-09-04 01:37:33 +00:00
<div v-if="!modes.distractionFree" class="reactions my-1 pb-2">
<h3 v-bind:class="[status.favourited ? 'fas fa-heart text-danger pr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn text-lighter cursor-pointer']" title="Like" v-on:click="likeStatus(status, $event)"></h3>
<h3 v-if="!status.comments_disabled" class="far fa-comment text-lighter pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
<h3 v-if="status.visibility == 'public'" v-bind:class="[status.reblogged ? 'fas fa-retweet pr-3 m-0 text-primary cursor-pointer' : 'fas fa-retweet pr-3 m-0 text-lighter share-btn cursor-pointer']" title="Share" v-on:click="shareStatus(status, $event)"></h3>
<span class="float-right">
<h3 class="fas fa-expand pr-3 m-0 cursor-pointer text-lighter" v-on:click="lightbox(status)"></h3>
</span>
2019-05-05 02:53:36 +00:00
</div>
2019-05-09 03:19:08 +00:00
<div class="likes font-weight-bold" v-if="expLc(status) == true && !modes.distractionFree">
2019-05-05 02:53:36 +00:00
<span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
</div>
<div class="caption">
<p class="mb-2 read-more" style="overflow: hidden;">
<span class="username font-weight-bold">
<bdi><a class="text-dark" :href="status.account.url">{{status.account.username}}</a></bdi>
</span>
<span v-html="status.content"></span>
</p>
</div>
<div class="comments" v-if="status.id == replyId && !status.comments_disabled">
<p class="mb-0 d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;" v-for="(reply, index) in replies">
<span>
<a class="text-dark font-weight-bold mr-1" :href="reply.account.url">{{reply.account.username}}</a>
<span v-html="reply.content"></span>
</span>
<span class="mb-0" style="min-width:38px">
2019-09-04 01:37:33 +00:00
<span v-on:click="likeStatus(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger cursor-pointer':'far fa-heart fa-sm text-lighter cursor-pointer']"></i></span>
<!-- <post-menu :status="reply" :profile="profile" size="sm" :modal="'true'" :feed="feed" class="d-inline-flex pl-2"></post-menu> -->
<span class="text-lighter pl-2 cursor-pointer" @click="ctxMenu(reply)">
<span class="fas fa-ellipsis-v text-lighter"></span>
</span>
</span>
2019-05-05 02:53:36 +00:00
</p>
</div>
<div class="timestamp mt-2">
<p class="small text-uppercase mb-0">
<a :href="status.url" class="text-muted">
<timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
</a>
2019-05-09 03:19:08 +00:00
<a v-if="modes.distractionFree" class="float-right" :href="status.url">
<i class="fas fa-ellipsis-h fa-lg text-muted"></i>
</a>
2019-05-05 02:53:36 +00:00
</p>
</div>
2019-04-30 04:04:42 +00:00
</div>
2018-12-09 22:58:37 +00:00
2019-05-05 04:44:19 +00:00
<div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white px-2 py-0">
<ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
2019-05-21 04:26:11 +00:00
<li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
2019-05-05 04:44:19 +00:00
</ul>
2019-04-30 04:04:42 +00:00
</div>
2018-12-09 22:58:37 +00:00
2019-05-05 04:44:19 +00:00
<div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white sticky-md-bottom p-0">
<form class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="status.id" data-truncate="false">
<textarea class="form-control border-0 rounded-0" name="comment" placeholder="Add a comment…" autocomplete="off" autocorrect="off" style="height:56px;line-height: 18px;max-height:80px;resize: none; padding-right:4.2rem;" v-model="replyText"></textarea>
<input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" v-on:click.prevent="commentSubmit(status, $event)"/>
2019-05-05 02:53:36 +00:00
</form>
</div>
2019-04-30 04:04:42 +00:00
</div>
2018-12-09 22:58:37 +00:00
</div>
2019-09-04 01:37:33 +00:00
<div v-if="!loading && feed.length">
2019-10-16 05:40:08 +00:00
<div class="card shadow-none border">
2019-04-30 04:04:42 +00:00
<div class="card-body">
2019-05-01 04:38:14 +00:00
<infinite-loading @infinite="infiniteTimeline" :distance="800">
2019-04-30 04:04:42 +00:00
<div slot="no-more" class="font-weight-bold">No more posts to load</div>
<div slot="no-results" class="font-weight-bold">No more posts to load</div>
2019-04-30 04:04:42 +00:00
</infinite-loading>
</div>
</div>
</div>
2019-04-30 04:04:42 +00:00
<div v-if="!loading && scope == 'home' && feed.length == 0">
<div class="card">
<div class="card-body text-center">
<p class="h2 font-weight-lighter p-5">Hello, {{profile.acct}}</p>
<p class="text-lighter"><i class="fas fa-camera-retro fa-5x"></i></p>
<p class="h3 font-weight-lighter p-5">Start following people to build your timeline.</p>
<p><a href="/discover" class="btn btn-primary font-weight-bold py-0">Discover new people and posts</a></p>
</div>
</div>
</div>
</div>
2018-12-09 22:58:37 +00:00
</div>
<div v-if="!modes.distractionFree" class="col-md-4 col-lg-4 my-3 order-1 order-md-2 d-none d-md-block">
2019-04-30 04:04:42 +00:00
<div class="position-sticky" style="top:68px;">
<div class="mb-4">
2019-04-30 03:33:55 +00:00
<div class="">
2019-04-30 04:04:42 +00:00
<div class="">
<div class="media d-flex align-items-center">
<a :href="profile.url">
<img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
</a>
<div class="media-body d-flex justify-content-between word-break" >
<div>
<p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
<p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
</div>
<div class="ml-2">
2019-06-10 04:00:48 +00:00
<a class="text-muted" href="/settings/home"><i class="fas fa-cog fa-lg"></i></a>
2019-04-30 04:04:42 +00:00
</div>
2019-02-11 00:56:52 +00:00
</div>
</div>
</div>
2019-09-04 01:37:33 +00:00
<div class="card-footer bg-transparent border-0 mt-2 py-1">
2019-04-30 04:04:42 +00:00
<div class="d-flex justify-content-between text-center">
2019-09-04 01:37:33 +00:00
<span class="cursor-pointer" @click="redirect(profile.url)">
<p class="mb-0 font-weight-bold">{{formatCount(profile.statuses_count)}}</p>
2019-04-30 04:04:42 +00:00
<p class="mb-0 small text-muted">Posts</p>
</span>
2019-09-04 01:37:33 +00:00
<span class="cursor-pointer" @click="redirect(profile.url+'?md=followers')">
<p class="mb-0 font-weight-bold">{{formatCount(profile.followers_count)}}</p>
2019-04-30 04:04:42 +00:00
<p class="mb-0 small text-muted">Followers</p>
</span>
2019-09-04 01:37:33 +00:00
<span class="cursor-pointer" @click="redirect(profile.url+'?md=following')">
<p class="mb-0 font-weight-bold">{{formatCount(profile.following_count)}}</p>
2019-04-30 04:04:42 +00:00
<p class="mb-0 small text-muted">Following</p>
</span>
</div>
2019-09-04 01:37:33 +00:00
</div>
</div>
</div>
<div v-if="showTips" class="mb-4 card-tips">
<div class="card border shadow-none mb-3" style="max-width: 18rem;">
<div class="card-body">
<div class="card-title">
<span class="font-weight-bold">Tip: Hide follower counts</span>
<span class="float-right cursor-pointer" @click.prevent="hideTips()"><i class="fas fa-times text-lighter"></i></span>
</div>
<p class="card-text">
<span style="font-size:13px;">You can hide followers or following count and lists on your profile.</span>
<br><a href="/settings/privacy/" class="small font-weight-bold">Privacy Settings</a></p>
</div>
</div>
2018-12-09 22:58:37 +00:00
</div>
2019-10-01 04:38:52 +00:00
<div v-show="modes.notify == true && !loading" class="mb-4">
2019-04-30 04:04:42 +00:00
<notification-card></notification-card>
</div>
2019-05-04 02:01:31 +00:00
<div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
2019-04-30 04:04:42 +00:00
<div class="card">
2019-05-04 02:01:31 +00:00
<div class="card-header bg-white d-flex align-items-center justify-content-between">
2019-05-14 03:15:00 +00:00
<a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
2019-05-02 04:18:42 +00:00
<div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
2019-05-04 02:01:31 +00:00
<div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
2019-04-30 04:04:42 +00:00
</div>
<div class="card-body pt-0">
<div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
<a :href="'/'+rec.username">
<img :src="rec.avatar" width="32px" height="32px" class="rounded-circle mr-3">
</a>
<div class="media-body">
<p class="mb-0 font-weight-bold small">
<a :href="'/'+rec.username" class="text-decoration-none text-dark">
{{rec.username}}
</a>
</p>
<p class="mb-0 small text-muted">{{rec.message}}</p>
</div>
<a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
2019-04-28 23:01:10 +00:00
</div>
</div>
</div>
</div>
2019-04-30 04:04:42 +00:00
<footer>
<div class="container pb-5">
<p class="mb-0 text-uppercase font-weight-bold text-muted small">
<a href="/site/about" class="text-dark pr-2">About Us</a>
<a href="/site/help" class="text-dark pr-2">Help</a>
<a href="/site/open-source" class="text-dark pr-2">Open Source</a>
<a href="/site/language" class="text-dark pr-2">Language</a>
<a href="/site/terms" class="text-dark pr-2">Terms</a>
<a href="/site/privacy" class="text-dark pr-2">Privacy</a>
<a href="/discover/places" class="text-dark pr-2">Places</a>
2019-04-30 04:04:42 +00:00
</p>
<p class="mb-0 text-uppercase font-weight-bold text-muted small">
<a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by Pixelfed</a>
2019-04-30 04:04:42 +00:00
</p>
</div>
</footer>
</div>
2018-12-09 22:58:37 +00:00
</div>
</div>
2019-08-05 05:07:41 +00:00
<b-modal ref="ctxModal"
id="ctx-modal"
hide-header
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded">
<div class="list-group text-center">
<div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuReportPost()">Report inappropriate</div>
2019-08-07 02:40:44 +00:00
<div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id && ctxMenuRelationship && ctxMenuRelationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-danger" @click="ctxMenuUnfollow()">Unfollow</div>
<div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id && ctxMenuRelationship && !ctxMenuRelationship.following" class="list-group-item rounded cursor-pointer font-weight-bold text-primary" @click="ctxMenuFollow()">Follow</div>
2019-08-05 05:07:41 +00:00
<div class="list-group-item rounded cursor-pointer" @click="ctxMenuGoToPost()">Go to post</div>
<!-- <div class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
<div class="list-group-item rounded cursor-pointer" @click="ctxMenuShare()">Share</div> -->
<div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
2019-09-04 01:37:33 +00:00
<div v-if="profile && profile.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenuShow()">Moderation Tools</div>
<div v-if="ctxMenuStatus && (profile.is_admin || profile.id == ctxMenuStatus.account.id)" class="list-group-item rounded cursor-pointer" @click="deletePost(ctxMenuStatus)">Delete</div>
2019-08-05 05:07:41 +00:00
<div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
</div>
</b-modal>
2019-09-04 01:37:33 +00:00
<b-modal ref="ctxModModal"
id="ctx-mod-modal"
hide-header
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded">
<div class="list-group text-center">
<div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div>
<div class="list-group-item rounded cursor-pointer" @click="">Add Content Warning</div>
<div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
</div>
</b-modal>
2019-08-05 05:07:41 +00:00
<b-modal ref="ctxShareModal"
id="ctx-share-modal"
title="Share"
hide-footer
centered
rounded
size="sm"
body-class="list-group-flush p-0 rounded text-center">
<div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
<div class="list-group-item rounded cursor-pointer">Facebook</div>
<div class="list-group-item rounded cursor-pointer">Mastodon</div>
<div class="list-group-item rounded cursor-pointer">Pinterest</div>
<div class="list-group-item rounded cursor-pointer">Pixelfed</div>
<div class="list-group-item rounded cursor-pointer">Twitter</div>
<div class="list-group-item rounded cursor-pointer">VK</div>
<div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
</b-modal>
<b-modal ref="ctxEmbedModal"
id="ctx-embed-modal"
hide-header
hide-footer
centered
rounded
size="md"
body-class="p-2 rounded">
<div>
<textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 17px; min-height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
<hr>
<button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
<p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="#">API Terms of Use</a>.</p>
</div>
</b-modal>
2019-05-03 19:11:29 +00:00
<b-modal
id="lightbox"
2019-03-10 05:26:29 +00:00
ref="lightboxModal"
2019-03-26 00:53:20 +00:00
hide-header
hide-footer
2019-03-10 05:26:29 +00:00
centered
size="lg"
body-class="p-0"
>
2019-09-04 01:37:33 +00:00
<div v-if="lightboxMedia" :class="lightboxMedia.filter_class" class="w-100 h-100">
<img :src="lightboxMedia.url" style="max-height: 100%; max-width: 100%">
2019-03-10 05:26:29 +00:00
</div>
</b-modal>
2018-12-09 22:58:37 +00:00
</div>
</template>
2018-12-31 04:31:57 +00:00
<style type="text/css" scoped>
.postPresenterContainer {
display: flex;
align-items: center;
background: #fff;
}
.word-break {
word-break: break-all;
}
2019-02-11 00:56:52 +00:00
.small .custom-control-label {
padding-top: 3px;
}
2019-05-05 04:44:19 +00:00
.reply-btn {
position: absolute;
bottom: 12px;
right: 20px;
width: 60px;
text-align: center;
border-radius: 0 3px 3px 0;
}
.emoji-reactions .nav-item {
font-size: 1.2rem;
padding: 9px;
cursor: pointer;
}
.emoji-reactions::-webkit-scrollbar {
width: 0px;
height: 0px;
background: transparent;
}
2018-12-09 22:58:37 +00:00
</style>
<script type="text/javascript">
export default {
2019-03-10 05:26:29 +00:00
props: ['scope'],
2018-12-09 22:58:37 +00:00
data() {
return {
2019-05-07 06:00:13 +00:00
ids: [],
2019-08-05 05:07:41 +00:00
config: window.App.config,
2019-01-06 05:02:42 +00:00
page: 2,
2018-12-09 22:58:37 +00:00
feed: [],
profile: {},
min_id: 0,
max_id: 0,
stories: {},
suggestions: {},
2019-01-06 05:02:42 +00:00
loading: true,
2019-02-11 00:56:52 +00:00
replies: [],
replyId: null,
modes: {
'mod': false,
'dark': false,
'notify': true,
2019-05-09 03:19:08 +00:00
'distractionFree': false
2019-02-28 03:59:16 +00:00
},
followers: [],
followerCursor: 1,
followerMore: true,
following: [],
followingCursor: 1,
2019-03-10 05:26:29 +00:00
followingMore: true,
2019-05-04 02:01:31 +00:00
lightboxMedia: false,
showSuggestions: false,
showReadMore: true,
2019-05-05 04:44:19 +00:00
replyStatus: {},
2019-05-21 04:26:11 +00:00
replyText: '',
emoji: window.App.util.emoji,
2019-07-09 04:03:56 +00:00
showHashtagPosts: false,
hashtagPosts: [],
hashtagPostsName: '',
2019-08-05 05:07:41 +00:00
ctxMenuStatus: false,
ctxMenuRelationship: false,
ctxEmbedPayload: false,
2019-09-04 01:37:33 +00:00
copiedEmbed: false,
showTips: true,
2018-12-09 22:58:37 +00:00
}
},
beforeMount() {
2019-08-05 05:07:41 +00:00
this.fetchProfile();
this.fetchTimelineApi();
2018-12-09 22:58:37 +00:00
},
mounted() {
if($('link[data-stylesheet="dark"]').length != 0) {
this.modes.dark = true;
}
2019-05-04 02:01:31 +00:00
if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
this.showSuggestions = false;
} else {
this.showSuggestions = true;
}
if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
this.showReadMore = false;
} else {
this.showReadMore = true;
}
2019-05-09 03:19:08 +00:00
if(localStorage.getItem('pf_metro_ui.exp.df') == 'true') {
this.modes.distractionFree = true;
} else {
this.modes.distractionFree = false;
}
2019-09-04 01:37:33 +00:00
if(localStorage.getItem('metro-tips') == 'false') {
this.showTips = false;
}
2019-02-11 00:56:52 +00:00
this.$nextTick(function () {
$('[data-toggle="tooltip"]').tooltip()
});
2018-12-09 22:58:37 +00:00
},
updated() {
if(this.showReadMore == true) {
pixelfed.readmore();
}
2018-12-09 22:58:37 +00:00
},
methods: {
fetchProfile() {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
2018-12-09 22:58:37 +00:00
this.profile = res.data;
2019-05-03 03:11:28 +00:00
if(this.profile.is_admin == true) {
this.modes.mod = true;
}
//this.expRec();
2018-12-09 22:58:37 +00:00
}).catch(err => {
swal(
'Oops, something went wrong',
'Please reload the page.',
'error'
);
});
},
fetchTimelineApi() {
2019-03-10 05:26:29 +00:00
let apiUrl = false;
switch(this.scope) {
case 'home':
apiUrl = '/api/pixelfed/v1/timelines/home';
2019-03-10 05:26:29 +00:00
break;
case 'local':
apiUrl = '/api/pixelfed/v1/timelines/public';
2019-03-10 05:26:29 +00:00
break;
case 'network':
apiUrl = '/api/pixelfed/v1/timelines/network';
2019-03-10 05:26:29 +00:00
break;
}
2019-03-04 02:32:31 +00:00
axios.get(apiUrl, {
params: {
2019-03-10 05:26:29 +00:00
max_id: this.max_id,
limit: 5
2019-03-04 02:32:31 +00:00
}
}).then(res => {
2018-12-09 22:58:37 +00:00
let data = res.data;
this.feed.push(...data);
let ids = data.map(status => status.id);
2019-05-07 06:00:13 +00:00
this.ids = ids;
this.min_id = Math.max(...ids).toString();
this.max_id = Math.min(...ids).toString();
2019-01-06 05:02:42 +00:00
this.loading = false;
2019-09-24 04:35:31 +00:00
$('.timeline .pagination').removeClass('d-none');
2019-10-01 04:38:52 +00:00
// if(this.feed.length == 4) {
// this.fetchTimelineApi();
// }
2019-09-24 04:35:31 +00:00
if(this.hashtagPosts.length == 0) {
2019-09-04 01:37:33 +00:00
this.fetchHashtagPosts();
}
2018-12-09 22:58:37 +00:00
}).catch(err => {
2019-09-24 04:35:31 +00:00
swal(
'Oops, something went wrong',
'Please reload the page.',
'error'
);
2018-12-09 22:58:37 +00:00
});
},
infiniteTimeline($state) {
2019-04-22 03:04:46 +00:00
if(this.loading) {
2019-09-04 01:37:33 +00:00
$state.complete();
2019-04-22 03:04:46 +00:00
return;
}
if(this.page > 40) {
this.loading = false;
$state.complete();
}
2019-03-10 05:26:29 +00:00
let apiUrl = false;
switch(this.scope) {
case 'home':
apiUrl = '/api/pixelfed/v1/timelines/home';
2019-03-10 05:26:29 +00:00
break;
case 'local':
apiUrl = '/api/pixelfed/v1/timelines/public';
2019-03-10 05:26:29 +00:00
break;
case 'network':
apiUrl = '/api/pixelfed/v1/timelines/network';
2019-03-10 05:26:29 +00:00
break;
}
axios.get(apiUrl, {
params: {
2019-03-04 02:32:31 +00:00
max_id: this.max_id,
2019-09-24 04:35:31 +00:00
limit: 6
},
}).then(res => {
2019-01-06 05:02:42 +00:00
if (res.data.length && this.loading == false) {
let data = res.data;
2019-05-07 06:00:13 +00:00
let self = this;
2019-08-05 05:07:41 +00:00
data.forEach((d, index) => {
2019-05-07 06:00:13 +00:00
if(self.ids.indexOf(d.id) == -1) {
self.feed.push(d);
self.ids.push(d.id);
}
});
this.min_id = Math.max(...this.ids).toString();
this.max_id = Math.min(...this.ids).toString();
this.page += 1;
$state.loaded();
2019-01-06 05:02:42 +00:00
this.loading = false;
} else {
$state.complete();
}
}).catch(err => {
this.loading = false;
$state.complete();
});
},
2018-12-09 22:58:37 +00:00
reportUrl(status) {
let type = status.in_reply_to ? 'comment' : 'post';
let id = status.id;
return '/i/report?type=' + type + '&id=' + id;
},
commentFocus(status, $event) {
2019-04-03 06:04:15 +00:00
if(this.replyId == status.id || status.comments_disabled) {
2019-02-11 00:56:52 +00:00
return;
2018-12-09 22:58:37 +00:00
}
2019-02-11 00:56:52 +00:00
this.replies = {};
2019-05-05 04:44:19 +00:00
this.replyStatus = {};
this.replyText = '';
2019-02-11 00:56:52 +00:00
this.replyId = status.id;
2019-05-05 04:44:19 +00:00
this.replyStatus = status;
2019-02-11 00:56:52 +00:00
this.fetchStatusComments(status, '');
2018-12-09 22:58:37 +00:00
},
likeStatus(status) {
2018-12-09 22:58:37 +00:00
if($('body').hasClass('loggedIn') == false) {
return;
}
2019-08-05 05:07:41 +00:00
let count = status.favourites_count;
status.favourited = !status.favourited;
2018-12-09 22:58:37 +00:00
axios.post('/i/like', {
item: status.id
}).then(res => {
status.favourites_count = res.data.count;
}).catch(err => {
2019-08-05 05:07:41 +00:00
status.favourited = !status.favourited;
status.favourites_count = count;
2018-12-09 22:58:37 +00:00
swal('Error', 'Something went wrong, please try again later.', 'error');
});
},
shareStatus(status, $event) {
if($('body').hasClass('loggedIn') == false) {
return;
}
axios.post('/i/share', {
item: status.id
}).then(res => {
status.reblogs_count = res.data.count;
2019-02-11 00:56:52 +00:00
status.reblogged = !status.reblogged;
2018-12-09 22:58:37 +00:00
}).catch(err => {
swal('Error', 'Something went wrong, please try again later.', 'error');
});
},
timestampFormat(timestamp) {
let ts = new Date(timestamp);
return ts.toDateString() + ' ' + ts.toLocaleTimeString();
},
2018-12-16 08:59:30 +00:00
redirect(url) {
window.location.href = url;
return;
},
2018-12-09 22:58:37 +00:00
statusOwner(status) {
let sid = status.account.id;
let uid = this.profile.id;
if(sid == uid) {
return true;
} else {
return false;
}
},
fetchStatusComments(status, card) {
axios.get('/api/v2/status/'+status.id+'/replies')
.then(res => {
let data = res.data.filter(res => {
return res.sensitive == false;
});
2019-02-11 00:56:52 +00:00
this.replies = _.reverse(data);
2018-12-09 22:58:37 +00:00
}).catch(err => {
})
},
muteProfile(status) {
if($('body').hasClass('loggedIn') == false) {
return;
}
axios.post('/i/mute', {
type: 'user',
item: status.account.id
}).then(res => {
this.feed = this.feed.filter(s => s.account.id !== status.account.id);
2018-12-09 22:58:37 +00:00
swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
}).catch(err => {
swal('Error', 'Something went wrong. Please try again later.', 'error');
});
},
blockProfile(status) {
if($('body').hasClass('loggedIn') == false) {
return;
}
axios.post('/i/block', {
type: 'user',
item: status.account.id
}).then(res => {
this.feed = this.feed.filter(s => s.account.id !== status.account.id);
swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
2018-12-09 22:58:37 +00:00
}).catch(err => {
swal('Error', 'Something went wrong. Please try again later.', 'error');
});
},
2019-09-04 01:37:33 +00:00
deletePost(status) {
2019-05-03 03:11:28 +00:00
if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
2018-12-09 22:58:37 +00:00
return;
}
2019-03-26 01:07:25 +00:00
if(window.confirm('Are you sure you want to delete this post?') == false) {
return;
}
2019-05-03 19:11:29 +00:00
2018-12-09 22:58:37 +00:00
axios.post('/i/delete', {
type: 'status',
item: status.id
}).then(res => {
2019-06-27 06:50:32 +00:00
this.feed = this.feed.filter(s => {
return s.id != status.id;
2019-09-04 01:37:33 +00:00
});
this.$refs.ctxModal.hide();
2018-12-09 22:58:37 +00:00
}).catch(err => {
swal('Error', 'Something went wrong. Please try again later.', 'error');
});
},
commentSubmit(status, $event) {
let id = status.id;
2019-05-05 04:44:19 +00:00
let comment = this.replyText;
2018-12-09 22:58:37 +00:00
axios.post('/i/comment', {
item: id,
comment: comment
}).then(res => {
2019-05-05 04:44:19 +00:00
this.replyText = '';
2019-02-11 00:56:52 +00:00
this.replies.push(res.data.entity);
2018-12-09 22:58:37 +00:00
});
2019-02-11 00:56:52 +00:00
},
2018-12-09 22:58:37 +00:00
2019-02-11 00:56:52 +00:00
moderatePost(status, action, $event) {
let username = status.account.username;
switch(action) {
case 'autocw':
let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
}).then(res => {
if(res) {
axios.post('/api/v2/moderator/action', {
action: action,
item_id: status.id,
item_type: 'status'
}).then(res => {
swal('Success', 'Successfully enforced CW for ' + username, 'success');
}).catch(err => {
swal(
'Error',
'Something went wrong, please try again later.',
'error'
);
});
}
});
break;
case 'noautolink':
msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
}).then(res => {
if(res) {
axios.post('/api/v2/moderator/action', {
action: action,
item_id: status.id,
item_type: 'status'
}).then(res => {
swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
}).catch(err => {
swal(
'Error',
'Something went wrong, please try again later.',
'error'
);
});
}
});
break;
2019-09-04 01:37:33 +00:00
2019-02-11 00:56:52 +00:00
case 'unlisted':
msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
}).then(res => {
if(res) {
axios.post('/api/v2/moderator/action', {
action: action,
item_id: status.id,
item_type: 'status'
}).then(res => {
swal('Success', 'Successfully unlisted for ' + username, 'success');
}).catch(err => {
swal(
'Error',
'Something went wrong, please try again later.',
'error'
);
});
}
});
break;
case 'disable':
msg = 'Are you sure you want to disable ' + username + 's account ?';
2019-02-11 00:56:52 +00:00
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
}).then(res => {
if(res) {
axios.post('/api/v2/moderator/action', {
action: action,
item_id: status.id,
item_type: 'status'
}).then(res => {
swal('Success', 'Successfully disabled ' + username + 's account', 'success');
2019-02-11 00:56:52 +00:00
}).catch(err => {
swal(
'Error',
'Something went wrong, please try again later.',
'error'
);
});
}
});
break;
case 'suspend':
msg = 'Are you sure you want to suspend ' + username + 's account ?';
2019-02-11 00:56:52 +00:00
swal({
title: 'Confirm',
text: msg,
icon: 'warning',
buttons: true,
dangerMode: true
}).then(res => {
if(res) {
axios.post('/api/v2/moderator/action', {
action: action,
item_id: status.id,
item_type: 'status'
}).then(res => {
swal('Success', 'Successfully suspend ' + username + 's account', 'success');
2019-02-11 00:56:52 +00:00
}).catch(err => {
swal(
'Error',
'Something went wrong, please try again later.',
'error'
);
});
}
});
break;
}
},
2019-02-28 03:59:16 +00:00
followingModal() {
if(this.following.length > 0) {
this.$refs.followingModal.show();
return;
}
axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
2019-02-28 03:59:16 +00:00
params: {
page: this.followingCursor
}
})
.then(res => {
this.following = res.data;
this.followingCursor++;
});
2019-03-10 05:26:29 +00:00
if(res.data.length < 10) {
2019-02-28 19:24:32 +00:00
this.followingMore = false;
}
2019-02-28 03:59:16 +00:00
this.$refs.followingModal.show();
},
followersModal() {
if(this.followers.length > 0) {
this.$refs.followerModal.show();
return;
}
axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
2019-02-28 03:59:16 +00:00
params: {
page: this.followerCursor
}
})
.then(res => {
this.followers = res.data;
this.followerCursor++;
2019-02-28 19:24:32 +00:00
})
2019-03-10 05:26:29 +00:00
if(res.data.length < 10) {
2019-02-28 19:24:32 +00:00
this.followerMore = false;
}
2019-02-28 03:59:16 +00:00
this.$refs.followerModal.show();
},
followingLoadMore() {
axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
2019-02-28 03:59:16 +00:00
params: {
page: this.followingCursor
}
})
.then(res => {
if(res.data.length > 0) {
this.following.push(...res.data);
this.followingCursor++;
2019-02-28 17:34:52 +00:00
}
2019-03-10 05:26:29 +00:00
if(res.data.length < 10) {
2019-02-28 03:59:16 +00:00
this.followingMore = false;
}
});
},
followersLoadMore() {
axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
2019-02-28 03:59:16 +00:00
params: {
page: this.followerCursor
}
})
.then(res => {
if(res.data.length > 0) {
this.followers.push(...res.data);
this.followerCursor++;
2019-02-28 17:34:52 +00:00
}
2019-03-10 05:26:29 +00:00
if(res.data.length < 10) {
2019-02-28 03:59:16 +00:00
this.followerMore = false;
}
});
2019-03-10 05:26:29 +00:00
},
2019-09-04 01:37:33 +00:00
lightbox(status) {
this.lightboxMedia = status.media_attachments[0];
2019-03-10 05:26:29 +00:00
this.$refs.lightboxModal.show();
2019-04-21 02:18:24 +00:00
},
expLc(status) {
if(this.config.ab.lc == false) {
return true;
}
if(this.statusOwner(status) == true) {
return true;
}
return false;
2019-04-28 23:01:10 +00:00
},
expRec() {
2019-09-24 04:35:31 +00:00
return;
2019-04-28 23:01:10 +00:00
if(this.config.ab.rec == false) {
return;
}
axios.get('/api/local/exp/rec')
.then(res => {
this.suggestions = res.data;
})
},
expRecFollow(id, index) {
2019-09-24 04:35:31 +00:00
return;
2019-04-28 23:01:10 +00:00
if(this.config.ab.rec == false) {
return;
}
axios.post('/i/follow', {
item: id
}).then(res => {
this.suggestions.splice(index, 1);
2019-06-02 02:18:21 +00:00
}).catch(err => {
if(err.response.data.message) {
swal('Error', err.response.data.message, 'error');
}
});
},
2019-09-04 01:37:33 +00:00
followAction(status) {
let id = status.account.id;
axios.post('/i/follow', {
item: id
}).then(res => {
2019-09-04 01:37:33 +00:00
this.feed.forEach(s => {
if(s.account.id == id) {
s.account.relationship.following = !s.account.relationship.following;
}
});
let username = status.account.acct;
if(status.account.relationship.following) {
swal('Follow successful!', 'You are now following ' + username, 'success');
} else {
swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
}
2019-09-04 01:37:33 +00:00
2019-06-02 02:18:21 +00:00
}).catch(err => {
if(err.response.data.message) {
swal('Error', err.response.data.message, 'error');
}
});
2019-05-03 03:11:28 +00:00
},
owner(status) {
return this.profile.id === status.account.id;
},
admin() {
return this.profile.is_admin == true;
},
ownerOrAdmin(status) {
return this.owner(status) || this.admin();
2019-05-04 02:01:31 +00:00
},
hideSuggestions() {
localStorage.setItem('pf_metro_ui.exp.rec', false);
this.showSuggestions = false;
2019-05-05 04:44:19 +00:00
},
emojiReaction(status) {
let em = event.target.innerText;
if(this.replyText.length == 0) {
this.replyText = em + ' ';
$('textarea[name="comment"]').focus();
} else {
this.replyText += em + ' ';
$('textarea[name="comment"]').focus();
}
},
2019-05-14 03:15:00 +00:00
refreshSuggestions() {
2019-09-24 04:35:31 +00:00
return;
2019-05-14 03:15:00 +00:00
let el = event.target.parentNode;
if(el.classList.contains('disabled') == true) {
return;
}
axios.get('/api/local/exp/rec', {
params: {
refresh: true
}
})
.then(res => {
this.suggestions = res.data;
if (el.classList) {
el.classList.add('disabled');
el.classList.add('text-light');
}
else {
el.className += ' ' + 'disabled text-light';
}
setTimeout(function() {
el.setAttribute('href', '#');
if (el.classList) {
el.classList.remove('disabled');
el.classList.remove('text-light');
}
else {
el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
}
}, 10000);
});
2019-07-09 04:03:56 +00:00
},
fetchHashtagPosts() {
axios.get('/api/local/discover/tag/list')
.then(res => {
let tags = res.data;
if(tags.length == 0) {
return;
}
let hashtag = tags[0];
this.hashtagPostsName = hashtag;
axios.get('/api/v2/discover/tag', {
params: {
hashtag: hashtag
}
}).then(res => {
if(res.data.tags.length) {
this.showHashtagPosts = true;
this.hashtagPosts = res.data.tags.splice(0,3);
}
})
})
2019-08-05 05:07:41 +00:00
},
ctxMenu(status) {
this.ctxMenuStatus = status;
2019-09-24 04:35:31 +00:00
// let payload = '<div class="pixlfed-media" data-id="'+ this.ctxMenuStatus.id + '"></div><script ';
// payload += 'src="https://pixelfed.dev/js/embed.js" async><';
// payload += '/script>';
// this.ctxEmbedPayload = payload;
2019-08-05 05:07:41 +00:00
if(status.account.id == this.profile.id) {
this.$refs.ctxModal.show();
} else {
axios.get('/api/pixelfed/v1/accounts/relationships', {
2019-08-05 05:07:41 +00:00
params: {
'id[]': status.account.id
}
}).then(res => {
this.ctxMenuRelationship = res.data[0];
this.$refs.ctxModal.show();
});
}
},
closeCtxMenu(truncate) {
this.copiedEmbed = false;
this.ctxMenuStatus = false;
this.ctxMenuRelationship = false;
this.$refs.ctxModal.hide();
},
ctxMenuCopyLink() {
let status = this.ctxMenuStatus;
navigator.clipboard.writeText(status.url);
this.closeCtxMenu();
return;
},
ctxMenuGoToPost() {
let status = this.ctxMenuStatus;
window.location.href = status.url;
this.closeCtxMenu();
return;
},
ctxMenuFollow() {
2019-09-04 01:37:33 +00:00
let id = this.ctxMenuStatus.account.id;
2019-08-05 05:07:41 +00:00
axios.post('/i/follow', {
2019-09-04 01:37:33 +00:00
item: id
2019-08-05 05:07:41 +00:00
}).then(res => {
2019-09-04 01:37:33 +00:00
this.feed.forEach(s => {
if(s.account.id == id) {
s.account.relationship.following = !s.account.relationship.following;
}
});
2019-08-05 05:07:41 +00:00
let username = this.ctxMenuStatus.account.acct;
this.closeCtxMenu();
setTimeout(function() {
swal('Follow successful!', 'You are now following ' + username, 'success');
}, 500);
});
},
ctxMenuUnfollow() {
2019-09-04 01:37:33 +00:00
let id = this.ctxMenuStatus.account.id;
2019-08-05 05:07:41 +00:00
axios.post('/i/follow', {
2019-09-04 01:37:33 +00:00
item: id
2019-08-05 05:07:41 +00:00
}).then(res => {
2019-09-04 01:37:33 +00:00
this.feed.forEach(s => {
if(s.account.id == id) {
s.account.relationship.following = !s.account.relationship.following;
}
});
2019-08-05 05:07:41 +00:00
let username = this.ctxMenuStatus.account.acct;
2019-09-04 01:37:33 +00:00
if(this.scope == 'home') {
this.feed = this.feed.filter(s => {
return s.account.id != this.ctxMenuStatus.account.id;
});
}
2019-08-05 05:07:41 +00:00
this.closeCtxMenu();
setTimeout(function() {
swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
}, 500);
});
},
ctxMenuReportPost() {
window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id;
},
ctxMenuEmbed() {
this.$refs.ctxModal.hide();
this.$refs.ctxEmbedModal.show();
},
ctxMenuShare() {
this.$refs.ctxModal.hide();
this.$refs.ctxShareModal.show();
},
closeCtxShareMenu() {
this.$refs.ctxShareModal.hide();
this.$refs.ctxModal.show();
},
ctxCopyEmbed() {
navigator.clipboard.writeText(this.ctxEmbedPayload);
this.$refs.ctxEmbedModal.hide();
2019-09-04 01:37:33 +00:00
},
ctxModMenuShow() {
this.$refs.ctxModal.hide();
this.$refs.ctxModModal.show();
},
ctxModMenu() {
this.$refs.ctxModal.hide();
},
ctxModMenuClose() {
this.$refs.ctxModal.hide();
this.$refs.ctxModModal.hide();
},
hideTips() {
this.showTips = false;
2019-09-24 04:35:31 +00:00
window.localStorage.setItem('metro-tips', false);
},
formatCount(count) {
return App.util.format.count(count);
2019-05-14 03:15:00 +00:00
}
2019-08-05 05:07:41 +00:00
2018-12-09 22:58:37 +00:00
}
}
2019-02-28 17:34:52 +00:00
</script>