Timeline.vue 47 KB

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