Timeline.vue 48 KB

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