Timeline.vue 58 KB

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