Timeline.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. <template>
  2. <div class="container" style="">
  3. <div class="row">
  4. <div :class="[modes.distractionFree ? 'col-md-8 col-lg-8 offset-md-2 px-0 my-sm-3 timeline order-2 order-md-1':'col-md-8 col-lg-8 px-0 my-sm-3 timeline order-2 order-md-1']">
  5. <div style="padding-top:10px;">
  6. <div v-if="loading" class="text-center">
  7. <div class="spinner-border" role="status">
  8. <span class="sr-only">Loading...</span>
  9. </div>
  10. </div>
  11. <div :data-status-id="status.id" v-for="(status, index) in feed" :key="`${index}-${status.id}`">
  12. <div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  13. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  14. <h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
  15. <span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
  16. </div>
  17. <div class="card-body row mx-0">
  18. <div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
  19. <div class="card">
  20. <div class="card-body text-center pt-3">
  21. <p class="mb-0">
  22. <a :href="'/'+rec.username">
  23. <img :src="rec.avatar" class="img-fluid rounded-circle cursor-pointer" width="45px" height="45px">
  24. </a>
  25. </p>
  26. <div class="py-3">
  27. <p class="font-weight-bold text-dark cursor-pointer mb-0">
  28. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  29. {{rec.username}}
  30. </a>
  31. </p>
  32. <p class="small text-muted mb-0">{{rec.message}}</p>
  33. </div>
  34. <p class="mb-0">
  35. <a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  36. </p>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div v-if="index == 4 && showHashtagPosts && hashtagPosts.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  43. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  44. <span></span>
  45. <h6 class="text-muted font-weight-bold mb-0"><a :href="'/discover/tags/'+hashtagPostsName+'?src=tr'">#{{hashtagPostsName}}</a></h6>
  46. <span class="cursor-pointer text-muted" v-on:click="showHashtagPosts = false"><i class="fas fa-times"></i></span>
  47. </div>
  48. <div class="card-body row mx-0">
  49. <div v-for="(tag, index) in hashtagPosts" class="col-4 p-0 p-sm-2 p-md-3 hashtag-post-square">
  50. <a class="card info-overlay card-md-border-0" :href="tag.status.url">
  51. <div :class="[tag.status.filter ? 'square ' + tag.status.filter : 'square']">
  52. <div class="square-content" :style="'background-image: url('+tag.status.thumb+')'"></div>
  53. <div class="info-overlay-text">
  54. <h5 class="text-white m-auto font-weight-bold">
  55. <span class="pr-4">
  56. <span class="far fa-heart fa-lg pr-1"></span> {{tag.status.like_count}}
  57. </span>
  58. <span>
  59. <span class="fas fa-retweet fa-lg pr-1"></span> {{tag.status.share_count}}
  60. </span>
  61. </h5>
  62. </div>
  63. </div>
  64. </a>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  69. <div v-if="!modes.distractionFree" class="card-header d-inline-flex align-items-center bg-white">
  70. <img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
  71. <div class="pl-2">
  72. <!-- <a class="d-block username font-weight-bold text-dark" v-bind:href="status.account.url" style="line-height:0.5;"> -->
  73. <a class="username font-weight-bold text-dark text-decoration-none" v-bind:href="status.account.url">
  74. {{status.account.username}}
  75. </a>
  76. <span v-if="status.account.is_admin" class="fa-stack" title="Admin Account" data-toggle="tooltip" style="height:1em; line-height:1em; max-width:19px;">
  77. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  78. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  79. </span>
  80. <span v-if="scope != 'home' && status.account.id != profile.id && status.account.relationship">
  81. <span class="px-1">•</span>
  82. <span :class="'font-weight-bold cursor-pointer ' + [status.account.relationship.following == true ? 'text-muted' : 'text-primary']" @click="followAction(status)">{{status.account.relationship.following == true ? 'Following' : 'Follow'}}</span>
  83. </span>
  84. <a v-if="status.place" class="d-block small text-decoration-none" :href="'/discover/places/'+status.place.id+'/'+status.place.slug" style="color:#718096">{{status.place.name}}, {{status.place.country}}</a>
  85. </div>
  86. <div class="text-right" style="flex-grow:1;">
  87. <button class="btn btn-link text-dark py-0" type="button" @click="ctxMenu(status)">
  88. <span class="fas fa-ellipsis-h text-lighter"></span>
  89. </button>
  90. <!-- <div class="dropdown-menu dropdown-menu-right">
  91. <a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
  92. <!-- <a class="dropdown-item font-weight-bold" href="#">Share</a>
  93. <a class="dropdown-item font-weight-bold" href="#">Embed</a> ->
  94. <span v-if="statusOwner(status) == false">
  95. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  96. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
  97. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
  98. </span>
  99. <span v-if="statusOwner(status) == true">
  100. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  101. </span>
  102. <span v-if="profile.is_admin == true && modes.mod == true">
  103. <div class="dropdown-divider"></div>
  104. <a v-if="!statusOwner(status)" class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  105. <div class="dropdown-divider"></div>
  106. <h6 class="dropdown-header">Mod Tools</h6>
  107. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')">
  108. <p class="mb-0" data-toggle="tooltip" data-placement="bottom" title="Adds a CW to every post made by this account.">Enforce CW</p>
  109. </a>
  110. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')">
  111. <p class="mb-0" title="Do not transform mentions, hashtags or urls into HTML.">No Autolinking</p>
  112. </a>
  113. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')">
  114. <p class="mb-0" title="Removes account from public/network timelines.">Unlisted Posts</p>
  115. </a>
  116. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'disable')">
  117. <p class="mb-0" title="Temporarily disable account until next time user log in.">Disable Account</p>
  118. </a>
  119. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')">
  120. <p class="mb-0" title="This prevents any new interactions, without deleting existing data.">Suspend Account</p>
  121. </a>
  122. </span>
  123. </div> -->
  124. </div>
  125. </div>
  126. <div class="postPresenterContainer" @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 && !loading" 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="/discover/places" class="text-dark pr-2">Places</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="ctxModal"
  339. id="ctx-modal"
  340. hide-header
  341. hide-footer
  342. centered
  343. rounded
  344. size="sm"
  345. body-class="list-group-flush p-0 rounded">
  346. <div class="list-group text-center">
  347. <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>
  348. <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>
  349. <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>
  350. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuGoToPost()">Go to post</div>
  351. <!-- <div class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
  352. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuShare()">Share</div> -->
  353. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
  354. <div v-if="profile && profile.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenuShow()">Moderation Tools</div>
  355. <div v-if="ctxMenuStatus && (profile.is_admin || profile.id == ctxMenuStatus.account.id)" class="list-group-item rounded cursor-pointer" @click="deletePost(ctxMenuStatus)">Delete</div>
  356. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
  357. </div>
  358. </b-modal>
  359. <b-modal ref="ctxModModal"
  360. id="ctx-mod-modal"
  361. hide-header
  362. hide-footer
  363. centered
  364. rounded
  365. size="sm"
  366. body-class="list-group-flush p-0 rounded">
  367. <div class="list-group text-center">
  368. <div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div>
  369. <div class="list-group-item rounded cursor-pointer" @click="">Add Content Warning</div>
  370. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
  371. </div>
  372. </b-modal>
  373. <b-modal ref="ctxShareModal"
  374. id="ctx-share-modal"
  375. title="Share"
  376. hide-footer
  377. centered
  378. rounded
  379. size="sm"
  380. body-class="list-group-flush p-0 rounded text-center">
  381. <div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
  382. <div class="list-group-item rounded cursor-pointer">Facebook</div>
  383. <div class="list-group-item rounded cursor-pointer">Mastodon</div>
  384. <div class="list-group-item rounded cursor-pointer">Pinterest</div>
  385. <div class="list-group-item rounded cursor-pointer">Pixelfed</div>
  386. <div class="list-group-item rounded cursor-pointer">Twitter</div>
  387. <div class="list-group-item rounded cursor-pointer">VK</div>
  388. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
  389. </b-modal>
  390. <b-modal ref="ctxEmbedModal"
  391. id="ctx-embed-modal"
  392. hide-header
  393. hide-footer
  394. centered
  395. rounded
  396. size="md"
  397. body-class="p-2 rounded">
  398. <div>
  399. <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>
  400. <hr>
  401. <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>
  402. <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>
  403. </div>
  404. </b-modal>
  405. <b-modal
  406. id="lightbox"
  407. ref="lightboxModal"
  408. hide-header
  409. hide-footer
  410. centered
  411. size="lg"
  412. body-class="p-0"
  413. >
  414. <div v-if="lightboxMedia" :class="lightboxMedia.filter_class" class="w-100 h-100">
  415. <img :src="lightboxMedia.url" style="max-height: 100%; max-width: 100%">
  416. </div>
  417. </b-modal>
  418. </div>
  419. </template>
  420. <style type="text/css" scoped>
  421. .postPresenterContainer {
  422. display: flex;
  423. align-items: center;
  424. background: #fff;
  425. }
  426. .word-break {
  427. word-break: break-all;
  428. }
  429. .small .custom-control-label {
  430. padding-top: 3px;
  431. }
  432. .reply-btn {
  433. position: absolute;
  434. bottom: 12px;
  435. right: 20px;
  436. width: 60px;
  437. text-align: center;
  438. border-radius: 0 3px 3px 0;
  439. }
  440. .emoji-reactions .nav-item {
  441. font-size: 1.2rem;
  442. padding: 9px;
  443. cursor: pointer;
  444. }
  445. .emoji-reactions::-webkit-scrollbar {
  446. width: 0px;
  447. height: 0px;
  448. background: transparent;
  449. }
  450. </style>
  451. <script type="text/javascript">
  452. export default {
  453. props: ['scope'],
  454. data() {
  455. return {
  456. ids: [],
  457. config: window.App.config,
  458. page: 2,
  459. feed: [],
  460. profile: {},
  461. min_id: 0,
  462. max_id: 0,
  463. stories: {},
  464. suggestions: {},
  465. loading: true,
  466. replies: [],
  467. replyId: null,
  468. modes: {
  469. 'mod': false,
  470. 'dark': false,
  471. 'notify': true,
  472. 'distractionFree': false
  473. },
  474. followers: [],
  475. followerCursor: 1,
  476. followerMore: true,
  477. following: [],
  478. followingCursor: 1,
  479. followingMore: true,
  480. lightboxMedia: false,
  481. showSuggestions: false,
  482. showReadMore: true,
  483. replyStatus: {},
  484. replyText: '',
  485. emoji: ['😀','🤣','😃','😄','😆','😉','😊','😋','😘','😗','😙','😚','🤗','🤩','🤔','🤨','😐','😑','😶','🙄','😏','😣','😥','😮','🤐','😪','😫','😴','😌','😛','😜','😝','🤤','😒','😓','😔','😕','🙃','🤑','😲','🙁','😖','😞','😟','😤','😭','😦','😧','😨','😩','🤯','😬','😰','😱','😳','🤪','😵','😡','😠','🤬','😷','🤒','🤕','🤢','🤮','🤧','😇','🤠','🤡','🤥','🤫','🤭','🧐','🤓','😈','👿','👹','👺','💀','👻','👽','🤖','💩','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🤲','👐','🤝','👍','👎','👊','✊','🤛','🤜','🤞','✌️','🤟','🤘','👈','👉','👆','👇','☝️','✋','🤚','🖐','🖖','👋','🤙','💪','🖕','✍️','🙏','💍','💄','💋','👄','👅','👂','👃','👣','👁','👀','🧠','🗣','👤','👥'],
  486. showHashtagPosts: false,
  487. hashtagPosts: [],
  488. hashtagPostsName: '',
  489. ctxMenuStatus: false,
  490. ctxMenuRelationship: false,
  491. ctxEmbedPayload: false,
  492. copiedEmbed: false,
  493. showTips: true,
  494. }
  495. },
  496. beforeMount() {
  497. this.fetchProfile();
  498. this.fetchTimelineApi();
  499. },
  500. mounted() {
  501. if($('link[data-stylesheet="dark"]').length != 0) {
  502. this.modes.dark = true;
  503. }
  504. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  505. this.showSuggestions = false;
  506. } else {
  507. this.showSuggestions = true;
  508. }
  509. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  510. this.showReadMore = false;
  511. } else {
  512. this.showReadMore = true;
  513. }
  514. if(localStorage.getItem('pf_metro_ui.exp.df') == 'true') {
  515. this.modes.distractionFree = true;
  516. } else {
  517. this.modes.distractionFree = false;
  518. }
  519. if(localStorage.getItem('metro-tips') == 'false') {
  520. this.showTips = false;
  521. }
  522. this.$nextTick(function () {
  523. $('[data-toggle="tooltip"]').tooltip()
  524. });
  525. },
  526. updated() {
  527. if(this.showReadMore == true) {
  528. pixelfed.readmore();
  529. }
  530. },
  531. methods: {
  532. fetchProfile() {
  533. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  534. this.profile = res.data;
  535. if(this.profile.is_admin == true) {
  536. this.modes.mod = true;
  537. }
  538. $('.profile-card .loader').addClass('d-none');
  539. $('.profile-card .contents').removeClass('d-none');
  540. $('.profile-card .card-footer').removeClass('d-none');
  541. this.expRec();
  542. }).catch(err => {
  543. swal(
  544. 'Oops, something went wrong',
  545. 'Please reload the page.',
  546. 'error'
  547. );
  548. });
  549. },
  550. fetchTimelineApi() {
  551. let apiUrl = false;
  552. switch(this.scope) {
  553. case 'home':
  554. apiUrl = '/api/pixelfed/v1/timelines/home';
  555. break;
  556. case 'local':
  557. apiUrl = '/api/pixelfed/v1/timelines/public';
  558. break;
  559. case 'network':
  560. apiUrl = '/api/pixelfed/v1/timelines/network';
  561. break;
  562. }
  563. axios.get(apiUrl, {
  564. params: {
  565. max_id: this.max_id,
  566. limit: 4
  567. }
  568. }).then(res => {
  569. let data = res.data;
  570. this.feed.push(...data);
  571. let ids = data.map(status => status.id);
  572. this.ids = ids;
  573. this.min_id = Math.max(...ids);
  574. this.max_id = Math.min(...ids);
  575. this.loading = false;
  576. $('.timeline .pagination').removeClass('d-none');
  577. // if(this.feed.length == 4) {
  578. // this.fetchTimelineApi();
  579. // }
  580. if(this.hashtagPosts.length == 0) {
  581. this.fetchHashtagPosts();
  582. }
  583. }).catch(err => {
  584. swal(
  585. 'Oops, something went wrong',
  586. 'Please reload the page.',
  587. 'error'
  588. );
  589. });
  590. },
  591. infiniteTimeline($state) {
  592. if(this.loading) {
  593. $state.complete();
  594. return;
  595. }
  596. let apiUrl = false;
  597. switch(this.scope) {
  598. case 'home':
  599. apiUrl = '/api/pixelfed/v1/timelines/home';
  600. break;
  601. case 'local':
  602. apiUrl = '/api/pixelfed/v1/timelines/public';
  603. break;
  604. case 'network':
  605. apiUrl = '/api/pixelfed/v1/timelines/network';
  606. break;
  607. }
  608. axios.get(apiUrl, {
  609. params: {
  610. max_id: this.max_id,
  611. limit: 6
  612. },
  613. }).then(res => {
  614. if (res.data.length && this.loading == false) {
  615. let data = res.data;
  616. let self = this;
  617. data.forEach((d, index) => {
  618. if(self.ids.indexOf(d.id) == -1) {
  619. self.feed.push(d);
  620. self.ids.push(d.id);
  621. }
  622. });
  623. this.min_id = Math.max(...this.ids);
  624. this.max_id = Math.min(...this.ids);
  625. this.page += 1;
  626. $state.loaded();
  627. this.loading = false;
  628. } else {
  629. $state.complete();
  630. }
  631. }).catch(err => {
  632. this.loading = false;
  633. $state.complete();
  634. });
  635. },
  636. reportUrl(status) {
  637. let type = status.in_reply_to ? 'comment' : 'post';
  638. let id = status.id;
  639. return '/i/report?type=' + type + '&id=' + id;
  640. },
  641. commentFocus(status, $event) {
  642. if(this.replyId == status.id || status.comments_disabled) {
  643. return;
  644. }
  645. this.replies = {};
  646. this.replyStatus = {};
  647. this.replyText = '';
  648. this.replyId = status.id;
  649. this.replyStatus = status;
  650. this.fetchStatusComments(status, '');
  651. },
  652. likeStatus(status) {
  653. if($('body').hasClass('loggedIn') == false) {
  654. return;
  655. }
  656. let count = status.favourites_count;
  657. status.favourited = !status.favourited;
  658. axios.post('/i/like', {
  659. item: status.id
  660. }).then(res => {
  661. status.favourites_count = res.data.count;
  662. }).catch(err => {
  663. status.favourited = !status.favourited;
  664. status.favourites_count = count;
  665. swal('Error', 'Something went wrong, please try again later.', 'error');
  666. });
  667. },
  668. shareStatus(status, $event) {
  669. if($('body').hasClass('loggedIn') == false) {
  670. return;
  671. }
  672. axios.post('/i/share', {
  673. item: status.id
  674. }).then(res => {
  675. status.reblogs_count = res.data.count;
  676. status.reblogged = !status.reblogged;
  677. }).catch(err => {
  678. swal('Error', 'Something went wrong, please try again later.', 'error');
  679. });
  680. },
  681. timestampFormat(timestamp) {
  682. let ts = new Date(timestamp);
  683. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  684. },
  685. redirect(url) {
  686. window.location.href = url;
  687. return;
  688. },
  689. statusOwner(status) {
  690. let sid = status.account.id;
  691. let uid = this.profile.id;
  692. if(sid == uid) {
  693. return true;
  694. } else {
  695. return false;
  696. }
  697. },
  698. fetchStatusComments(status, card) {
  699. axios.get('/api/v2/status/'+status.id+'/replies')
  700. .then(res => {
  701. let data = res.data.filter(res => {
  702. return res.sensitive == false;
  703. });
  704. this.replies = _.reverse(data);
  705. }).catch(err => {
  706. })
  707. },
  708. muteProfile(status) {
  709. if($('body').hasClass('loggedIn') == false) {
  710. return;
  711. }
  712. axios.post('/i/mute', {
  713. type: 'user',
  714. item: status.account.id
  715. }).then(res => {
  716. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  717. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  718. }).catch(err => {
  719. swal('Error', 'Something went wrong. Please try again later.', 'error');
  720. });
  721. },
  722. blockProfile(status) {
  723. if($('body').hasClass('loggedIn') == false) {
  724. return;
  725. }
  726. axios.post('/i/block', {
  727. type: 'user',
  728. item: status.account.id
  729. }).then(res => {
  730. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  731. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  732. }).catch(err => {
  733. swal('Error', 'Something went wrong. Please try again later.', 'error');
  734. });
  735. },
  736. deletePost(status) {
  737. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  738. return;
  739. }
  740. if(window.confirm('Are you sure you want to delete this post?') == false) {
  741. return;
  742. }
  743. axios.post('/i/delete', {
  744. type: 'status',
  745. item: status.id
  746. }).then(res => {
  747. this.feed = this.feed.filter(s => {
  748. return s.id != status.id;
  749. });
  750. this.$refs.ctxModal.hide();
  751. }).catch(err => {
  752. swal('Error', 'Something went wrong. Please try again later.', 'error');
  753. });
  754. },
  755. commentSubmit(status, $event) {
  756. let id = status.id;
  757. let comment = this.replyText;
  758. axios.post('/i/comment', {
  759. item: id,
  760. comment: comment
  761. }).then(res => {
  762. this.replyText = '';
  763. this.replies.push(res.data.entity);
  764. });
  765. },
  766. moderatePost(status, action, $event) {
  767. let username = status.account.username;
  768. switch(action) {
  769. case 'autocw':
  770. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  771. swal({
  772. title: 'Confirm',
  773. text: msg,
  774. icon: 'warning',
  775. buttons: true,
  776. dangerMode: true
  777. }).then(res => {
  778. if(res) {
  779. axios.post('/api/v2/moderator/action', {
  780. action: action,
  781. item_id: status.id,
  782. item_type: 'status'
  783. }).then(res => {
  784. swal('Success', 'Successfully enforced CW for ' + username, 'success');
  785. }).catch(err => {
  786. swal(
  787. 'Error',
  788. 'Something went wrong, please try again later.',
  789. 'error'
  790. );
  791. });
  792. }
  793. });
  794. break;
  795. case 'noautolink':
  796. msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
  797. swal({
  798. title: 'Confirm',
  799. text: msg,
  800. icon: 'warning',
  801. buttons: true,
  802. dangerMode: true
  803. }).then(res => {
  804. if(res) {
  805. axios.post('/api/v2/moderator/action', {
  806. action: action,
  807. item_id: status.id,
  808. item_type: 'status'
  809. }).then(res => {
  810. swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
  811. }).catch(err => {
  812. swal(
  813. 'Error',
  814. 'Something went wrong, please try again later.',
  815. 'error'
  816. );
  817. });
  818. }
  819. });
  820. break;
  821. case 'unlisted':
  822. msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
  823. swal({
  824. title: 'Confirm',
  825. text: msg,
  826. icon: 'warning',
  827. buttons: true,
  828. dangerMode: true
  829. }).then(res => {
  830. if(res) {
  831. axios.post('/api/v2/moderator/action', {
  832. action: action,
  833. item_id: status.id,
  834. item_type: 'status'
  835. }).then(res => {
  836. swal('Success', 'Successfully unlisted for ' + username, 'success');
  837. }).catch(err => {
  838. swal(
  839. 'Error',
  840. 'Something went wrong, please try again later.',
  841. 'error'
  842. );
  843. });
  844. }
  845. });
  846. break;
  847. case 'disable':
  848. msg = 'Are you sure you want to disable ' + username + '’s account ?';
  849. swal({
  850. title: 'Confirm',
  851. text: msg,
  852. icon: 'warning',
  853. buttons: true,
  854. dangerMode: true
  855. }).then(res => {
  856. if(res) {
  857. axios.post('/api/v2/moderator/action', {
  858. action: action,
  859. item_id: status.id,
  860. item_type: 'status'
  861. }).then(res => {
  862. swal('Success', 'Successfully disabled ' + username + '’s account', 'success');
  863. }).catch(err => {
  864. swal(
  865. 'Error',
  866. 'Something went wrong, please try again later.',
  867. 'error'
  868. );
  869. });
  870. }
  871. });
  872. break;
  873. case 'suspend':
  874. msg = 'Are you sure you want to suspend ' + username + '’s account ?';
  875. swal({
  876. title: 'Confirm',
  877. text: msg,
  878. icon: 'warning',
  879. buttons: true,
  880. dangerMode: true
  881. }).then(res => {
  882. if(res) {
  883. axios.post('/api/v2/moderator/action', {
  884. action: action,
  885. item_id: status.id,
  886. item_type: 'status'
  887. }).then(res => {
  888. swal('Success', 'Successfully suspend ' + username + '’s account', 'success');
  889. }).catch(err => {
  890. swal(
  891. 'Error',
  892. 'Something went wrong, please try again later.',
  893. 'error'
  894. );
  895. });
  896. }
  897. });
  898. break;
  899. }
  900. },
  901. followingModal() {
  902. if(this.following.length > 0) {
  903. this.$refs.followingModal.show();
  904. return;
  905. }
  906. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  907. params: {
  908. page: this.followingCursor
  909. }
  910. })
  911. .then(res => {
  912. this.following = res.data;
  913. this.followingCursor++;
  914. });
  915. if(res.data.length < 10) {
  916. this.followingMore = false;
  917. }
  918. this.$refs.followingModal.show();
  919. },
  920. followersModal() {
  921. if(this.followers.length > 0) {
  922. this.$refs.followerModal.show();
  923. return;
  924. }
  925. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  926. params: {
  927. page: this.followerCursor
  928. }
  929. })
  930. .then(res => {
  931. this.followers = res.data;
  932. this.followerCursor++;
  933. })
  934. if(res.data.length < 10) {
  935. this.followerMore = false;
  936. }
  937. this.$refs.followerModal.show();
  938. },
  939. followingLoadMore() {
  940. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  941. params: {
  942. page: this.followingCursor
  943. }
  944. })
  945. .then(res => {
  946. if(res.data.length > 0) {
  947. this.following.push(...res.data);
  948. this.followingCursor++;
  949. }
  950. if(res.data.length < 10) {
  951. this.followingMore = false;
  952. }
  953. });
  954. },
  955. followersLoadMore() {
  956. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  957. params: {
  958. page: this.followerCursor
  959. }
  960. })
  961. .then(res => {
  962. if(res.data.length > 0) {
  963. this.followers.push(...res.data);
  964. this.followerCursor++;
  965. }
  966. if(res.data.length < 10) {
  967. this.followerMore = false;
  968. }
  969. });
  970. },
  971. lightbox(status) {
  972. this.lightboxMedia = status.media_attachments[0];
  973. this.$refs.lightboxModal.show();
  974. },
  975. expLc(status) {
  976. if(this.config.ab.lc == false) {
  977. return true;
  978. }
  979. if(this.statusOwner(status) == true) {
  980. return true;
  981. }
  982. return false;
  983. },
  984. expRec() {
  985. return;
  986. if(this.config.ab.rec == false) {
  987. return;
  988. }
  989. axios.get('/api/local/exp/rec')
  990. .then(res => {
  991. this.suggestions = res.data;
  992. })
  993. },
  994. expRecFollow(id, index) {
  995. return;
  996. if(this.config.ab.rec == false) {
  997. return;
  998. }
  999. axios.post('/i/follow', {
  1000. item: id
  1001. }).then(res => {
  1002. this.suggestions.splice(index, 1);
  1003. }).catch(err => {
  1004. if(err.response.data.message) {
  1005. swal('Error', err.response.data.message, 'error');
  1006. }
  1007. });
  1008. },
  1009. followAction(status) {
  1010. let id = status.account.id;
  1011. axios.post('/i/follow', {
  1012. item: id
  1013. }).then(res => {
  1014. this.feed.forEach(s => {
  1015. if(s.account.id == id) {
  1016. s.account.relationship.following = !s.account.relationship.following;
  1017. }
  1018. });
  1019. let username = status.account.acct;
  1020. if(status.account.relationship.following) {
  1021. swal('Follow successful!', 'You are now following ' + username, 'success');
  1022. } else {
  1023. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1024. }
  1025. }).catch(err => {
  1026. if(err.response.data.message) {
  1027. swal('Error', err.response.data.message, 'error');
  1028. }
  1029. });
  1030. },
  1031. owner(status) {
  1032. return this.profile.id === status.account.id;
  1033. },
  1034. admin() {
  1035. return this.profile.is_admin == true;
  1036. },
  1037. ownerOrAdmin(status) {
  1038. return this.owner(status) || this.admin();
  1039. },
  1040. hideSuggestions() {
  1041. localStorage.setItem('pf_metro_ui.exp.rec', false);
  1042. this.showSuggestions = false;
  1043. },
  1044. emojiReaction(status) {
  1045. let em = event.target.innerText;
  1046. if(this.replyText.length == 0) {
  1047. this.replyText = em + ' ';
  1048. $('textarea[name="comment"]').focus();
  1049. } else {
  1050. this.replyText += em + ' ';
  1051. $('textarea[name="comment"]').focus();
  1052. }
  1053. },
  1054. refreshSuggestions() {
  1055. return;
  1056. let el = event.target.parentNode;
  1057. if(el.classList.contains('disabled') == true) {
  1058. return;
  1059. }
  1060. axios.get('/api/local/exp/rec', {
  1061. params: {
  1062. refresh: true
  1063. }
  1064. })
  1065. .then(res => {
  1066. this.suggestions = res.data;
  1067. if (el.classList) {
  1068. el.classList.add('disabled');
  1069. el.classList.add('text-light');
  1070. }
  1071. else {
  1072. el.className += ' ' + 'disabled text-light';
  1073. }
  1074. setTimeout(function() {
  1075. el.setAttribute('href', '#');
  1076. if (el.classList) {
  1077. el.classList.remove('disabled');
  1078. el.classList.remove('text-light');
  1079. }
  1080. else {
  1081. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1082. }
  1083. }, 10000);
  1084. });
  1085. },
  1086. fetchHashtagPosts() {
  1087. axios.get('/api/local/discover/tag/list')
  1088. .then(res => {
  1089. let tags = res.data;
  1090. if(tags.length == 0) {
  1091. return;
  1092. }
  1093. let hashtag = tags[0];
  1094. this.hashtagPostsName = hashtag;
  1095. axios.get('/api/v2/discover/tag', {
  1096. params: {
  1097. hashtag: hashtag
  1098. }
  1099. }).then(res => {
  1100. if(res.data.tags.length) {
  1101. this.showHashtagPosts = true;
  1102. this.hashtagPosts = res.data.tags.splice(0,3);
  1103. }
  1104. })
  1105. })
  1106. },
  1107. ctxMenu(status) {
  1108. this.ctxMenuStatus = status;
  1109. // let payload = '<div class="pixlfed-media" data-id="'+ this.ctxMenuStatus.id + '"></div><script ';
  1110. // payload += 'src="https://pixelfed.dev/js/embed.js" async><';
  1111. // payload += '/script>';
  1112. // this.ctxEmbedPayload = payload;
  1113. if(status.account.id == this.profile.id) {
  1114. this.$refs.ctxModal.show();
  1115. } else {
  1116. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1117. params: {
  1118. 'id[]': status.account.id
  1119. }
  1120. }).then(res => {
  1121. this.ctxMenuRelationship = res.data[0];
  1122. this.$refs.ctxModal.show();
  1123. });
  1124. }
  1125. },
  1126. closeCtxMenu(truncate) {
  1127. this.copiedEmbed = false;
  1128. this.ctxMenuStatus = false;
  1129. this.ctxMenuRelationship = false;
  1130. this.$refs.ctxModal.hide();
  1131. },
  1132. ctxMenuCopyLink() {
  1133. let status = this.ctxMenuStatus;
  1134. navigator.clipboard.writeText(status.url);
  1135. this.closeCtxMenu();
  1136. return;
  1137. },
  1138. ctxMenuGoToPost() {
  1139. let status = this.ctxMenuStatus;
  1140. window.location.href = status.url;
  1141. this.closeCtxMenu();
  1142. return;
  1143. },
  1144. ctxMenuFollow() {
  1145. let id = this.ctxMenuStatus.account.id;
  1146. axios.post('/i/follow', {
  1147. item: id
  1148. }).then(res => {
  1149. this.feed.forEach(s => {
  1150. if(s.account.id == id) {
  1151. s.account.relationship.following = !s.account.relationship.following;
  1152. }
  1153. });
  1154. let username = this.ctxMenuStatus.account.acct;
  1155. this.closeCtxMenu();
  1156. setTimeout(function() {
  1157. swal('Follow successful!', 'You are now following ' + username, 'success');
  1158. }, 500);
  1159. });
  1160. },
  1161. ctxMenuUnfollow() {
  1162. let id = this.ctxMenuStatus.account.id;
  1163. axios.post('/i/follow', {
  1164. item: id
  1165. }).then(res => {
  1166. this.feed.forEach(s => {
  1167. if(s.account.id == id) {
  1168. s.account.relationship.following = !s.account.relationship.following;
  1169. }
  1170. });
  1171. let username = this.ctxMenuStatus.account.acct;
  1172. if(this.scope == 'home') {
  1173. this.feed = this.feed.filter(s => {
  1174. return s.account.id != this.ctxMenuStatus.account.id;
  1175. });
  1176. }
  1177. this.closeCtxMenu();
  1178. setTimeout(function() {
  1179. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1180. }, 500);
  1181. });
  1182. },
  1183. ctxMenuReportPost() {
  1184. window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id;
  1185. },
  1186. ctxMenuEmbed() {
  1187. this.$refs.ctxModal.hide();
  1188. this.$refs.ctxEmbedModal.show();
  1189. },
  1190. ctxMenuShare() {
  1191. this.$refs.ctxModal.hide();
  1192. this.$refs.ctxShareModal.show();
  1193. },
  1194. closeCtxShareMenu() {
  1195. this.$refs.ctxShareModal.hide();
  1196. this.$refs.ctxModal.show();
  1197. },
  1198. ctxCopyEmbed() {
  1199. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1200. this.$refs.ctxEmbedModal.hide();
  1201. },
  1202. ctxModMenuShow() {
  1203. this.$refs.ctxModal.hide();
  1204. this.$refs.ctxModModal.show();
  1205. },
  1206. ctxModMenu() {
  1207. this.$refs.ctxModal.hide();
  1208. },
  1209. ctxModMenuClose() {
  1210. this.$refs.ctxModal.hide();
  1211. this.$refs.ctxModModal.hide();
  1212. },
  1213. hideTips() {
  1214. this.showTips = false;
  1215. window.localStorage.setItem('metro-tips', false);
  1216. }
  1217. }
  1218. }
  1219. </script>