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