Timeline.vue 47 KB

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