1
0

Timeline.vue 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. <template>
  2. <div class="container" style="">
  3. <div class="row">
  4. <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']">
  5. <div style="padding-top:10px;">
  6. <div v-if="loading" class="text-center">
  7. <div class="spinner-border" role="status">
  8. <span class="sr-only">Loading...</span>
  9. </div>
  10. </div>
  11. <div :data-status-id="status.id" v-for="(status, index) in feed" :key="`${index}-${status.id}`">
  12. <div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  13. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  14. <h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
  15. <span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
  16. </div>
  17. <div class="card-body row mx-0">
  18. <div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
  19. <div class="card">
  20. <div class="card-body text-center pt-3">
  21. <p class="mb-0">
  22. <a :href="'/'+rec.username">
  23. <img :src="rec.avatar" class="img-fluid rounded-circle cursor-pointer" width="45px" height="45px">
  24. </a>
  25. </p>
  26. <div class="py-3">
  27. <p class="font-weight-bold text-dark cursor-pointer mb-0">
  28. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  29. {{rec.username}}
  30. </a>
  31. </p>
  32. <p class="small text-muted mb-0">{{rec.message}}</p>
  33. </div>
  34. <p class="mb-0">
  35. <a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  36. </p>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div v-if="index == 4 && showHashtagPosts && hashtagPosts.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  43. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  44. <span></span>
  45. <h6 class="text-muted font-weight-bold mb-0"><a :href="'/discover/tags/'+hashtagPostsName+'?src=tr'">#{{hashtagPostsName}}</a></h6>
  46. <span class="cursor-pointer text-muted" v-on:click="showHashtagPosts = false"><i class="fas fa-times"></i></span>
  47. </div>
  48. <div class="card-body row mx-0">
  49. <div v-for="(tag, index) in hashtagPosts" class="col-4 p-0 p-sm-2 p-md-3 hashtag-post-square">
  50. <a class="card info-overlay card-md-border-0" :href="tag.status.url">
  51. <div :class="[tag.status.filter ? 'square ' + tag.status.filter : 'square']">
  52. <div class="square-content" :style="'background-image: url('+tag.status.thumb+')'"></div>
  53. <div class="info-overlay-text">
  54. <h5 class="text-white m-auto font-weight-bold">
  55. <span class="pr-4">
  56. <span class="far fa-heart fa-lg pr-1"></span> {{tag.status.like_count}}
  57. </span>
  58. <span>
  59. <span class="fas fa-retweet fa-lg pr-1"></span> {{tag.status.share_count}}
  60. </span>
  61. </h5>
  62. </div>
  63. </div>
  64. </a>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  69. <div v-if="!modes.distractionFree" class="card-header d-inline-flex align-items-center bg-white">
  70. <img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
  71. <div class="pl-2">
  72. <!-- <a class="d-block username font-weight-bold text-dark" v-bind:href="status.account.url" style="line-height:0.5;"> -->
  73. <a class="username font-weight-bold text-dark text-decoration-none" v-bind:href="status.account.url">
  74. {{status.account.username}}
  75. </a>
  76. <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;">
  77. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  78. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  79. </span>
  80. <span v-if="scope != 'home' && status.account.id != profile.id && status.account.relationship">
  81. <span class="px-1">•</span>
  82. <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>
  83. </span>
  84. <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>
  85. </div>
  86. <div class="text-right" style="flex-grow:1;">
  87. <button class="btn btn-link text-dark py-0" type="button" @click="ctxMenu(status)">
  88. <span class="fas fa-ellipsis-h text-lighter"></span>
  89. </button>
  90. <!-- <div class="dropdown-menu dropdown-menu-right">
  91. <a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
  92. <!-- <a class="dropdown-item font-weight-bold" href="#">Share</a>
  93. <a class="dropdown-item font-weight-bold" href="#">Embed</a> ->
  94. <span v-if="statusOwner(status) == false">
  95. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  96. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
  97. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
  98. </span>
  99. <span v-if="statusOwner(status) == true">
  100. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  101. </span>
  102. <span v-if="profile.is_admin == true && modes.mod == true">
  103. <div class="dropdown-divider"></div>
  104. <a v-if="!statusOwner(status)" class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  105. <div class="dropdown-divider"></div>
  106. <h6 class="dropdown-header">Mod Tools</h6>
  107. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')">
  108. <p class="mb-0" data-toggle="tooltip" data-placement="bottom" title="Adds a CW to every post made by this account.">Enforce CW</p>
  109. </a>
  110. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')">
  111. <p class="mb-0" title="Do not transform mentions, hashtags or urls into HTML.">No Autolinking</p>
  112. </a>
  113. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')">
  114. <p class="mb-0" title="Removes account from public/network timelines.">Unlisted Posts</p>
  115. </a>
  116. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'disable')">
  117. <p class="mb-0" title="Temporarily disable account until next time user log in.">Disable Account</p>
  118. </a>
  119. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')">
  120. <p class="mb-0" title="This prevents any new interactions, without deleting existing data.">Suspend Account</p>
  121. </a>
  122. </span>
  123. </div> -->
  124. </div>
  125. </div>
  126. <div class="postPresenterContainer">
  127. <div v-if="status.pf_type === 'photo'" class="w-100">
  128. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  129. </div>
  130. <div v-else-if="status.pf_type === 'video'" class="w-100">
  131. <video-presenter :status="status"></video-presenter>
  132. </div>
  133. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  134. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  135. </div>
  136. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  137. <video-album-presenter :status="status"></video-album-presenter>
  138. </div>
  139. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  140. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  141. </div>
  142. <div v-else class="w-100">
  143. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  144. </div>
  145. </div>
  146. <div class="card-body">
  147. <div v-if="!modes.distractionFree" class="reactions my-1 pb-2">
  148. <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>
  149. <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>
  150. <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>
  151. <span class="float-right">
  152. <h3 class="fas fa-expand pr-3 m-0 cursor-pointer text-lighter" v-on:click="lightbox(status)"></h3>
  153. </span>
  154. </div>
  155. <div class="likes font-weight-bold" v-if="expLc(status) == true && !modes.distractionFree">
  156. <span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
  157. </div>
  158. <div class="caption">
  159. <p class="mb-2 read-more" style="overflow: hidden;">
  160. <span class="username font-weight-bold">
  161. <bdi><a class="text-dark" :href="status.account.url">{{status.account.username}}</a></bdi>
  162. </span>
  163. <span v-html="status.content"></span>
  164. </p>
  165. </div>
  166. <div class="comments" v-if="status.id == replyId && !status.comments_disabled">
  167. <p class="mb-0 d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;" v-for="(reply, index) in replies">
  168. <span>
  169. <a class="text-dark font-weight-bold mr-1" :href="reply.account.url">{{reply.account.username}}</a>
  170. <span v-html="reply.content"></span>
  171. </span>
  172. <span class="mb-0" style="min-width:38px">
  173. <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>
  174. <!-- <post-menu :status="reply" :profile="profile" size="sm" :modal="'true'" :feed="feed" class="d-inline-flex pl-2"></post-menu> -->
  175. <span class="text-lighter pl-2 cursor-pointer" @click="ctxMenu(reply)">
  176. <span class="fas fa-ellipsis-v text-lighter"></span>
  177. </span>
  178. </span>
  179. </p>
  180. </div>
  181. <div class="timestamp mt-2">
  182. <p class="small text-uppercase mb-0">
  183. <a :href="status.url" class="text-muted">
  184. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  185. </a>
  186. <a v-if="modes.distractionFree" class="float-right" :href="status.url">
  187. <i class="fas fa-ellipsis-h fa-lg text-muted"></i>
  188. </a>
  189. </p>
  190. </div>
  191. </div>
  192. <div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white px-2 py-0">
  193. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  194. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  195. </ul>
  196. </div>
  197. <div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white sticky-md-bottom p-0">
  198. <form class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="status.id" data-truncate="false">
  199. <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>
  200. <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)"/>
  201. </form>
  202. </div>
  203. </div>
  204. </div>
  205. <div v-if="!loading && feed.length">
  206. <div class="card">
  207. <div class="card-body">
  208. <infinite-loading @infinite="infiniteTimeline" :distance="800">
  209. <div slot="no-more" class="font-weight-bold">No more posts to load</div>
  210. <div slot="no-results" class="font-weight-bold">No more posts to load</div>
  211. </infinite-loading>
  212. </div>
  213. </div>
  214. </div>
  215. <div v-if="!loading && scope == 'home' && feed.length == 0">
  216. <div class="card">
  217. <div class="card-body text-center">
  218. <p class="h2 font-weight-lighter p-5">Hello, {{profile.acct}}</p>
  219. <p class="text-lighter"><i class="fas fa-camera-retro fa-5x"></i></p>
  220. <p class="h3 font-weight-lighter p-5">Start following people to build your timeline.</p>
  221. <p><a href="/discover" class="btn btn-primary font-weight-bold py-0">Discover new people and posts</a></p>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. <div v-if="!modes.distractionFree" class="col-md-4 col-lg-4 my-3 order-1 order-md-2 d-none d-md-block">
  228. <div class="position-sticky" style="top:68px;">
  229. <div class="mb-4">
  230. <div class="">
  231. <div class="">
  232. <div class="media d-flex align-items-center">
  233. <a :href="profile.url">
  234. <img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
  235. </a>
  236. <div class="media-body d-flex justify-content-between word-break" >
  237. <div>
  238. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
  239. <p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
  240. </div>
  241. <div class="ml-2">
  242. <a class="text-muted" href="/settings/home"><i class="fas fa-cog fa-lg"></i></a>
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. <div class="card-footer bg-transparent border-0 mt-2 py-1">
  248. <div class="d-flex justify-content-between text-center">
  249. <span class="cursor-pointer" @click="redirect(profile.url)">
  250. <p class="mb-0 font-weight-bold">{{formatCount(profile.statuses_count)}}</p>
  251. <p class="mb-0 small text-muted">Posts</p>
  252. </span>
  253. <span class="cursor-pointer" @click="redirect(profile.url+'?md=followers')">
  254. <p class="mb-0 font-weight-bold">{{formatCount(profile.followers_count)}}</p>
  255. <p class="mb-0 small text-muted">Followers</p>
  256. </span>
  257. <span class="cursor-pointer" @click="redirect(profile.url+'?md=following')">
  258. <p class="mb-0 font-weight-bold">{{formatCount(profile.following_count)}}</p>
  259. <p class="mb-0 small text-muted">Following</p>
  260. </span>
  261. </div>
  262. </div>
  263. </div>
  264. </div>
  265. <div v-if="showTips" class="mb-4 card-tips">
  266. <div class="card border shadow-none mb-3" style="max-width: 18rem;">
  267. <div class="card-body">
  268. <div class="card-title">
  269. <span class="font-weight-bold">Tip: Hide follower counts</span>
  270. <span class="float-right cursor-pointer" @click.prevent="hideTips()"><i class="fas fa-times text-lighter"></i></span>
  271. </div>
  272. <p class="card-text">
  273. <span style="font-size:13px;">You can hide followers or following count and lists on your profile.</span>
  274. <br><a href="/settings/privacy/" class="small font-weight-bold">Privacy Settings</a></p>
  275. </div>
  276. </div>
  277. </div>
  278. <div v-show="modes.notify == true && !loading" class="mb-4">
  279. <notification-card></notification-card>
  280. </div>
  281. <div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
  282. <div class="card">
  283. <div class="card-header bg-white d-flex align-items-center justify-content-between">
  284. <a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
  285. <div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
  286. <div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
  287. </div>
  288. <div class="card-body pt-0">
  289. <div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
  290. <a :href="'/'+rec.username">
  291. <img :src="rec.avatar" width="32px" height="32px" class="rounded-circle mr-3">
  292. </a>
  293. <div class="media-body">
  294. <p class="mb-0 font-weight-bold small">
  295. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  296. {{rec.username}}
  297. </a>
  298. </p>
  299. <p class="mb-0 small text-muted">{{rec.message}}</p>
  300. </div>
  301. <a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. <footer>
  307. <div class="container pb-5">
  308. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  309. <a href="/site/about" class="text-dark pr-2">About Us</a>
  310. <a href="/site/help" class="text-dark pr-2">Help</a>
  311. <a href="/site/open-source" class="text-dark pr-2">Open Source</a>
  312. <a href="/site/language" class="text-dark pr-2">Language</a>
  313. <a href="/site/terms" class="text-dark pr-2">Terms</a>
  314. <a href="/site/privacy" class="text-dark pr-2">Privacy</a>
  315. <a href="/discover/places" class="text-dark pr-2">Places</a>
  316. </p>
  317. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  318. <a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by Pixelfed</a>
  319. </p>
  320. </div>
  321. </footer>
  322. </div>
  323. </div>
  324. </div>
  325. <b-modal ref="ctxModal"
  326. id="ctx-modal"
  327. hide-header
  328. hide-footer
  329. centered
  330. rounded
  331. size="sm"
  332. body-class="list-group-flush p-0 rounded">
  333. <div class="list-group text-center">
  334. <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>
  335. <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>
  336. <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>
  337. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuGoToPost()">Go to post</div>
  338. <!-- <div class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
  339. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuShare()">Share</div> -->
  340. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
  341. <div v-if="profile && profile.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenuShow()">Moderation Tools</div>
  342. <div v-if="ctxMenuStatus && (profile.is_admin || profile.id == ctxMenuStatus.account.id)" class="list-group-item rounded cursor-pointer" @click="deletePost(ctxMenuStatus)">Delete</div>
  343. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
  344. </div>
  345. </b-modal>
  346. <b-modal ref="ctxModModal"
  347. id="ctx-mod-modal"
  348. hide-header
  349. hide-footer
  350. centered
  351. rounded
  352. size="sm"
  353. body-class="list-group-flush p-0 rounded">
  354. <div class="list-group text-center">
  355. <div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div>
  356. <div class="list-group-item rounded cursor-pointer" @click="">Add Content Warning</div>
  357. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
  358. </div>
  359. </b-modal>
  360. <b-modal ref="ctxShareModal"
  361. id="ctx-share-modal"
  362. title="Share"
  363. hide-footer
  364. centered
  365. rounded
  366. size="sm"
  367. body-class="list-group-flush p-0 rounded text-center">
  368. <div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
  369. <div class="list-group-item rounded cursor-pointer">Facebook</div>
  370. <div class="list-group-item rounded cursor-pointer">Mastodon</div>
  371. <div class="list-group-item rounded cursor-pointer">Pinterest</div>
  372. <div class="list-group-item rounded cursor-pointer">Pixelfed</div>
  373. <div class="list-group-item rounded cursor-pointer">Twitter</div>
  374. <div class="list-group-item rounded cursor-pointer">VK</div>
  375. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
  376. </b-modal>
  377. <b-modal ref="ctxEmbedModal"
  378. id="ctx-embed-modal"
  379. hide-header
  380. hide-footer
  381. centered
  382. rounded
  383. size="md"
  384. body-class="p-2 rounded">
  385. <div>
  386. <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>
  387. <hr>
  388. <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>
  389. <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>
  390. </div>
  391. </b-modal>
  392. <b-modal
  393. id="lightbox"
  394. ref="lightboxModal"
  395. hide-header
  396. hide-footer
  397. centered
  398. size="lg"
  399. body-class="p-0"
  400. >
  401. <div v-if="lightboxMedia" :class="lightboxMedia.filter_class" class="w-100 h-100">
  402. <img :src="lightboxMedia.url" style="max-height: 100%; max-width: 100%">
  403. </div>
  404. </b-modal>
  405. </div>
  406. </template>
  407. <style type="text/css" scoped>
  408. .postPresenterContainer {
  409. display: flex;
  410. align-items: center;
  411. background: #fff;
  412. }
  413. .word-break {
  414. word-break: break-all;
  415. }
  416. .small .custom-control-label {
  417. padding-top: 3px;
  418. }
  419. .reply-btn {
  420. position: absolute;
  421. bottom: 12px;
  422. right: 20px;
  423. width: 60px;
  424. text-align: center;
  425. border-radius: 0 3px 3px 0;
  426. }
  427. .emoji-reactions .nav-item {
  428. font-size: 1.2rem;
  429. padding: 9px;
  430. cursor: pointer;
  431. }
  432. .emoji-reactions::-webkit-scrollbar {
  433. width: 0px;
  434. height: 0px;
  435. background: transparent;
  436. }
  437. </style>
  438. <script type="text/javascript">
  439. export default {
  440. props: ['scope'],
  441. data() {
  442. return {
  443. ids: [],
  444. config: window.App.config,
  445. page: 2,
  446. feed: [],
  447. profile: {},
  448. min_id: 0,
  449. max_id: 0,
  450. stories: {},
  451. suggestions: {},
  452. loading: true,
  453. replies: [],
  454. replyId: null,
  455. modes: {
  456. 'mod': false,
  457. 'dark': false,
  458. 'notify': true,
  459. 'distractionFree': false
  460. },
  461. followers: [],
  462. followerCursor: 1,
  463. followerMore: true,
  464. following: [],
  465. followingCursor: 1,
  466. followingMore: true,
  467. lightboxMedia: false,
  468. showSuggestions: false,
  469. showReadMore: true,
  470. replyStatus: {},
  471. replyText: '',
  472. emoji: window.App.util.emoji,
  473. showHashtagPosts: false,
  474. hashtagPosts: [],
  475. hashtagPostsName: '',
  476. ctxMenuStatus: false,
  477. ctxMenuRelationship: false,
  478. ctxEmbedPayload: false,
  479. copiedEmbed: false,
  480. showTips: true,
  481. }
  482. },
  483. beforeMount() {
  484. this.fetchProfile();
  485. this.fetchTimelineApi();
  486. },
  487. mounted() {
  488. if($('link[data-stylesheet="dark"]').length != 0) {
  489. this.modes.dark = true;
  490. }
  491. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  492. this.showSuggestions = false;
  493. } else {
  494. this.showSuggestions = true;
  495. }
  496. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  497. this.showReadMore = false;
  498. } else {
  499. this.showReadMore = true;
  500. }
  501. if(localStorage.getItem('pf_metro_ui.exp.df') == 'true') {
  502. this.modes.distractionFree = true;
  503. } else {
  504. this.modes.distractionFree = false;
  505. }
  506. if(localStorage.getItem('metro-tips') == 'false') {
  507. this.showTips = false;
  508. }
  509. this.$nextTick(function () {
  510. $('[data-toggle="tooltip"]').tooltip()
  511. });
  512. },
  513. updated() {
  514. if(this.showReadMore == true) {
  515. pixelfed.readmore();
  516. }
  517. },
  518. methods: {
  519. fetchProfile() {
  520. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  521. this.profile = res.data;
  522. if(this.profile.is_admin == true) {
  523. this.modes.mod = true;
  524. }
  525. //this.expRec();
  526. }).catch(err => {
  527. swal(
  528. 'Oops, something went wrong',
  529. 'Please reload the page.',
  530. 'error'
  531. );
  532. });
  533. },
  534. fetchTimelineApi() {
  535. let apiUrl = false;
  536. switch(this.scope) {
  537. case 'home':
  538. apiUrl = '/api/pixelfed/v1/timelines/home';
  539. break;
  540. case 'local':
  541. apiUrl = '/api/pixelfed/v1/timelines/public';
  542. break;
  543. case 'network':
  544. apiUrl = '/api/pixelfed/v1/timelines/network';
  545. break;
  546. }
  547. axios.get(apiUrl, {
  548. params: {
  549. max_id: this.max_id,
  550. limit: 5
  551. }
  552. }).then(res => {
  553. let data = res.data;
  554. this.feed.push(...data);
  555. let ids = data.map(status => status.id);
  556. this.ids = ids;
  557. this.min_id = Math.max(...ids).toString();
  558. this.max_id = Math.min(...ids).toString();
  559. this.loading = false;
  560. $('.timeline .pagination').removeClass('d-none');
  561. // if(this.feed.length == 4) {
  562. // this.fetchTimelineApi();
  563. // }
  564. if(this.hashtagPosts.length == 0) {
  565. this.fetchHashtagPosts();
  566. }
  567. }).catch(err => {
  568. swal(
  569. 'Oops, something went wrong',
  570. 'Please reload the page.',
  571. 'error'
  572. );
  573. });
  574. },
  575. infiniteTimeline($state) {
  576. if(this.loading) {
  577. $state.complete();
  578. return;
  579. }
  580. if(this.page > 40) {
  581. this.loading = false;
  582. $state.complete();
  583. }
  584. let apiUrl = false;
  585. switch(this.scope) {
  586. case 'home':
  587. apiUrl = '/api/pixelfed/v1/timelines/home';
  588. break;
  589. case 'local':
  590. apiUrl = '/api/pixelfed/v1/timelines/public';
  591. break;
  592. case 'network':
  593. apiUrl = '/api/pixelfed/v1/timelines/network';
  594. break;
  595. }
  596. axios.get(apiUrl, {
  597. params: {
  598. max_id: this.max_id,
  599. limit: 6
  600. },
  601. }).then(res => {
  602. if (res.data.length && this.loading == false) {
  603. let data = res.data;
  604. let self = this;
  605. data.forEach((d, index) => {
  606. if(self.ids.indexOf(d.id) == -1) {
  607. self.feed.push(d);
  608. self.ids.push(d.id);
  609. }
  610. });
  611. this.min_id = Math.max(...this.ids).toString();
  612. this.max_id = Math.min(...this.ids).toString();
  613. this.page += 1;
  614. $state.loaded();
  615. this.loading = false;
  616. } else {
  617. $state.complete();
  618. }
  619. }).catch(err => {
  620. this.loading = false;
  621. $state.complete();
  622. });
  623. },
  624. reportUrl(status) {
  625. let type = status.in_reply_to ? 'comment' : 'post';
  626. let id = status.id;
  627. return '/i/report?type=' + type + '&id=' + id;
  628. },
  629. commentFocus(status, $event) {
  630. if(this.replyId == status.id || status.comments_disabled) {
  631. return;
  632. }
  633. this.replies = {};
  634. this.replyStatus = {};
  635. this.replyText = '';
  636. this.replyId = status.id;
  637. this.replyStatus = status;
  638. this.fetchStatusComments(status, '');
  639. },
  640. likeStatus(status) {
  641. if($('body').hasClass('loggedIn') == false) {
  642. return;
  643. }
  644. let count = status.favourites_count;
  645. status.favourited = !status.favourited;
  646. axios.post('/i/like', {
  647. item: status.id
  648. }).then(res => {
  649. status.favourites_count = res.data.count;
  650. }).catch(err => {
  651. status.favourited = !status.favourited;
  652. status.favourites_count = count;
  653. swal('Error', 'Something went wrong, please try again later.', 'error');
  654. });
  655. },
  656. shareStatus(status, $event) {
  657. if($('body').hasClass('loggedIn') == false) {
  658. return;
  659. }
  660. axios.post('/i/share', {
  661. item: status.id
  662. }).then(res => {
  663. status.reblogs_count = res.data.count;
  664. status.reblogged = !status.reblogged;
  665. }).catch(err => {
  666. swal('Error', 'Something went wrong, please try again later.', 'error');
  667. });
  668. },
  669. timestampFormat(timestamp) {
  670. let ts = new Date(timestamp);
  671. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  672. },
  673. redirect(url) {
  674. window.location.href = url;
  675. return;
  676. },
  677. statusOwner(status) {
  678. let sid = status.account.id;
  679. let uid = this.profile.id;
  680. if(sid == uid) {
  681. return true;
  682. } else {
  683. return false;
  684. }
  685. },
  686. fetchStatusComments(status, card) {
  687. axios.get('/api/v2/status/'+status.id+'/replies')
  688. .then(res => {
  689. let data = res.data.filter(res => {
  690. return res.sensitive == false;
  691. });
  692. this.replies = _.reverse(data);
  693. }).catch(err => {
  694. })
  695. },
  696. muteProfile(status) {
  697. if($('body').hasClass('loggedIn') == false) {
  698. return;
  699. }
  700. axios.post('/i/mute', {
  701. type: 'user',
  702. item: status.account.id
  703. }).then(res => {
  704. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  705. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  706. }).catch(err => {
  707. swal('Error', 'Something went wrong. Please try again later.', 'error');
  708. });
  709. },
  710. blockProfile(status) {
  711. if($('body').hasClass('loggedIn') == false) {
  712. return;
  713. }
  714. axios.post('/i/block', {
  715. type: 'user',
  716. item: status.account.id
  717. }).then(res => {
  718. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  719. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  720. }).catch(err => {
  721. swal('Error', 'Something went wrong. Please try again later.', 'error');
  722. });
  723. },
  724. deletePost(status) {
  725. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  726. return;
  727. }
  728. if(window.confirm('Are you sure you want to delete this post?') == false) {
  729. return;
  730. }
  731. axios.post('/i/delete', {
  732. type: 'status',
  733. item: status.id
  734. }).then(res => {
  735. this.feed = this.feed.filter(s => {
  736. return s.id != status.id;
  737. });
  738. this.$refs.ctxModal.hide();
  739. }).catch(err => {
  740. swal('Error', 'Something went wrong. Please try again later.', 'error');
  741. });
  742. },
  743. commentSubmit(status, $event) {
  744. let id = status.id;
  745. let comment = this.replyText;
  746. axios.post('/i/comment', {
  747. item: id,
  748. comment: comment
  749. }).then(res => {
  750. this.replyText = '';
  751. this.replies.push(res.data.entity);
  752. });
  753. },
  754. moderatePost(status, action, $event) {
  755. let username = status.account.username;
  756. switch(action) {
  757. case 'autocw':
  758. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  759. swal({
  760. title: 'Confirm',
  761. text: msg,
  762. icon: 'warning',
  763. buttons: true,
  764. dangerMode: true
  765. }).then(res => {
  766. if(res) {
  767. axios.post('/api/v2/moderator/action', {
  768. action: action,
  769. item_id: status.id,
  770. item_type: 'status'
  771. }).then(res => {
  772. swal('Success', 'Successfully enforced CW for ' + username, 'success');
  773. }).catch(err => {
  774. swal(
  775. 'Error',
  776. 'Something went wrong, please try again later.',
  777. 'error'
  778. );
  779. });
  780. }
  781. });
  782. break;
  783. case 'noautolink':
  784. msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
  785. swal({
  786. title: 'Confirm',
  787. text: msg,
  788. icon: 'warning',
  789. buttons: true,
  790. dangerMode: true
  791. }).then(res => {
  792. if(res) {
  793. axios.post('/api/v2/moderator/action', {
  794. action: action,
  795. item_id: status.id,
  796. item_type: 'status'
  797. }).then(res => {
  798. swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
  799. }).catch(err => {
  800. swal(
  801. 'Error',
  802. 'Something went wrong, please try again later.',
  803. 'error'
  804. );
  805. });
  806. }
  807. });
  808. break;
  809. case 'unlisted':
  810. msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
  811. swal({
  812. title: 'Confirm',
  813. text: msg,
  814. icon: 'warning',
  815. buttons: true,
  816. dangerMode: true
  817. }).then(res => {
  818. if(res) {
  819. axios.post('/api/v2/moderator/action', {
  820. action: action,
  821. item_id: status.id,
  822. item_type: 'status'
  823. }).then(res => {
  824. swal('Success', 'Successfully unlisted for ' + username, 'success');
  825. }).catch(err => {
  826. swal(
  827. 'Error',
  828. 'Something went wrong, please try again later.',
  829. 'error'
  830. );
  831. });
  832. }
  833. });
  834. break;
  835. case 'disable':
  836. msg = 'Are you sure you want to disable ' + username + '’s account ?';
  837. swal({
  838. title: 'Confirm',
  839. text: msg,
  840. icon: 'warning',
  841. buttons: true,
  842. dangerMode: true
  843. }).then(res => {
  844. if(res) {
  845. axios.post('/api/v2/moderator/action', {
  846. action: action,
  847. item_id: status.id,
  848. item_type: 'status'
  849. }).then(res => {
  850. swal('Success', 'Successfully disabled ' + username + '’s account', 'success');
  851. }).catch(err => {
  852. swal(
  853. 'Error',
  854. 'Something went wrong, please try again later.',
  855. 'error'
  856. );
  857. });
  858. }
  859. });
  860. break;
  861. case 'suspend':
  862. msg = 'Are you sure you want to suspend ' + username + '’s account ?';
  863. swal({
  864. title: 'Confirm',
  865. text: msg,
  866. icon: 'warning',
  867. buttons: true,
  868. dangerMode: true
  869. }).then(res => {
  870. if(res) {
  871. axios.post('/api/v2/moderator/action', {
  872. action: action,
  873. item_id: status.id,
  874. item_type: 'status'
  875. }).then(res => {
  876. swal('Success', 'Successfully suspend ' + username + '’s account', 'success');
  877. }).catch(err => {
  878. swal(
  879. 'Error',
  880. 'Something went wrong, please try again later.',
  881. 'error'
  882. );
  883. });
  884. }
  885. });
  886. break;
  887. }
  888. },
  889. followingModal() {
  890. if(this.following.length > 0) {
  891. this.$refs.followingModal.show();
  892. return;
  893. }
  894. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  895. params: {
  896. page: this.followingCursor
  897. }
  898. })
  899. .then(res => {
  900. this.following = res.data;
  901. this.followingCursor++;
  902. });
  903. if(res.data.length < 10) {
  904. this.followingMore = false;
  905. }
  906. this.$refs.followingModal.show();
  907. },
  908. followersModal() {
  909. if(this.followers.length > 0) {
  910. this.$refs.followerModal.show();
  911. return;
  912. }
  913. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  914. params: {
  915. page: this.followerCursor
  916. }
  917. })
  918. .then(res => {
  919. this.followers = res.data;
  920. this.followerCursor++;
  921. })
  922. if(res.data.length < 10) {
  923. this.followerMore = false;
  924. }
  925. this.$refs.followerModal.show();
  926. },
  927. followingLoadMore() {
  928. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  929. params: {
  930. page: this.followingCursor
  931. }
  932. })
  933. .then(res => {
  934. if(res.data.length > 0) {
  935. this.following.push(...res.data);
  936. this.followingCursor++;
  937. }
  938. if(res.data.length < 10) {
  939. this.followingMore = false;
  940. }
  941. });
  942. },
  943. followersLoadMore() {
  944. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  945. params: {
  946. page: this.followerCursor
  947. }
  948. })
  949. .then(res => {
  950. if(res.data.length > 0) {
  951. this.followers.push(...res.data);
  952. this.followerCursor++;
  953. }
  954. if(res.data.length < 10) {
  955. this.followerMore = false;
  956. }
  957. });
  958. },
  959. lightbox(status) {
  960. this.lightboxMedia = status.media_attachments[0];
  961. this.$refs.lightboxModal.show();
  962. },
  963. expLc(status) {
  964. if(this.config.ab.lc == false) {
  965. return true;
  966. }
  967. if(this.statusOwner(status) == true) {
  968. return true;
  969. }
  970. return false;
  971. },
  972. expRec() {
  973. return;
  974. if(this.config.ab.rec == false) {
  975. return;
  976. }
  977. axios.get('/api/local/exp/rec')
  978. .then(res => {
  979. this.suggestions = res.data;
  980. })
  981. },
  982. expRecFollow(id, index) {
  983. return;
  984. if(this.config.ab.rec == false) {
  985. return;
  986. }
  987. axios.post('/i/follow', {
  988. item: id
  989. }).then(res => {
  990. this.suggestions.splice(index, 1);
  991. }).catch(err => {
  992. if(err.response.data.message) {
  993. swal('Error', err.response.data.message, 'error');
  994. }
  995. });
  996. },
  997. followAction(status) {
  998. let id = status.account.id;
  999. axios.post('/i/follow', {
  1000. item: id
  1001. }).then(res => {
  1002. this.feed.forEach(s => {
  1003. if(s.account.id == id) {
  1004. s.account.relationship.following = !s.account.relationship.following;
  1005. }
  1006. });
  1007. let username = status.account.acct;
  1008. if(status.account.relationship.following) {
  1009. swal('Follow successful!', 'You are now following ' + username, 'success');
  1010. } else {
  1011. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1012. }
  1013. }).catch(err => {
  1014. if(err.response.data.message) {
  1015. swal('Error', err.response.data.message, 'error');
  1016. }
  1017. });
  1018. },
  1019. owner(status) {
  1020. return this.profile.id === status.account.id;
  1021. },
  1022. admin() {
  1023. return this.profile.is_admin == true;
  1024. },
  1025. ownerOrAdmin(status) {
  1026. return this.owner(status) || this.admin();
  1027. },
  1028. hideSuggestions() {
  1029. localStorage.setItem('pf_metro_ui.exp.rec', false);
  1030. this.showSuggestions = false;
  1031. },
  1032. emojiReaction(status) {
  1033. let em = event.target.innerText;
  1034. if(this.replyText.length == 0) {
  1035. this.replyText = em + ' ';
  1036. $('textarea[name="comment"]').focus();
  1037. } else {
  1038. this.replyText += em + ' ';
  1039. $('textarea[name="comment"]').focus();
  1040. }
  1041. },
  1042. refreshSuggestions() {
  1043. return;
  1044. let el = event.target.parentNode;
  1045. if(el.classList.contains('disabled') == true) {
  1046. return;
  1047. }
  1048. axios.get('/api/local/exp/rec', {
  1049. params: {
  1050. refresh: true
  1051. }
  1052. })
  1053. .then(res => {
  1054. this.suggestions = res.data;
  1055. if (el.classList) {
  1056. el.classList.add('disabled');
  1057. el.classList.add('text-light');
  1058. }
  1059. else {
  1060. el.className += ' ' + 'disabled text-light';
  1061. }
  1062. setTimeout(function() {
  1063. el.setAttribute('href', '#');
  1064. if (el.classList) {
  1065. el.classList.remove('disabled');
  1066. el.classList.remove('text-light');
  1067. }
  1068. else {
  1069. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1070. }
  1071. }, 10000);
  1072. });
  1073. },
  1074. fetchHashtagPosts() {
  1075. axios.get('/api/local/discover/tag/list')
  1076. .then(res => {
  1077. let tags = res.data;
  1078. if(tags.length == 0) {
  1079. return;
  1080. }
  1081. let hashtag = tags[0];
  1082. this.hashtagPostsName = hashtag;
  1083. axios.get('/api/v2/discover/tag', {
  1084. params: {
  1085. hashtag: hashtag
  1086. }
  1087. }).then(res => {
  1088. if(res.data.tags.length) {
  1089. this.showHashtagPosts = true;
  1090. this.hashtagPosts = res.data.tags.splice(0,3);
  1091. }
  1092. })
  1093. })
  1094. },
  1095. ctxMenu(status) {
  1096. this.ctxMenuStatus = status;
  1097. // let payload = '<div class="pixlfed-media" data-id="'+ this.ctxMenuStatus.id + '"></div><script ';
  1098. // payload += 'src="https://pixelfed.dev/js/embed.js" async><';
  1099. // payload += '/script>';
  1100. // this.ctxEmbedPayload = payload;
  1101. if(status.account.id == this.profile.id) {
  1102. this.$refs.ctxModal.show();
  1103. } else {
  1104. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1105. params: {
  1106. 'id[]': status.account.id
  1107. }
  1108. }).then(res => {
  1109. this.ctxMenuRelationship = res.data[0];
  1110. this.$refs.ctxModal.show();
  1111. });
  1112. }
  1113. },
  1114. closeCtxMenu(truncate) {
  1115. this.copiedEmbed = false;
  1116. this.ctxMenuStatus = false;
  1117. this.ctxMenuRelationship = false;
  1118. this.$refs.ctxModal.hide();
  1119. },
  1120. ctxMenuCopyLink() {
  1121. let status = this.ctxMenuStatus;
  1122. navigator.clipboard.writeText(status.url);
  1123. this.closeCtxMenu();
  1124. return;
  1125. },
  1126. ctxMenuGoToPost() {
  1127. let status = this.ctxMenuStatus;
  1128. window.location.href = status.url;
  1129. this.closeCtxMenu();
  1130. return;
  1131. },
  1132. ctxMenuFollow() {
  1133. let id = this.ctxMenuStatus.account.id;
  1134. axios.post('/i/follow', {
  1135. item: id
  1136. }).then(res => {
  1137. this.feed.forEach(s => {
  1138. if(s.account.id == id) {
  1139. s.account.relationship.following = !s.account.relationship.following;
  1140. }
  1141. });
  1142. let username = this.ctxMenuStatus.account.acct;
  1143. this.closeCtxMenu();
  1144. setTimeout(function() {
  1145. swal('Follow successful!', 'You are now following ' + username, 'success');
  1146. }, 500);
  1147. });
  1148. },
  1149. ctxMenuUnfollow() {
  1150. let id = this.ctxMenuStatus.account.id;
  1151. axios.post('/i/follow', {
  1152. item: id
  1153. }).then(res => {
  1154. this.feed.forEach(s => {
  1155. if(s.account.id == id) {
  1156. s.account.relationship.following = !s.account.relationship.following;
  1157. }
  1158. });
  1159. let username = this.ctxMenuStatus.account.acct;
  1160. if(this.scope == 'home') {
  1161. this.feed = this.feed.filter(s => {
  1162. return s.account.id != this.ctxMenuStatus.account.id;
  1163. });
  1164. }
  1165. this.closeCtxMenu();
  1166. setTimeout(function() {
  1167. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1168. }, 500);
  1169. });
  1170. },
  1171. ctxMenuReportPost() {
  1172. window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id;
  1173. },
  1174. ctxMenuEmbed() {
  1175. this.$refs.ctxModal.hide();
  1176. this.$refs.ctxEmbedModal.show();
  1177. },
  1178. ctxMenuShare() {
  1179. this.$refs.ctxModal.hide();
  1180. this.$refs.ctxShareModal.show();
  1181. },
  1182. closeCtxShareMenu() {
  1183. this.$refs.ctxShareModal.hide();
  1184. this.$refs.ctxModal.show();
  1185. },
  1186. ctxCopyEmbed() {
  1187. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1188. this.$refs.ctxEmbedModal.hide();
  1189. },
  1190. ctxModMenuShow() {
  1191. this.$refs.ctxModal.hide();
  1192. this.$refs.ctxModModal.show();
  1193. },
  1194. ctxModMenu() {
  1195. this.$refs.ctxModal.hide();
  1196. },
  1197. ctxModMenuClose() {
  1198. this.$refs.ctxModal.hide();
  1199. this.$refs.ctxModModal.hide();
  1200. },
  1201. hideTips() {
  1202. this.showTips = false;
  1203. window.localStorage.setItem('metro-tips', false);
  1204. },
  1205. formatCount(count) {
  1206. return App.util.format.count(count);
  1207. }
  1208. }
  1209. }
  1210. </script>