Timeline.vue 48 KB

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