Timeline.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307
  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. if(self.ids.indexOf(d.id) == -1) {
  627. self.feed.push(d);
  628. self.ids.push(d.id);
  629. }
  630. });
  631. this.min_id = Math.max(...this.ids);
  632. this.max_id = Math.min(...this.ids);
  633. this.page += 1;
  634. $state.loaded();
  635. this.loading = false;
  636. } else {
  637. $state.complete();
  638. }
  639. });
  640. },
  641. loadMore(event) {
  642. let homeTimeline = '/api/v1/timelines/home';
  643. let localTimeline = '/api/v1/timelines/public';
  644. let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline;
  645. event.target.innerText = 'Loading...';
  646. axios.get(apiUrl, {
  647. params: {
  648. page: this.page,
  649. },
  650. }).then(res => {
  651. if (res.data.length && this.loading == false) {
  652. let data = res.data;
  653. let ids = data.map(status => status.id);
  654. this.min_id = Math.min(...ids);
  655. if(this.page == 1) {
  656. this.max_id = Math.max(...ids);
  657. }
  658. this.feed.push(...data);
  659. this.page += 1;
  660. this.loading = false;
  661. event.target.innerText = 'Load more posts';
  662. } else {
  663. }
  664. });
  665. },
  666. reportUrl(status) {
  667. let type = status.in_reply_to ? 'comment' : 'post';
  668. let id = status.id;
  669. return '/i/report?type=' + type + '&id=' + id;
  670. },
  671. commentFocus(status, $event) {
  672. if(this.replyId == status.id || status.comments_disabled) {
  673. return;
  674. }
  675. this.replies = {};
  676. this.replyStatus = {};
  677. this.replyText = '';
  678. this.replyId = status.id;
  679. this.replyStatus = status;
  680. this.fetchStatusComments(status, '');
  681. },
  682. likeStatus(status) {
  683. if($('body').hasClass('loggedIn') == false) {
  684. return;
  685. }
  686. let count = status.favourites_count;
  687. status.favourited = !status.favourited;
  688. axios.post('/i/like', {
  689. item: status.id
  690. }).then(res => {
  691. status.favourites_count = res.data.count;
  692. }).catch(err => {
  693. status.favourited = !status.favourited;
  694. status.favourites_count = count;
  695. swal('Error', 'Something went wrong, please try again later.', 'error');
  696. });
  697. },
  698. shareStatus(status, $event) {
  699. if($('body').hasClass('loggedIn') == false) {
  700. return;
  701. }
  702. axios.post('/i/share', {
  703. item: status.id
  704. }).then(res => {
  705. status.reblogs_count = res.data.count;
  706. status.reblogged = !status.reblogged;
  707. }).catch(err => {
  708. swal('Error', 'Something went wrong, please try again later.', 'error');
  709. });
  710. },
  711. timestampFormat(timestamp) {
  712. let ts = new Date(timestamp);
  713. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  714. },
  715. editUrl(status) {
  716. return status.url + '/edit';
  717. },
  718. redirect(url) {
  719. window.location.href = url;
  720. return;
  721. },
  722. replyUrl(status) {
  723. let username = this.profile.username;
  724. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  725. return '/p/' + username + '/' + id;
  726. },
  727. mentionUrl(status) {
  728. let username = status.account.username;
  729. let id = status.id;
  730. return '/p/' + username + '/' + id;
  731. },
  732. statusOwner(status) {
  733. let sid = status.account.id;
  734. let uid = this.profile.id;
  735. if(sid == uid) {
  736. return true;
  737. } else {
  738. return false;
  739. }
  740. },
  741. fetchStatusComments(status, card) {
  742. axios.get('/api/v2/status/'+status.id+'/replies')
  743. .then(res => {
  744. let data = res.data.filter(res => {
  745. return res.sensitive == false;
  746. });
  747. this.replies = _.reverse(data);
  748. }).catch(err => {
  749. })
  750. },
  751. muteProfile(status) {
  752. if($('body').hasClass('loggedIn') == false) {
  753. return;
  754. }
  755. axios.post('/i/mute', {
  756. type: 'user',
  757. item: status.account.id
  758. }).then(res => {
  759. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  760. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  761. }).catch(err => {
  762. swal('Error', 'Something went wrong. Please try again later.', 'error');
  763. });
  764. },
  765. blockProfile(status) {
  766. if($('body').hasClass('loggedIn') == false) {
  767. return;
  768. }
  769. axios.post('/i/block', {
  770. type: 'user',
  771. item: status.account.id
  772. }).then(res => {
  773. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  774. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  775. }).catch(err => {
  776. swal('Error', 'Something went wrong. Please try again later.', 'error');
  777. });
  778. },
  779. deletePost(status, index) {
  780. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  781. return;
  782. }
  783. if(window.confirm('Are you sure you want to delete this post?') == false) {
  784. return;
  785. }
  786. axios.post('/i/delete', {
  787. type: 'status',
  788. item: status.id
  789. }).then(res => {
  790. this.feed = this.feed.filter(s => {
  791. return s.id != status.id;
  792. })
  793. swal('Success', 'You have successfully deleted this post', 'success');
  794. }).catch(err => {
  795. swal('Error', 'Something went wrong. Please try again later.', 'error');
  796. });
  797. },
  798. commentSubmit(status, $event) {
  799. let id = status.id;
  800. let comment = this.replyText;
  801. axios.post('/i/comment', {
  802. item: id,
  803. comment: comment
  804. }).then(res => {
  805. this.replyText = '';
  806. this.replies.push(res.data.entity);
  807. });
  808. },
  809. moderatePost(status, action, $event) {
  810. let username = status.account.username;
  811. switch(action) {
  812. case 'autocw':
  813. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  814. swal({
  815. title: 'Confirm',
  816. text: msg,
  817. icon: 'warning',
  818. buttons: true,
  819. dangerMode: true
  820. }).then(res => {
  821. if(res) {
  822. axios.post('/api/v2/moderator/action', {
  823. action: action,
  824. item_id: status.id,
  825. item_type: 'status'
  826. }).then(res => {
  827. swal('Success', 'Successfully enforced CW for ' + username, 'success');
  828. }).catch(err => {
  829. swal(
  830. 'Error',
  831. 'Something went wrong, please try again later.',
  832. 'error'
  833. );
  834. });
  835. }
  836. });
  837. break;
  838. case 'noautolink':
  839. msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
  840. swal({
  841. title: 'Confirm',
  842. text: msg,
  843. icon: 'warning',
  844. buttons: true,
  845. dangerMode: true
  846. }).then(res => {
  847. if(res) {
  848. axios.post('/api/v2/moderator/action', {
  849. action: action,
  850. item_id: status.id,
  851. item_type: 'status'
  852. }).then(res => {
  853. swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
  854. }).catch(err => {
  855. swal(
  856. 'Error',
  857. 'Something went wrong, please try again later.',
  858. 'error'
  859. );
  860. });
  861. }
  862. });
  863. break;
  864. case 'unlisted':
  865. msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
  866. swal({
  867. title: 'Confirm',
  868. text: msg,
  869. icon: 'warning',
  870. buttons: true,
  871. dangerMode: true
  872. }).then(res => {
  873. if(res) {
  874. axios.post('/api/v2/moderator/action', {
  875. action: action,
  876. item_id: status.id,
  877. item_type: 'status'
  878. }).then(res => {
  879. swal('Success', 'Successfully unlisted for ' + username, 'success');
  880. }).catch(err => {
  881. swal(
  882. 'Error',
  883. 'Something went wrong, please try again later.',
  884. 'error'
  885. );
  886. });
  887. }
  888. });
  889. break;
  890. case 'disable':
  891. msg = 'Are you sure you want to disable ' + username + 'โ€™s account ?';
  892. swal({
  893. title: 'Confirm',
  894. text: msg,
  895. icon: 'warning',
  896. buttons: true,
  897. dangerMode: true
  898. }).then(res => {
  899. if(res) {
  900. axios.post('/api/v2/moderator/action', {
  901. action: action,
  902. item_id: status.id,
  903. item_type: 'status'
  904. }).then(res => {
  905. swal('Success', 'Successfully disabled ' + username + 'โ€™s account', 'success');
  906. }).catch(err => {
  907. swal(
  908. 'Error',
  909. 'Something went wrong, please try again later.',
  910. 'error'
  911. );
  912. });
  913. }
  914. });
  915. break;
  916. case 'suspend':
  917. msg = 'Are you sure you want to suspend ' + username + 'โ€™s account ?';
  918. swal({
  919. title: 'Confirm',
  920. text: msg,
  921. icon: 'warning',
  922. buttons: true,
  923. dangerMode: true
  924. }).then(res => {
  925. if(res) {
  926. axios.post('/api/v2/moderator/action', {
  927. action: action,
  928. item_id: status.id,
  929. item_type: 'status'
  930. }).then(res => {
  931. swal('Success', 'Successfully suspend ' + username + 'โ€™s account', 'success');
  932. }).catch(err => {
  933. swal(
  934. 'Error',
  935. 'Something went wrong, please try again later.',
  936. 'error'
  937. );
  938. });
  939. }
  940. });
  941. break;
  942. }
  943. },
  944. followingModal() {
  945. if(this.following.length > 0) {
  946. this.$refs.followingModal.show();
  947. return;
  948. }
  949. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  950. params: {
  951. page: this.followingCursor
  952. }
  953. })
  954. .then(res => {
  955. this.following = res.data;
  956. this.followingCursor++;
  957. });
  958. if(res.data.length < 10) {
  959. this.followingMore = false;
  960. }
  961. this.$refs.followingModal.show();
  962. },
  963. followersModal() {
  964. if(this.followers.length > 0) {
  965. this.$refs.followerModal.show();
  966. return;
  967. }
  968. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  969. params: {
  970. page: this.followerCursor
  971. }
  972. })
  973. .then(res => {
  974. this.followers = res.data;
  975. this.followerCursor++;
  976. })
  977. if(res.data.length < 10) {
  978. this.followerMore = false;
  979. }
  980. this.$refs.followerModal.show();
  981. },
  982. followingLoadMore() {
  983. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  984. params: {
  985. page: this.followingCursor
  986. }
  987. })
  988. .then(res => {
  989. if(res.data.length > 0) {
  990. this.following.push(...res.data);
  991. this.followingCursor++;
  992. }
  993. if(res.data.length < 10) {
  994. this.followingMore = false;
  995. }
  996. });
  997. },
  998. followersLoadMore() {
  999. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  1000. params: {
  1001. page: this.followerCursor
  1002. }
  1003. })
  1004. .then(res => {
  1005. if(res.data.length > 0) {
  1006. this.followers.push(...res.data);
  1007. this.followerCursor++;
  1008. }
  1009. if(res.data.length < 10) {
  1010. this.followerMore = false;
  1011. }
  1012. });
  1013. },
  1014. lightbox(src) {
  1015. this.lightboxMedia = src;
  1016. this.$refs.lightboxModal.show();
  1017. },
  1018. expLc(status) {
  1019. if(this.config.ab.lc == false) {
  1020. return true;
  1021. }
  1022. if(this.statusOwner(status) == true) {
  1023. return true;
  1024. }
  1025. return false;
  1026. },
  1027. expRec() {
  1028. if(this.config.ab.rec == false) {
  1029. return;
  1030. }
  1031. axios.get('/api/local/exp/rec')
  1032. .then(res => {
  1033. this.suggestions = res.data;
  1034. })
  1035. },
  1036. expRecFollow(id, index) {
  1037. if(this.config.ab.rec == false) {
  1038. return;
  1039. }
  1040. axios.post('/i/follow', {
  1041. item: id
  1042. }).then(res => {
  1043. this.suggestions.splice(index, 1);
  1044. }).catch(err => {
  1045. if(err.response.data.message) {
  1046. swal('Error', err.response.data.message, 'error');
  1047. }
  1048. });
  1049. },
  1050. followModalAction(id, index, type = 'following') {
  1051. axios.post('/i/follow', {
  1052. item: id
  1053. }).then(res => {
  1054. if(type == 'following') {
  1055. this.following.splice(index, 1);
  1056. }
  1057. }).catch(err => {
  1058. if(err.response.data.message) {
  1059. swal('Error', err.response.data.message, 'error');
  1060. }
  1061. });
  1062. },
  1063. owner(status) {
  1064. return this.profile.id === status.account.id;
  1065. },
  1066. admin() {
  1067. return this.profile.is_admin == true;
  1068. },
  1069. ownerOrAdmin(status) {
  1070. return this.owner(status) || this.admin();
  1071. },
  1072. hideSuggestions() {
  1073. localStorage.setItem('pf_metro_ui.exp.rec', false);
  1074. this.showSuggestions = false;
  1075. },
  1076. emojiReaction(status) {
  1077. let em = event.target.innerText;
  1078. if(this.replyText.length == 0) {
  1079. this.replyText = em + ' ';
  1080. $('textarea[name="comment"]').focus();
  1081. } else {
  1082. this.replyText += em + ' ';
  1083. $('textarea[name="comment"]').focus();
  1084. }
  1085. },
  1086. refreshSuggestions() {
  1087. let el = event.target.parentNode;
  1088. if(el.classList.contains('disabled') == true) {
  1089. return;
  1090. }
  1091. axios.get('/api/local/exp/rec', {
  1092. params: {
  1093. refresh: true
  1094. }
  1095. })
  1096. .then(res => {
  1097. this.suggestions = res.data;
  1098. if (el.classList) {
  1099. el.classList.add('disabled');
  1100. el.classList.add('text-light');
  1101. }
  1102. else {
  1103. el.className += ' ' + 'disabled text-light';
  1104. }
  1105. setTimeout(function() {
  1106. el.setAttribute('href', '#');
  1107. if (el.classList) {
  1108. el.classList.remove('disabled');
  1109. el.classList.remove('text-light');
  1110. }
  1111. else {
  1112. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1113. }
  1114. }, 10000);
  1115. });
  1116. },
  1117. fetchHashtagPosts() {
  1118. axios.get('/api/local/discover/tag/list')
  1119. .then(res => {
  1120. let tags = res.data;
  1121. if(tags.length == 0) {
  1122. return;
  1123. }
  1124. let hashtag = tags[0];
  1125. this.hashtagPostsName = hashtag;
  1126. axios.get('/api/v2/discover/tag', {
  1127. params: {
  1128. hashtag: hashtag
  1129. }
  1130. }).then(res => {
  1131. if(res.data.tags.length) {
  1132. this.showHashtagPosts = true;
  1133. this.hashtagPosts = res.data.tags.splice(0,3);
  1134. }
  1135. })
  1136. })
  1137. },
  1138. ctxMenu(status) {
  1139. this.ctxMenuStatus = status;
  1140. let payload = '<div class="pixlfed-media" data-id="'+ this.ctxMenuStatus.id + '"></div><script ';
  1141. payload += 'src="https://pixelfed.dev/js/embed.js" async><';
  1142. payload += '/script>';
  1143. this.ctxEmbedPayload = payload;
  1144. if(status.account.id == this.profile.id) {
  1145. this.$refs.ctxModal.show();
  1146. } else {
  1147. axios.get('/api/v1/accounts/relationships', {
  1148. params: {
  1149. 'id[]': status.account.id
  1150. }
  1151. }).then(res => {
  1152. this.ctxMenuRelationship = res.data[0];
  1153. this.$refs.ctxModal.show();
  1154. });
  1155. }
  1156. },
  1157. closeCtxMenu(truncate) {
  1158. this.copiedEmbed = false;
  1159. this.ctxMenuStatus = false;
  1160. this.ctxMenuRelationship = false;
  1161. this.$refs.ctxModal.hide();
  1162. },
  1163. ctxMenuCopyLink() {
  1164. let status = this.ctxMenuStatus;
  1165. navigator.clipboard.writeText(status.url);
  1166. this.closeCtxMenu();
  1167. return;
  1168. },
  1169. ctxMenuGoToPost() {
  1170. let status = this.ctxMenuStatus;
  1171. window.location.href = status.url;
  1172. this.closeCtxMenu();
  1173. return;
  1174. },
  1175. ctxMenuFollow() {
  1176. axios.post('/i/follow', {
  1177. item: this.ctxMenuStatus.account.id
  1178. }).then(res => {
  1179. let username = this.ctxMenuStatus.account.acct;
  1180. this.closeCtxMenu();
  1181. setTimeout(function() {
  1182. swal('Follow successful!', 'You are now following ' + username, 'success');
  1183. }, 500);
  1184. });
  1185. },
  1186. ctxMenuUnfollow() {
  1187. axios.post('/i/follow', {
  1188. item: this.ctxMenuStatus.account.id
  1189. }).then(res => {
  1190. let username = this.ctxMenuStatus.account.acct;
  1191. this.closeCtxMenu();
  1192. setTimeout(function() {
  1193. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1194. }, 500);
  1195. });
  1196. },
  1197. ctxMenuReportPost() {
  1198. window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id;
  1199. },
  1200. ctxMenuEmbed() {
  1201. this.$refs.ctxModal.hide();
  1202. this.$refs.ctxEmbedModal.show();
  1203. },
  1204. ctxMenuShare() {
  1205. this.$refs.ctxModal.hide();
  1206. this.$refs.ctxShareModal.show();
  1207. },
  1208. closeCtxShareMenu() {
  1209. this.$refs.ctxShareModal.hide();
  1210. this.$refs.ctxModal.show();
  1211. },
  1212. ctxCopyEmbed() {
  1213. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1214. this.$refs.ctxEmbedModal.hide();
  1215. }
  1216. }
  1217. }
  1218. </script>