Timeline.vue 77 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226
  1. <template>
  2. <div>
  3. <div v-if="currentLayout === 'feed'" class="container">
  4. <div class="row">
  5. <div v-if="morePostsAvailable == true" class="col-12 mt-5 pt-3 mb-3 fixed-top">
  6. <p class="text-center">
  7. <button class="btn btn-dark px-4 rounded-pill font-weight-bold shadow" @click="syncNewPosts">Load New Posts</button>
  8. </p>
  9. </div>
  10. <div class="d-none col-12 pl-3 pl-md-0 pt-3 pl-0">
  11. <div class="d-none d-md-flex justify-content-between align-items-center">
  12. <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>
  13. <p class="mb-0">
  14. <span class="btn-group">
  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('feed')"><i class="fas fa-list"></i></a>
  16. <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>
  17. </span>
  18. </p>
  19. <p class="mb-0 d-none d-md-block">
  20. <a class="btn btn-block btn-primary btn-sm font-weight-bold" href="/i/compose" data-toggle="modal" data-target="#composeModal">
  21. New Post
  22. </a>
  23. </p>
  24. </div>
  25. <hr>
  26. </div>
  27. <div class="col-md-8 col-lg-8 px-0 mb-sm-3 timeline order-2 order-md-1">
  28. <div style="margin-top:-2px;">
  29. <story-component v-if="config.features.stories"></story-component>
  30. </div>
  31. <div>
  32. <div v-if="loading" class="text-center" style="padding-top:10px;">
  33. <div class="spinner-border" role="status">
  34. <span class="sr-only">Loading...</span>
  35. </div>
  36. </div>
  37. <div :data-status-id="status.id" v-for="(status, index) in feed" :key="`${index}-${status.id}`">
  38. <div v-if="index == 0 && showTips && !loading" class="my-4 card-tips">
  39. <announcements-card v-on:show-tips="showTips = $event"></announcements-card>
  40. </div>
  41. <div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  42. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  43. <h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
  44. <span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
  45. </div>
  46. <div class="card-body row mx-0">
  47. <div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
  48. <div class="card">
  49. <div class="card-body text-center pt-3">
  50. <p class="mb-0">
  51. <a :href="'/'+rec.username">
  52. <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">
  53. </a>
  54. </p>
  55. <div class="py-3">
  56. <p class="font-weight-bold text-dark cursor-pointer mb-0">
  57. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  58. {{rec.username}}
  59. </a>
  60. </p>
  61. <p class="small text-muted mb-0">{{rec.message}}</p>
  62. </div>
  63. <p class="mb-0">
  64. <a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  65. </p>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. <div v-if="index == 4 && showHashtagPosts && hashtagPosts.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  72. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  73. <span></span>
  74. <h6 class="text-muted font-weight-bold mb-0"><a :href="'/discover/tags/'+hashtagPostsName+'?src=tr'">#{{hashtagPostsName}}</a></h6>
  75. <span class="cursor-pointer text-muted" v-on:click="showHashtagPosts = false"><i class="fas fa-times"></i></span>
  76. </div>
  77. <div class="card-body row mx-0">
  78. <div v-for="(tag, index) in hashtagPosts" class="col-4 p-0 p-sm-2 p-md-3 hashtag-post-square">
  79. <a class="card info-overlay card-md-border-0" :href="tag.status.url">
  80. <div :class="[tag.status.filter ? 'square ' + tag.status.filter : 'square']">
  81. <div v-if="tag.status.sensitive" class="square-content">
  82. <div class="info-overlay-text-label">
  83. <h5 class="text-white m-auto font-weight-bold">
  84. <span>
  85. <span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
  86. </span>
  87. </h5>
  88. </div>
  89. <blur-hash-canvas
  90. width="32"
  91. height="32"
  92. :hash="tag.status.media_attachments[0].blurhash"
  93. />
  94. </div>
  95. <div v-else class="square-content">
  96. <blur-hash-image
  97. width="32"
  98. height="32"
  99. :hash="tag.status.media_attachments[0].blurhash"
  100. :src="tag.status.media_attachments[0].preview_url"
  101. />
  102. </div>
  103. <div class="info-overlay-text">
  104. <h5 class="text-white m-auto font-weight-bold">
  105. <span class="pr-4">
  106. <span class="far fa-heart fa-lg pr-1"></span> {{formatCount(tag.status.favourites_count)}}
  107. </span>
  108. <span>
  109. <span class="far fa-comment fa-lg pr-1"></span> {{formatCount(tag.status.reply_count)}}
  110. </span>
  111. </h5>
  112. </div>
  113. </div>
  114. </a>
  115. </div>
  116. </div>
  117. </div>
  118. <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'">
  119. <div v-if="status" class="card-header d-inline-flex align-items-center bg-white">
  120. <!-- <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'"> -->
  121. <!-- <div v-if="hasStory" class="has-story has-story-sm cursor-pointer shadow-sm" @click="profileUrl(status)">
  122. <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'">
  123. </div>
  124. <div v-else> -->
  125. <div>
  126. <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">
  127. </div>
  128. <div class="pl-2">
  129. <!-- <a class="d-block username font-weight-bold text-dark" v-bind:href="status.account.url" style="line-height:0.5;"> -->
  130. <a class="username font-weight-bold text-dark text-decoration-none text-break" v-bind:href="profileUrl(status)" v-html="statusCardUsernameFormat(status)">
  131. Loading...
  132. </a>
  133. <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;">
  134. <i class="fas fa-certificate text-danger fa-stack-1x"></i>
  135. <i class="fas fa-crown text-white fa-sm fa-stack-1x" style="font-size:7px;"></i>
  136. </span>
  137. <!-- <span v-if="scope != 'home' && status.account.id != profile.id && status.account.relationship">
  138. <span class="px-1">•</span>
  139. <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>
  140. </span> -->
  141. <!-- <span v-if="status.account.id != profile.id">
  142. <span class="px-1">•</span>
  143. <span class="font-weight-bold cursor-pointer text-primary">Follow</span>
  144. </span> -->
  145. <div class="d-flex align-items-center">
  146. <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>
  147. </div>
  148. </div>
  149. <div class="text-right" style="flex-grow:1;">
  150. <button class="btn btn-link text-dark py-0" type="button" @click="ctxMenu(status)">
  151. <span class="fas fa-ellipsis-h text-lighter"></span>
  152. <span class="sr-only">Post Menu</span>
  153. </button>
  154. </div>
  155. </div>
  156. <div class="postPresenterContainer" style="background: #000;">
  157. <div v-if="config.ab.top && status.pf_type === 'text'" class="w-100">
  158. <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;">
  159. <div class="w-100 h-100 d-flex justify-content-center align-items-center">
  160. <p class="text-center text-break h3 px-5 font-weight-bold" v-html="status.content"></p>
  161. </div>
  162. </div>
  163. </div>
  164. <div v-else-if="status.pf_type === 'photo'" class="w-100">
  165. <photo-presenter :status="status" v-on:lightbox="lightbox" v-on:togglecw="status.sensitive = false"></photo-presenter>
  166. </div>
  167. <div v-else-if="status.pf_type === 'video'" class="w-100">
  168. <video-presenter :status="status"></video-presenter>
  169. </div>
  170. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  171. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  172. </div>
  173. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  174. <video-album-presenter :status="status"></video-album-presenter>
  175. </div>
  176. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  177. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  178. </div>
  179. <div v-else class="w-100">
  180. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  181. </div>
  182. </div>
  183. <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()">
  184. <p class="font-weight-bold d-flex justify-content-between align-items-center mb-0">
  185. <span>
  186. <i class="fas fa-info-circle mr-2"></i>
  187. For information about COVID-19, {{config.features.label.covid.org}}
  188. </span>
  189. <span>
  190. <i class="fas fa-chevron-right text-lighter"></i>
  191. </span>
  192. </p>
  193. </div>
  194. <div class="card-body">
  195. <div class="reactions my-1 pb-2">
  196. <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>
  197. <h3 v-else class="far fa-heart pr-3 m-0 like-btn text-dark cursor-pointer" title="Like" v-on:click="likeStatus(status, $event);"></h3>
  198. <h3 v-if="!status.comments_disabled" class="far fa-comment text-dark pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
  199. <!-- <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-dark share-btn cursor-pointer']" title="Share" v-on:click="shareStatus(status, $event)"></h3> -->
  200. <!-- <h3 class="fas fa-expand pr-3 m-0 cursor-pointer text-dark" v-on:click="lightbox(status)"></h3> -->
  201. <span v-if="status.taggedPeople.length" class="float-right">
  202. <span class="font-weight-light small" style="color:#718096">
  203. <i class="far fa-user" data-toggle="tooltip" title="Tagged People"></i>
  204. <span v-for="(tag, index) in status.taggedPeople" class="mr-n2">
  205. <a :href="'/'+tag.username">
  206. <img :src="tag.avatar" width="20px" height="20px" class="border rounded-circle" data-toggle="tooltip" :title="'@'+tag.username" alt="Avatar">
  207. </a>
  208. </span>
  209. </span>
  210. </span>
  211. </div>
  212. <div class="likes font-weight-bold" v-if="expLc(status) == true">
  213. <span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
  214. </div>
  215. <div v-if="status.pf_type != 'text'" class="caption">
  216. <p v-if="!status.sensitive" class="mb-2 read-more" style="overflow: hidden;">
  217. <span class="username font-weight-bold">
  218. <bdi><a class="text-dark" :href="profileUrl(status)">{{status.account.username}}</a></bdi>
  219. </span>
  220. <span class="status-content" v-html="status.content"></span>
  221. </p>
  222. </div>
  223. <!-- <div class="comments" v-if="status.id == replyId && !status.comments_disabled">
  224. <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">
  225. <span>
  226. <a class="text-dark font-weight-bold mr-1" :href="profileUrl(reply)">{{reply.account.username}}</a>
  227. <span v-html="reply.content" style="word-break: break-all;" class="comment-body"></span>
  228. </span>
  229. <span class="mb-0" style="min-width:38px">
  230. <span v-on:click="likeStatus(reply, $event);">
  231. <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>
  232. </span>
  233. <!-- <post-menu :status="reply" :profile="profile" size="sm" :modal="'true'" :feed="feed" class="d-inline-flex pl-2"></post-menu> - ->
  234. <span class="text-lighter pl-2 cursor-pointer" @click="ctxMenu(reply)">
  235. <span class="fas fa-ellipsis-v text-lighter"></span>
  236. </span>
  237. </span>
  238. </p>
  239. </div> -->
  240. <div class="timestamp mt-2">
  241. <p class="small text-uppercase mb-0">
  242. <a :href="statusUrl(status)" class="text-muted">
  243. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  244. </a>
  245. </p>
  246. </div>
  247. </div>
  248. <!--<div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white px-2 py-0">
  249. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  250. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  251. </ul>
  252. </div>-->
  253. <!--<div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white sticky-md-bottom p-0">
  254. <form class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="status.id" data-truncate="false">
  255. <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>
  256. <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" />
  257. </form>
  258. </div>-->
  259. </div>
  260. </div>
  261. <div v-if="!loading && feed.length">
  262. <div class="card shadow-none">
  263. <div class="card-body">
  264. <infinite-loading @infinite="infiniteTimeline" :distance="800">
  265. <div slot="no-more" class="font-weight-bold">No more posts to load</div>
  266. <div slot="no-results" class="font-weight-bold">No more posts to load</div>
  267. </infinite-loading>
  268. </div>
  269. </div>
  270. </div>
  271. <div v-if="!loading && scope == 'home' && feed.length == 0">
  272. <div class="card shadow-none border">
  273. <div class="card-body text-center">
  274. <p class="h2 font-weight-lighter p-5">Hello, {{profile.acct}}</p>
  275. <p class="text-lighter"><i class="fas fa-camera-retro fa-5x"></i></p>
  276. <p class="h3 font-weight-lighter p-5">Start following people to build your timeline.</p>
  277. <p><a href="/discover" class="btn btn-primary font-weight-bold py-0">Discover new people and posts</a></p>
  278. </div>
  279. </div>
  280. </div>
  281. </div>
  282. </div>
  283. <div class="col-md-4 col-lg-4 my-4 order-1 order-md-2 d-none d-md-block">
  284. <div>
  285. <!-- <div class="mb-4">
  286. <a class="btn btn-block btn-primary btn-sm font-weight-bold mb-3 border" href="/i/compose" data-toggle="modal" data-target="#composeModal">
  287. <i class="far fa-plus-square pr-3 fa-lg pt-1"></i> New Post
  288. </a>
  289. </div> -->
  290. <div class="mb-4">
  291. <div v-show="!loading" class="">
  292. <div class="pb-2">
  293. <div class="media d-flex align-items-center">
  294. <a :href="!userStory ? profile.url : '/stories/' + profile.acct" class="mr-3">
  295. <!-- <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'"> -->
  296. <div v-if="userStory" class="has-story cursor-pointer shadow-sm" @click="storyRedirect()">
  297. <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">
  298. </div>
  299. <div v-else>
  300. <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">
  301. </div>
  302. </a>
  303. <div class="media-body d-flex justify-content-between word-break" >
  304. <div>
  305. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
  306. <p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
  307. </div>
  308. <div class="ml-2">
  309. <a class="text-muted" href="/settings/home">
  310. <i class="fas fa-cog fa-lg"></i>
  311. <span class="sr-only">User Settings</span>
  312. </a>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. <!-- <div class="card-footer bg-transparent border-top mt-2 py-1">
  318. <div class="d-flex justify-content-between text-center">
  319. <span class="cursor-pointer" @click="redirect(profile.url)">
  320. <p class="mb-0 font-weight-bold">{{formatCount(profile.statuses_count)}}</p>
  321. <p class="mb-0 small text-muted">Posts</p>
  322. </span>
  323. <span class="cursor-pointer" @click="redirect(profile.url+'?md=followers')">
  324. <p class="mb-0 font-weight-bold">{{formatCount(profile.followers_count)}}</p>
  325. <p class="mb-0 small text-muted">Followers</p>
  326. </span>
  327. <span class="cursor-pointer" @click="redirect(profile.url+'?md=following')">
  328. <p class="mb-0 font-weight-bold">{{formatCount(profile.following_count)}}</p>
  329. <p class="mb-0 small text-muted">Following</p>
  330. </span>
  331. </div>
  332. </div> -->
  333. </div>
  334. </div>
  335. <div v-show="modes.notify == true && !loading" class="mb-4">
  336. <notification-card></notification-card>
  337. </div>
  338. <div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
  339. <div class="card shadow-none border">
  340. <div class="card-header bg-white d-flex align-items-center justify-content-between">
  341. <a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
  342. <div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
  343. <div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
  344. </div>
  345. <div class="card-body pt-0">
  346. <div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
  347. <a :href="'/'+rec.username">
  348. <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">
  349. </a>
  350. <div class="media-body">
  351. <p class="mb-0 font-weight-bold small">
  352. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  353. {{rec.username}}
  354. </a>
  355. </p>
  356. <p class="mb-0 small text-muted">{{rec.message}}</p>
  357. </div>
  358. <a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  359. </div>
  360. </div>
  361. </div>
  362. </div>
  363. <footer>
  364. <div class="container pb-5">
  365. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  366. <a href="/site/about" class="text-dark pr-2">About</a>
  367. <a href="/site/help" class="text-dark pr-2">Help</a>
  368. <a href="/site/language" class="text-dark pr-2">Language</a>
  369. <a href="/discover/profiles" class="text-dark pr-2">Profiles</a>
  370. <a href="/discover/places" class="text-dark pr-2">Places</a>
  371. <a href="/site/privacy" class="text-dark pr-2">Privacy</a>
  372. <a href="/site/terms" class="text-dark pr-2">Terms</a>
  373. </p>
  374. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  375. <a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by Pixelfed</a>
  376. </p>
  377. </div>
  378. </footer>
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. <div v-if="currentLayout === 'comments'" class="container p-0 overflow-hidden">
  384. <div class="row">
  385. <div class="col-12 col-md-6 offset-md-3">
  386. <div class="card shadow-none border" style="height:100vh;">
  387. <div class="card-header d-flex justify-content-between align-items-center">
  388. <div
  389. @click="commentNavigateBack(status.id)"
  390. class="cursor-pointer"
  391. >
  392. <i class="fas fa-chevron-left fa-lg px-2"></i>
  393. </div>
  394. <div>
  395. <p class="font-weight-bold mb-0 h5">Comments</p>
  396. </div>
  397. <div>
  398. <i class="fas fa-cog fa-lg text-white"></i>
  399. </div>
  400. </div>
  401. <div class="card-body" style="overflow-y: auto !important">
  402. <div class="media">
  403. <img :src="status.account.avatar" class="rounded-circle border mr-3" width="32px" height="32px">
  404. <div class="media-body">
  405. <p class="d-flex justify-content-between align-items-top mb-0" style="overflow-y: hidden;">
  406. <span class="mr-2" style="font-size: 13px;">
  407. <a class="text-dark font-weight-bold mr-1 text-break" :href="status.account.url" v-bind:title="status.account.username">{{trimCaption(status.account.username,15)}}</a>
  408. <span class="text-break comment-body" style="word-break: break-all;" v-html="status.content"></span>
  409. </span>
  410. </p>
  411. </div>
  412. </div>
  413. <hr>
  414. <div class="postCommentsLoader text-center py-2">
  415. <div class="spinner-border" role="status">
  416. <span class="sr-only">Loading...</span>
  417. </div>
  418. </div>
  419. <div class="postCommentsContainer d-none">
  420. <p v-if="replies.length" class="mb-1 text-center load-more-link my-4">
  421. <a
  422. href="#"
  423. class="text-dark"
  424. title="Load more comments"
  425. @click.prevent="loadMoreComments"
  426. >
  427. <svg class="bi bi-plus-circle" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="font-size:2em;"> <path fill-rule="evenodd" d="M8 3.5a.5.5 0 01.5.5v4a.5.5 0 01-.5.5H4a.5.5 0 010-1h3.5V4a.5.5 0 01.5-.5z" clip-rule="evenodd"/> <path fill-rule="evenodd" d="M7.5 8a.5.5 0 01.5-.5h4a.5.5 0 010 1H8.5V12a.5.5 0 01-1 0V8z" clip-rule="evenodd"/> <path fill-rule="evenodd" d="M8 15A7 7 0 108 1a7 7 0 000 14zm0 1A8 8 0 108 0a8 8 0 000 16z" clip-rule="evenodd"/></svg>
  428. </a>
  429. </p>
  430. <div v-for="(reply, index) in replies" class="pb-3 media" :key="'tl' + reply.id + '_' + index">
  431. <img :src="reply.account.avatar" class="rounded-circle border mr-3" width="32px" height="32px">
  432. <div class="media-body">
  433. <div v-if="reply.sensitive == true">
  434. <span class="py-3">
  435. <a class="text-dark font-weight-bold mr-3" style="font-size: 13px;" :href="reply.account.url" v-bind:title="reply.account.username">{{trimCaption(reply.account.username,15)}}</a>
  436. <span class="text-break" style="font-size: 13px;">
  437. <span class="font-italic text-muted">This comment may contain sensitive material</span>
  438. <span class="text-primary cursor-pointer pl-1" @click="reply.sensitive = false;">Show</span>
  439. </span>
  440. </span>
  441. </div>
  442. <div v-else>
  443. <p class="d-flex justify-content-between align-items-top read-more mb-0" style="overflow-y: hidden;">
  444. <span class="mr-3" style="font-size: 13px;">
  445. <a class="text-dark font-weight-bold mr-1 text-break" :href="reply.account.url" v-bind:title="reply.account.username">{{trimCaption(reply.account.username,15)}}</a>
  446. <span class="text-break comment-body" style="word-break: break-all;" v-html="reply.content"></span>
  447. </span>
  448. <span class="text-right" style="min-width: 30px;">
  449. <span v-on:click="likeReply(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  450. <span class="pl-2 text-lighter cursor-pointer" @click="ctxMenu(reply)">
  451. <span class="fas fa-ellipsis-v text-lighter"></span>
  452. </span>
  453. <!-- <post-menu :status="reply" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block px-2" v-on:deletePost=""></post-menu> -->
  454. </span>
  455. </p>
  456. <p class="mb-0">
  457. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(reply.created_at)" :href="reply.url"></a>
  458. <span v-if="reply.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3 small">{{reply.favourites_count == 1 ? '1 like' : reply.favourites_count + ' likes'}}</span>
  459. <span class="small text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply, index, true)">Reply</span>
  460. </p>
  461. <div v-if="reply.reply_count > 0" class="cursor-pointer pb-2" v-on:click="toggleReplies(reply)">
  462. <span class="show-reply-bar"></span>
  463. <span class="comment-reaction small font-weight-bold">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
  464. </div>
  465. <div v-if="reply.thread == true" class="comment-thread">
  466. <div v-for="(s, sindex) in reply.replies" class="py-1 media" :key="'cr' + s.id + '_' + index">
  467. <img :src="s.account.avatar" class="rounded-circle border mr-3" width="25px" height="25px">
  468. <div class="media-body">
  469. <p class="d-flex justify-content-between align-items-top read-more mb-0" style="overflow-y: hidden;">
  470. <span class="mr-2" style="font-size: 13px;">
  471. <a class="text-dark font-weight-bold mr-1" :href="s.account.url" :title="s.account.username">{{s.account.username}}</a>
  472. <span class="text-break comment-body" style="word-break: break-all;" v-html="s.content"></span>
  473. </span>
  474. <span>
  475. <span v-on:click="likeReply(s, $event)"><i v-bind:class="[s.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  476. <!-- <post-menu :status="s" :profile="user" :size="'sm'" :modal="'true'" class="d-inline-block pl-2" v-on:deletePost="deleteCommentReply(s.id, sindex, index) "></post-menu> -->
  477. </span>
  478. </p>
  479. <p class="mb-0">
  480. <a v-once class="text-muted mr-3 text-decoration-none small" style="width: 20px;" v-text="timeAgo(s.created_at)" :href="s.url"></a>
  481. <span v-if="s.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{s.favourites_count == 1 ? '1 like' : s.favourites_count + ' likes'}}</span>
  482. </p>
  483. </div>
  484. </div>
  485. </div>
  486. </div>
  487. </div>
  488. </div>
  489. <div v-if="!replies.length">
  490. <p class="text-center text-muted font-weight-bold small">No comments yet</p>
  491. </div>
  492. </div>
  493. </div>
  494. <div class="card-footer mb-3">
  495. <div class="align-middle d-flex">
  496. <img
  497. :src="profile.avatar"
  498. width="36"
  499. height="36"
  500. class="rounded-circle border mr-3">
  501. <textarea
  502. class="form-control rounded-pill"
  503. name="comment"
  504. placeholder="Add a comment…"
  505. autocomplete="off"
  506. autocorrect="off"
  507. rows="1"
  508. maxlength="0"
  509. style="resize: none;overflow-y: hidden"
  510. @click="replyFocus(status)">
  511. </textarea>
  512. </div>
  513. </div>
  514. </div>
  515. </div>
  516. </div>
  517. </div>
  518. <div class="modal-stack">
  519. <b-modal ref="ctxModal"
  520. id="ctx-modal"
  521. hide-header
  522. hide-footer
  523. centered
  524. rounded
  525. size="sm"
  526. body-class="list-group-flush p-0 rounded">
  527. <div class="list-group text-center">
  528. <!-- <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>
  529. <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> -->
  530. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuGoToPost()">View Post</div>
  531. <!-- <div v-if="ctxMenuStatus && ctxMenuStatus.local == true && !ctxMenuStatus.in_reply_to_id" class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
  532. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div> -->
  533. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuShare()">Share</div>
  534. <div v-if="ctxMenuStatus && profile && profile.is_admin == true" class="list-group-item rounded cursor-pointer" @click="ctxModMenuShow()">Moderation Tools</div>
  535. <div v-if="ctxMenuStatus && ctxMenuStatus.account.id != profile.id" class="list-group-item rounded cursor-pointer text-danger" @click="ctxMenuReportPost()">Report</div>
  536. <div v-if="ctxMenuStatus && (profile.is_admin || profile.id == ctxMenuStatus.account.id)" class="list-group-item rounded cursor-pointer text-danger" @click="deletePost(ctxMenuStatus)">Delete</div>
  537. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxMenu()">Cancel</div>
  538. </div>
  539. </b-modal>
  540. <b-modal ref="ctxModModal"
  541. id="ctx-mod-modal"
  542. hide-header
  543. hide-footer
  544. centered
  545. rounded
  546. size="sm"
  547. body-class="list-group-flush p-0 rounded">
  548. <div class="list-group text-center">
  549. <p class="py-2 px-3 mb-0">
  550. <div class="text-center font-weight-bold text-danger">Moderation Tools</div>
  551. <div class="small text-center text-muted">Select one of the following options</div>
  552. </p>
  553. <div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div>
  554. <div v-if="ctxMenuStatus.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'remcw')">Remove Content Warning</div>
  555. <div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'addcw')">Add Content Warning</div>
  556. <!-- <div class="list-group-item rounded cursor-pointer" @click="ctxModOtherMenuShow()">Other</div> -->
  557. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
  558. </div>
  559. </b-modal>
  560. <b-modal ref="ctxModOtherModal"
  561. id="ctx-mod-other-modal"
  562. hide-header
  563. hide-footer
  564. centered
  565. rounded
  566. size="sm"
  567. body-class="list-group-flush p-0 rounded">
  568. <div class="list-group text-center">
  569. <p class="py-2 px-3 mb-0">
  570. <div class="text-center font-weight-bold text-danger">Moderation Tools</div>
  571. <div class="small text-center text-muted">Select one of the following options</div>
  572. </p>
  573. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="confirmModal()">Unlist Posts</div>
  574. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="confirmModal()">Moderation Log</div>
  575. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModOtherMenuClose()">Cancel</div>
  576. </div>
  577. </b-modal>
  578. <b-modal ref="ctxShareModal"
  579. id="ctx-share-modal"
  580. title="Share"
  581. hide-footer
  582. hide-header
  583. centered
  584. rounded
  585. size="sm"
  586. body-class="list-group-flush p-0 rounded text-center">
  587. <div class="list-group-item rounded cursor-pointer" @click="shareStatus(ctxMenuStatus, $event)">{{ctxMenuStatus.reblogged ? 'Unshare' : 'Share'}} to Followers</div>
  588. <div class="list-group-item rounded cursor-pointer" @click="ctxMenuCopyLink()">Copy Link</div>
  589. <div v-if="ctxMenuStatus && ctxMenuStatus.local == true && !ctxMenuStatus.in_reply_to_id" class="list-group-item rounded cursor-pointer" @click="ctxMenuEmbed()">Embed</div>
  590. <!-- <div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
  591. <div class="list-group-item rounded cursor-pointer">Facebook</div>
  592. <div class="list-group-item rounded cursor-pointer">Mastodon</div>
  593. <div class="list-group-item rounded cursor-pointer">Pinterest</div>
  594. <div class="list-group-item rounded cursor-pointer">Pixelfed</div>
  595. <div class="list-group-item rounded cursor-pointer">Twitter</div>
  596. <div class="list-group-item rounded cursor-pointer">VK</div> -->
  597. <div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
  598. </b-modal>
  599. <b-modal ref="ctxEmbedModal"
  600. id="ctx-embed-modal"
  601. hide-header
  602. hide-footer
  603. centered
  604. rounded
  605. size="md"
  606. body-class="p-2 rounded">
  607. <div>
  608. <div class="form-group">
  609. <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>
  610. </div>
  611. <div class="form-group pl-2 d-flex justify-content-center">
  612. <div class="form-check mr-3">
  613. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowCaption" :disabled="ctxEmbedCompactMode == true">
  614. <label class="form-check-label font-weight-light">
  615. Show Caption
  616. </label>
  617. </div>
  618. <div class="form-check mr-3">
  619. <input class="form-check-input" type="checkbox" v-model="ctxEmbedShowLikes" :disabled="ctxEmbedCompactMode == true">
  620. <label class="form-check-label font-weight-light">
  621. Show Likes
  622. </label>
  623. </div>
  624. <div class="form-check">
  625. <input class="form-check-input" type="checkbox" v-model="ctxEmbedCompactMode">
  626. <label class="form-check-label font-weight-light">
  627. Compact Mode
  628. </label>
  629. </div>
  630. </div>
  631. <hr>
  632. <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>
  633. <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>
  634. </div>
  635. </b-modal>
  636. <b-modal ref="ctxReport"
  637. id="ctx-report"
  638. hide-header
  639. hide-footer
  640. centered
  641. rounded
  642. size="sm"
  643. body-class="list-group-flush p-0 rounded">
  644. <p class="py-2 px-3 mb-0">
  645. <div class="text-center font-weight-bold text-danger">Report</div>
  646. <div class="small text-center text-muted">Select one of the following options</div>
  647. </p>
  648. <div class="list-group text-center">
  649. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('spam')">Spam</div>
  650. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('sensitive')">Sensitive Content</div>
  651. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('abusive')">Abusive or Harmful</div>
  652. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="openCtxReportOtherMenu()">Other</div>
  653. <!-- <div class="list-group-item rounded cursor-pointer" @click="ctxReportMenuGoBack()">Go Back</div> -->
  654. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxReportMenuGoBack()">Cancel</div>
  655. </div>
  656. </b-modal>
  657. <b-modal ref="ctxReportOther"
  658. id="ctx-report-other"
  659. hide-header
  660. hide-footer
  661. centered
  662. rounded
  663. size="sm"
  664. body-class="list-group-flush p-0 rounded">
  665. <p class="py-2 px-3 mb-0">
  666. <div class="text-center font-weight-bold text-danger">Report</div>
  667. <div class="small text-center text-muted">Select one of the following options</div>
  668. </p>
  669. <div class="list-group text-center">
  670. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('underage')">Underage Account</div>
  671. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('copyright')">Copyright Infringement</div>
  672. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('impersonation')">Impersonation</div>
  673. <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('scam')">Scam or Fraud</div>
  674. <!-- <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('terrorism')">Terrorism Related</div> -->
  675. <!-- <div class="list-group-item rounded cursor-pointer font-weight-bold" @click="sendReport('other')">Other or Not listed</div> -->
  676. <!-- <div class="list-group-item rounded cursor-pointer" @click="ctxReportOtherMenuGoBack()">Go Back</div> -->
  677. <div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxReportOtherMenuGoBack()">Cancel</div>
  678. </div>
  679. </b-modal>
  680. <b-modal ref="ctxConfirm"
  681. id="ctx-confirm"
  682. hide-header
  683. hide-footer
  684. centered
  685. rounded
  686. size="sm"
  687. body-class="list-group-flush p-0 rounded">
  688. <div class="d-flex align-items-center justify-content-center py-3">
  689. <div>{{ this.confirmModalTitle }}</div>
  690. </div>
  691. <div class="d-flex border-top btn-group btn-group-block rounded-0" role="group">
  692. <button type="button" class="btn btn-outline-lighter border-left-0 border-top-0 border-bottom-0 border-right py-2" style="color: rgb(0,122,255) !important;" @click.prevent="confirmModalCancel()">Cancel</button>
  693. <button type="button" class="btn btn-outline-lighter border-0" style="color: rgb(0,122,255) !important;" @click.prevent="confirmModalConfirm()">Confirm</button>
  694. </div>
  695. </b-modal>
  696. <b-modal ref="lightboxModal"
  697. id="lightbox"
  698. hide-header
  699. hide-footer
  700. centered
  701. size="lg"
  702. body-class="p-0"
  703. >
  704. <div v-if="lightboxMedia" :class="lightboxMedia.filter_class" class="w-100 h-100">
  705. <img :src="lightboxMedia.url" style="max-height: 100%; max-width: 100%" alt="lightbox media">
  706. </div>
  707. </b-modal>
  708. <b-modal ref="replyModal"
  709. id="ctx-reply-modal"
  710. hide-footer
  711. centered
  712. rounded
  713. :title-html="replyStatus.account ? 'Reply to <span class=text-dark>' + replyStatus.account.username + '</span>' : ''"
  714. title-tag="p"
  715. title-class="font-weight-bold text-muted"
  716. size="md"
  717. body-class="p-2 rounded">
  718. <div>
  719. <vue-tribute :options="tributeSettings">
  720. <textarea
  721. class="form-control replyModalTextarea"
  722. rows="4"
  723. v-model="replyText">
  724. </textarea>
  725. </vue-tribute>
  726. <div class="border-top border-bottom my-2">
  727. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  728. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  729. </ul>
  730. </div>
  731. <div class="d-flex justify-content-between align-items-center">
  732. <div>
  733. <span class="pl-2 small text-muted font-weight-bold text-monospace">
  734. <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}}
  735. </span>
  736. </div>
  737. <div class="d-flex align-items-center">
  738. <div class="custom-control custom-switch mr-3">
  739. <input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replyNsfw">
  740. <label :class="[replyNsfw ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label>
  741. </div>
  742. <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">
  743. {{replySending == true ? 'POSTING' : 'POST'}}
  744. </button>
  745. </div>
  746. </div>
  747. </div>
  748. </b-modal>
  749. <b-modal ref="ctxStatusModal"
  750. id="ctx-status-modal"
  751. hide-header
  752. hide-footer
  753. centered
  754. rounded
  755. size="xl"
  756. body-class="list-group-flush p-0 m-0 rounded">
  757. <!-- <post-component
  758. v-if="ctxMenuStatus"
  759. :status-template="ctxMenuStatus.pf_type"
  760. :status-id="ctxMenuStatus.id"
  761. :status-username="ctxMenuStatus.account.username"
  762. :status-url="ctxMenuStatus.url"
  763. :status-profile-url="ctxMenuStatus.account.url"
  764. :status-avatar="ctxMenuStatus.account.avatar"
  765. :status-profile-id="ctxMenuStatus.account.id"
  766. profile-layout="metro">
  767. </post-component> -->
  768. </b-modal>
  769. </div>
  770. </div>
  771. </template>
  772. <script type="text/javascript">
  773. import VueTribute from 'vue-tribute'
  774. export default {
  775. props: ['scope', 'layout'],
  776. components: {
  777. VueTribute
  778. },
  779. data() {
  780. return {
  781. ids: [],
  782. config: window.App.config,
  783. page: 2,
  784. feed: [],
  785. profile: {},
  786. min_id: 0,
  787. max_id: 0,
  788. suggestions: {},
  789. loading: true,
  790. replies: [],
  791. replyId: null,
  792. modes: {
  793. 'mod': false,
  794. 'dark': false,
  795. 'notify': true,
  796. 'distractionFree': false
  797. },
  798. followers: [],
  799. followerCursor: 1,
  800. followerMore: true,
  801. following: [],
  802. followingCursor: 1,
  803. followingMore: true,
  804. lightboxMedia: false,
  805. showSuggestions: true,
  806. showReadMore: true,
  807. replyStatus: {},
  808. replyText: '',
  809. replyNsfw: false,
  810. emoji: window.App.util.emoji,
  811. showHashtagPosts: false,
  812. hashtagPosts: [],
  813. hashtagPostsName: '',
  814. ctxMenuStatus: false,
  815. ctxMenuRelationship: false,
  816. ctxEmbedPayload: false,
  817. copiedEmbed: false,
  818. showTips: true,
  819. userStory: false,
  820. replySending: false,
  821. ctxEmbedShowCaption: true,
  822. ctxEmbedShowLikes: false,
  823. ctxEmbedCompactMode: false,
  824. morePostsAvailable: false,
  825. mpCount: 0,
  826. mpData: false,
  827. mpInterval: 15000,
  828. mpEnabled: false,
  829. mpPoller: null,
  830. confirmModalTitle: 'Are you sure?',
  831. confirmModalIdentifer: null,
  832. confirmModalType: false,
  833. currentLayout: 'feed',
  834. pagination: {},
  835. tributeSettings: {
  836. collection: [
  837. {
  838. trigger: '@',
  839. menuShowMinLength: 2,
  840. values: (function (text, cb) {
  841. let url = '/api/compose/v0/search/mention';
  842. axios.get(url, { params: { q: text }})
  843. .then(res => {
  844. cb(res.data);
  845. })
  846. .catch(err => {
  847. console.log(err);
  848. })
  849. })
  850. },
  851. {
  852. trigger: '#',
  853. menuShowMinLength: 2,
  854. values: (function (text, cb) {
  855. let url = '/api/compose/v0/search/hashtag';
  856. axios.get(url, { params: { q: text }})
  857. .then(res => {
  858. cb(res.data);
  859. })
  860. .catch(err => {
  861. console.log(err);
  862. })
  863. })
  864. }
  865. ]
  866. }
  867. }
  868. },
  869. watch: {
  870. ctxEmbedShowCaption: function (n,o) {
  871. if(n == true) {
  872. this.ctxEmbedCompactMode = false;
  873. }
  874. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  875. this.ctxEmbedPayload = window.App.util.embed.post(this.ctxMenuStatus.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  876. },
  877. ctxEmbedShowLikes: function (n,o) {
  878. if(n == true) {
  879. this.ctxEmbedCompactMode = false;
  880. }
  881. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  882. this.ctxEmbedPayload = window.App.util.embed.post(this.ctxMenuStatus.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  883. },
  884. ctxEmbedCompactMode: function (n,o) {
  885. if(n == true) {
  886. this.ctxEmbedShowCaption = false;
  887. this.ctxEmbedShowLikes = false;
  888. }
  889. let mode = this.ctxEmbedCompactMode ? 'compact' : 'full';
  890. this.ctxEmbedPayload = window.App.util.embed.post(this.ctxMenuStatus.url, this.ctxEmbedShowCaption, this.ctxEmbedShowLikes, mode);
  891. }
  892. },
  893. beforeMount() {
  894. this.fetchProfile();
  895. this.fetchTimelineApi();
  896. },
  897. mounted() {
  898. // todo: release after dark mode updates
  899. /* if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches || $('link[data-stylesheet="dark"]').length != 0) {
  900. this.modes.dark = true;
  901. let el = document.querySelector('link[data-stylesheet="light"]');
  902. el.setAttribute('href', '/css/appdark.css?id=' + Date.now());
  903. el.setAttribute('data-stylesheet', 'dark');
  904. }*/
  905. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  906. this.showSuggestions = false;
  907. } else {
  908. this.showSuggestions = true;
  909. }
  910. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  911. this.showReadMore = false;
  912. } else {
  913. this.showReadMore = true;
  914. }
  915. if(localStorage.getItem('metro-tips') == 'false') {
  916. this.showTips = false;
  917. }
  918. this.$nextTick(function () {
  919. $('[data-toggle="tooltip"]').tooltip();
  920. let u = new URLSearchParams(window.location.search);
  921. if(u.has('a') && u.get('a') == 'co') {
  922. $('#composeModal').modal('show');
  923. }
  924. });
  925. },
  926. updated() {
  927. if(this.showReadMore == true) {
  928. pixelfed.readmore();
  929. }
  930. },
  931. methods: {
  932. fetchProfile() {
  933. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  934. this.profile = res.data;
  935. if(this.profile.is_admin == true) {
  936. this.modes.mod = true;
  937. }
  938. window._sharedData.curUser = res.data;
  939. window.App.util.navatar();
  940. this.hasStory();
  941. // this.expRec();
  942. }).catch(err => {
  943. swal(
  944. 'Oops, something went wrong',
  945. 'Please reload the page.',
  946. 'error'
  947. );
  948. });
  949. },
  950. fetchTimelineApi() {
  951. let apiUrl = false;
  952. switch(this.scope) {
  953. case 'home':
  954. apiUrl = '/api/pixelfed/v1/timelines/home';
  955. break;
  956. case 'local':
  957. apiUrl = '/api/pixelfed/v1/timelines/public';
  958. break;
  959. case 'network':
  960. apiUrl = '/api/pixelfed/v1/timelines/network';
  961. break;
  962. }
  963. axios.get(apiUrl, {
  964. params: {
  965. max_id: this.max_id,
  966. limit: 3
  967. }
  968. }).then(res => {
  969. let data = res.data;
  970. this.feed.push(...data);
  971. let ids = data.map(status => status.id);
  972. this.ids = ids;
  973. this.min_id = Math.max(...ids).toString();
  974. this.max_id = Math.min(...ids).toString();
  975. this.loading = false;
  976. $('.timeline .pagination').removeClass('d-none');
  977. // if(this.feed.length == 4) {
  978. // this.fetchTimelineApi();
  979. // }
  980. if(this.hashtagPosts.length == 0) {
  981. this.fetchHashtagPosts();
  982. }
  983. // this.fetchStories();
  984. this.rtw();
  985. setTimeout(function() {
  986. document.querySelectorAll('.timeline .card-body .comments .comment-body a').forEach(function(i, e) {
  987. i.href = App.util.format.rewriteLinks(i);
  988. });
  989. }, 500);
  990. }).catch(err => {
  991. swal(
  992. 'Oops, something went wrong',
  993. 'Please reload the page.',
  994. 'error'
  995. );
  996. });
  997. },
  998. infiniteTimeline($state) {
  999. if(this.loading) {
  1000. $state.complete();
  1001. return;
  1002. }
  1003. if(this.page > 40) {
  1004. this.loading = false;
  1005. $state.complete();
  1006. }
  1007. let apiUrl = false;
  1008. switch(this.scope) {
  1009. case 'home':
  1010. apiUrl = '/api/pixelfed/v1/timelines/home';
  1011. break;
  1012. case 'local':
  1013. apiUrl = '/api/pixelfed/v1/timelines/public';
  1014. break;
  1015. case 'network':
  1016. apiUrl = '/api/pixelfed/v1/timelines/network';
  1017. break;
  1018. }
  1019. axios.get(apiUrl, {
  1020. params: {
  1021. max_id: this.max_id,
  1022. limit: 6
  1023. },
  1024. }).then(res => {
  1025. if (res.data.length && this.loading == false) {
  1026. let data = res.data;
  1027. let self = this;
  1028. data.forEach((d, index) => {
  1029. if(self.ids.indexOf(d.id) == -1) {
  1030. self.feed.push(d);
  1031. self.ids.push(d.id);
  1032. axios.post('/api/status/view', {
  1033. 'status_id': d.id,
  1034. 'profile_id': d.account.id
  1035. });
  1036. }
  1037. });
  1038. this.min_id = Math.max(...this.ids).toString();
  1039. this.max_id = Math.min(...this.ids).toString();
  1040. this.page += 1;
  1041. $state.loaded();
  1042. this.loading = false;
  1043. } else {
  1044. $state.complete();
  1045. }
  1046. }).catch(err => {
  1047. this.loading = false;
  1048. $state.complete();
  1049. });
  1050. },
  1051. reportUrl(status) {
  1052. let type = status.in_reply_to ? 'comment' : 'post';
  1053. let id = status.id;
  1054. return '/i/report?type=' + type + '&id=' + id;
  1055. },
  1056. commentFocus(status, $event) {
  1057. if(status.comments_disabled) {
  1058. return;
  1059. }
  1060. // if(this.status && this.status.id == status.id) {
  1061. // this.$refs.replyModal.show();
  1062. // return;
  1063. // }
  1064. this.status = status;
  1065. this.replies = {};
  1066. this.replyStatus = {};
  1067. this.replyText = '';
  1068. this.replyId = status.id;
  1069. this.replyStatus = status;
  1070. // this.$refs.replyModal.show();
  1071. this.fetchStatusComments(status, '');
  1072. $('nav').hide();
  1073. $('footer').hide();
  1074. $('.mobile-footer-spacer').attr('style', 'display:none !important');
  1075. $('.mobile-footer').attr('style', 'display:none !important');
  1076. this.currentLayout = 'comments';
  1077. window.history.pushState({}, '', status.url);
  1078. return;
  1079. },
  1080. commentNavigateBack(id) {
  1081. $('nav').show();
  1082. $('footer').show();
  1083. $('.mobile-footer-spacer').attr('style', 'display:block');
  1084. $('.mobile-footer').attr('style', 'display:block');
  1085. this.currentLayout = 'feed';
  1086. setTimeout(function() {
  1087. $([document.documentElement, document.body]).animate({
  1088. scrollTop: $(`div[data-status-id="${id}"]`).offset().top
  1089. }, 1000);
  1090. }, 500);
  1091. let path = this.scope == 'home' ? '/' : '/timeline/public';
  1092. window.history.pushState({}, '', path);
  1093. },
  1094. likeStatus(status, event) {
  1095. if($('body').hasClass('loggedIn') == false) {
  1096. return;
  1097. }
  1098. let count = status.favourites_count;
  1099. status.favourited = !status.favourited;
  1100. axios.post('/i/like', {
  1101. item: status.id
  1102. }).then(res => {
  1103. status.favourites_count = res.data.count;
  1104. }).catch(err => {
  1105. status.favourited = !status.favourited;
  1106. status.favourites_count = count;
  1107. swal('Error', 'Something went wrong, please try again later.', 'error');
  1108. });
  1109. window.navigator.vibrate(200);
  1110. if(status.favourited) {
  1111. setTimeout(function() {
  1112. event.target.classList.add('animate__animated', 'animate__bounce');
  1113. },100);
  1114. }
  1115. },
  1116. shareStatus(status, $event) {
  1117. if($('body').hasClass('loggedIn') == false) {
  1118. return;
  1119. }
  1120. this.closeModals();
  1121. axios.post('/i/share', {
  1122. item: status.id
  1123. }).then(res => {
  1124. status.reblogs_count = res.data.count;
  1125. status.reblogged = !status.reblogged;
  1126. if(status.reblogged) {
  1127. swal('Success', 'You shared this post', 'success');
  1128. } else {
  1129. swal('Success', 'You unshared this post', 'success');
  1130. }
  1131. }).catch(err => {
  1132. swal('Error', 'Something went wrong, please try again later.', 'error');
  1133. });
  1134. },
  1135. timestampFormat(timestamp) {
  1136. let ts = new Date(timestamp);
  1137. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  1138. },
  1139. redirect(url) {
  1140. window.location.href = url;
  1141. return;
  1142. },
  1143. statusOwner(status) {
  1144. let sid = status.account.id;
  1145. let uid = this.profile.id;
  1146. if(sid == uid) {
  1147. return true;
  1148. } else {
  1149. return false;
  1150. }
  1151. },
  1152. fetchStatusComments(status, card) {
  1153. // axios.get('/api/v2/status/'+status.id+'/replies',
  1154. // {
  1155. // params: {
  1156. // limit: 6
  1157. // }
  1158. // })
  1159. // .then(res => {
  1160. // let data = res.data.filter(res => {
  1161. // return res.sensitive == false;
  1162. // });
  1163. // this.replies = _.reverse(data);
  1164. // setTimeout(function() {
  1165. // document.querySelectorAll('.timeline .card-body .comments .comment-body a').forEach(function(i, e) {
  1166. // i.href = App.util.format.rewriteLinks(i);
  1167. // });
  1168. // }, 500);
  1169. // }).catch(err => {
  1170. // })
  1171. let url = '/api/v2/comments/'+status.account.id+'/status/'+status.id;
  1172. axios.get(url)
  1173. .then(response => {
  1174. let self = this;
  1175. // this.results = this.layout == 'metro' ?
  1176. // _.reverse(response.data.data) :
  1177. // response.data.data;
  1178. this.replies = _.reverse(response.data.data);
  1179. this.pagination = response.data.meta.pagination;
  1180. if(this.replies.length > 0) {
  1181. $('.load-more-link').removeClass('d-none');
  1182. }
  1183. $('.postCommentsLoader').addClass('d-none');
  1184. $('.postCommentsContainer').removeClass('d-none');
  1185. // setTimeout(function() {
  1186. // document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  1187. // i.href = App.util.format.rewriteLinks(i);
  1188. // });
  1189. // }, 500);
  1190. }).catch(error => {
  1191. if(!error.response) {
  1192. $('.postCommentsLoader .lds-ring')
  1193. .attr('style','width:100%')
  1194. .addClass('pt-4 font-weight-bold text-muted')
  1195. .text('An error occurred, cannot fetch comments. Please try again later.');
  1196. } else {
  1197. switch(error.response.status) {
  1198. case 401:
  1199. $('.postCommentsLoader .lds-ring')
  1200. .attr('style','width:100%')
  1201. .addClass('pt-4 font-weight-bold text-muted')
  1202. .text('Please login to view.');
  1203. break;
  1204. default:
  1205. $('.postCommentsLoader .lds-ring')
  1206. .attr('style','width:100%')
  1207. .addClass('pt-4 font-weight-bold text-muted')
  1208. .text('An error occurred, cannot fetch comments. Please try again later.');
  1209. break;
  1210. }
  1211. }
  1212. });
  1213. },
  1214. muteProfile(status) {
  1215. if($('body').hasClass('loggedIn') == false) {
  1216. return;
  1217. }
  1218. axios.post('/i/mute', {
  1219. type: 'user',
  1220. item: status.account.id
  1221. }).then(res => {
  1222. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  1223. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  1224. }).catch(err => {
  1225. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1226. });
  1227. },
  1228. blockProfile(status) {
  1229. if($('body').hasClass('loggedIn') == false) {
  1230. return;
  1231. }
  1232. axios.post('/i/block', {
  1233. type: 'user',
  1234. item: status.account.id
  1235. }).then(res => {
  1236. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  1237. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  1238. }).catch(err => {
  1239. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1240. });
  1241. },
  1242. deletePost(status) {
  1243. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  1244. return;
  1245. }
  1246. if(window.confirm('Are you sure you want to delete this post?') == false) {
  1247. return;
  1248. }
  1249. axios.post('/i/delete', {
  1250. type: 'status',
  1251. item: status.id
  1252. }).then(res => {
  1253. this.feed = this.feed.filter(s => {
  1254. return s.id != status.id;
  1255. });
  1256. this.closeModals();
  1257. }).catch(err => {
  1258. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1259. });
  1260. },
  1261. commentSubmit(status, $event) {
  1262. this.replySending = true;
  1263. let id = status.id;
  1264. let comment = this.replyText;
  1265. let limit = this.config.uploader.max_caption_length;
  1266. if(comment.length > limit) {
  1267. this.replySending = false;
  1268. swal('Comment Too Long', 'Please make sure your comment is '+limit+' characters or less.', 'error');
  1269. return;
  1270. }
  1271. axios.post('/i/comment', {
  1272. item: id,
  1273. comment: comment,
  1274. sensitive: this.replyNsfw
  1275. }).then(res => {
  1276. this.replyText = '';
  1277. this.replies.push(res.data.entity);
  1278. this.$refs.replyModal.hide();
  1279. });
  1280. this.replySending = false;
  1281. },
  1282. moderatePost(status, action, $event) {
  1283. let username = status.account.username;
  1284. let msg = '';
  1285. let self = this;
  1286. switch(action) {
  1287. case 'addcw':
  1288. msg = 'Are you sure you want to add a content warning to this post?';
  1289. swal({
  1290. title: 'Confirm',
  1291. text: msg,
  1292. icon: 'warning',
  1293. buttons: true,
  1294. dangerMode: true
  1295. }).then(res => {
  1296. if(res) {
  1297. axios.post('/api/v2/moderator/action', {
  1298. action: action,
  1299. item_id: status.id,
  1300. item_type: 'status'
  1301. }).then(res => {
  1302. swal('Success', 'Successfully added content warning', 'success');
  1303. status.sensitive = true;
  1304. self.ctxModMenuClose();
  1305. }).catch(err => {
  1306. swal(
  1307. 'Error',
  1308. 'Something went wrong, please try again later.',
  1309. 'error'
  1310. );
  1311. self.ctxModMenuClose();
  1312. });
  1313. }
  1314. });
  1315. break;
  1316. case 'remcw':
  1317. msg = 'Are you sure you want to remove the content warning on this post?';
  1318. swal({
  1319. title: 'Confirm',
  1320. text: msg,
  1321. icon: 'warning',
  1322. buttons: true,
  1323. dangerMode: true
  1324. }).then(res => {
  1325. if(res) {
  1326. axios.post('/api/v2/moderator/action', {
  1327. action: action,
  1328. item_id: status.id,
  1329. item_type: 'status'
  1330. }).then(res => {
  1331. swal('Success', 'Successfully added content warning', 'success');
  1332. status.sensitive = false;
  1333. self.ctxModMenuClose();
  1334. }).catch(err => {
  1335. swal(
  1336. 'Error',
  1337. 'Something went wrong, please try again later.',
  1338. 'error'
  1339. );
  1340. self.ctxModMenuClose();
  1341. });
  1342. }
  1343. });
  1344. break;
  1345. case 'unlist':
  1346. msg = 'Are you sure you want to unlist this post?';
  1347. swal({
  1348. title: 'Confirm',
  1349. text: msg,
  1350. icon: 'warning',
  1351. buttons: true,
  1352. dangerMode: true
  1353. }).then(res => {
  1354. if(res) {
  1355. axios.post('/api/v2/moderator/action', {
  1356. action: action,
  1357. item_id: status.id,
  1358. item_type: 'status'
  1359. }).then(res => {
  1360. this.feed = this.feed.filter(f => {
  1361. return f.id != status.id;
  1362. });
  1363. swal('Success', 'Successfully unlisted post', 'success');
  1364. self.ctxModMenuClose();
  1365. }).catch(err => {
  1366. self.ctxModMenuClose();
  1367. swal(
  1368. 'Error',
  1369. 'Something went wrong, please try again later.',
  1370. 'error'
  1371. );
  1372. });
  1373. }
  1374. });
  1375. break;
  1376. }
  1377. },
  1378. followingModal() {
  1379. if(this.following.length > 0) {
  1380. this.$refs.followingModal.show();
  1381. return;
  1382. }
  1383. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  1384. params: {
  1385. page: this.followingCursor
  1386. }
  1387. })
  1388. .then(res => {
  1389. this.following = res.data;
  1390. this.followingCursor++;
  1391. });
  1392. if(res.data.length < 10) {
  1393. this.followingMore = false;
  1394. }
  1395. this.$refs.followingModal.show();
  1396. },
  1397. followersModal() {
  1398. if(this.followers.length > 0) {
  1399. this.$refs.followerModal.show();
  1400. return;
  1401. }
  1402. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  1403. params: {
  1404. page: this.followerCursor
  1405. }
  1406. })
  1407. .then(res => {
  1408. this.followers = res.data;
  1409. this.followerCursor++;
  1410. })
  1411. if(res.data.length < 10) {
  1412. this.followerMore = false;
  1413. }
  1414. this.$refs.followerModal.show();
  1415. },
  1416. followingLoadMore() {
  1417. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  1418. params: {
  1419. page: this.followingCursor
  1420. }
  1421. })
  1422. .then(res => {
  1423. if(res.data.length > 0) {
  1424. this.following.push(...res.data);
  1425. this.followingCursor++;
  1426. }
  1427. if(res.data.length < 10) {
  1428. this.followingMore = false;
  1429. }
  1430. });
  1431. },
  1432. followersLoadMore() {
  1433. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  1434. params: {
  1435. page: this.followerCursor
  1436. }
  1437. })
  1438. .then(res => {
  1439. if(res.data.length > 0) {
  1440. this.followers.push(...res.data);
  1441. this.followerCursor++;
  1442. }
  1443. if(res.data.length < 10) {
  1444. this.followerMore = false;
  1445. }
  1446. });
  1447. },
  1448. lightbox(status) {
  1449. window.location.href = status.media_attachments[0].url;
  1450. return;
  1451. this.lightboxMedia = status.media_attachments[0];
  1452. this.$refs.lightboxModal.show();
  1453. },
  1454. expLc(status) {
  1455. if(this.config.ab.lc == false) {
  1456. return true;
  1457. }
  1458. if(this.statusOwner(status) == true) {
  1459. return true;
  1460. }
  1461. return false;
  1462. },
  1463. expRec() {
  1464. //return;
  1465. if(this.config.ab.rec == false) {
  1466. return;
  1467. }
  1468. axios.get('/api/local/exp/rec')
  1469. .then(res => {
  1470. this.suggestions = res.data;
  1471. })
  1472. },
  1473. expRecFollow(id, index) {
  1474. return;
  1475. if(this.config.ab.rec == false) {
  1476. return;
  1477. }
  1478. axios.post('/i/follow', {
  1479. item: id
  1480. }).then(res => {
  1481. this.suggestions.splice(index, 1);
  1482. }).catch(err => {
  1483. if(err.response.data.message) {
  1484. swal('Error', err.response.data.message, 'error');
  1485. }
  1486. });
  1487. },
  1488. followAction(status) {
  1489. let id = status.account.id;
  1490. axios.post('/i/follow', {
  1491. item: id
  1492. }).then(res => {
  1493. this.feed.forEach(s => {
  1494. if(s.account.id == id) {
  1495. s.account.relationship.following = !s.account.relationship.following;
  1496. }
  1497. });
  1498. let username = status.account.acct;
  1499. if(status.account.relationship.following) {
  1500. swal('Follow successful!', 'You are now following ' + username, 'success');
  1501. } else {
  1502. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1503. }
  1504. }).catch(err => {
  1505. if(err.response.data.message) {
  1506. swal('Error', err.response.data.message, 'error');
  1507. }
  1508. });
  1509. },
  1510. owner(status) {
  1511. return this.profile.id === status.account.id;
  1512. },
  1513. admin() {
  1514. return this.profile.is_admin == true;
  1515. },
  1516. ownerOrAdmin(status) {
  1517. return this.owner(status) || this.admin();
  1518. },
  1519. hideSuggestions() {
  1520. localStorage.setItem('pf_metro_ui.exp.rec', false);
  1521. this.showSuggestions = false;
  1522. },
  1523. emojiReaction(status) {
  1524. let em = event.target.innerText;
  1525. if(this.replyText.length == 0) {
  1526. this.replyText = em + ' ';
  1527. $('textarea[name="comment"]').focus();
  1528. } else {
  1529. this.replyText += em + ' ';
  1530. $('textarea[name="comment"]').focus();
  1531. }
  1532. },
  1533. refreshSuggestions() {
  1534. return;
  1535. let el = event.target.parentNode;
  1536. if(el.classList.contains('disabled') == true) {
  1537. return;
  1538. }
  1539. axios.get('/api/local/exp/rec', {
  1540. params: {
  1541. refresh: true
  1542. }
  1543. })
  1544. .then(res => {
  1545. this.suggestions = res.data;
  1546. if (el.classList) {
  1547. el.classList.add('disabled');
  1548. el.classList.add('text-light');
  1549. }
  1550. else {
  1551. el.className += ' ' + 'disabled text-light';
  1552. }
  1553. setTimeout(function() {
  1554. el.setAttribute('href', '#');
  1555. if (el.classList) {
  1556. el.classList.remove('disabled');
  1557. el.classList.remove('text-light');
  1558. }
  1559. else {
  1560. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1561. }
  1562. }, 10000);
  1563. });
  1564. },
  1565. fetchHashtagPosts() {
  1566. axios.get('/api/local/discover/tag/list')
  1567. .then(res => {
  1568. let tags = res.data;
  1569. if(tags.length == 0) {
  1570. return;
  1571. }
  1572. let hashtag = tags[Math.floor(Math.random(), tags.length)];
  1573. this.hashtagPostsName = hashtag;
  1574. axios.get('/api/v2/discover/tag', {
  1575. params: {
  1576. hashtag: hashtag
  1577. }
  1578. }).then(res => {
  1579. if(res.data.tags.length > 3) {
  1580. this.showHashtagPosts = true;
  1581. this.hashtagPosts = res.data.tags.splice(0,3);
  1582. }
  1583. })
  1584. })
  1585. },
  1586. ctxMenu(status) {
  1587. this.ctxMenuStatus = status;
  1588. this.ctxEmbedPayload = window.App.util.embed.post(status.url);
  1589. if(status.account.id == this.profile.id) {
  1590. this.ctxMenuRelationship = false;
  1591. this.$refs.ctxModal.show();
  1592. } else {
  1593. axios.get('/api/pixelfed/v1/accounts/relationships', {
  1594. params: {
  1595. 'id[]': status.account.id
  1596. }
  1597. }).then(res => {
  1598. this.ctxMenuRelationship = res.data[0];
  1599. this.$refs.ctxModal.show();
  1600. });
  1601. }
  1602. },
  1603. closeCtxMenu(truncate) {
  1604. this.copiedEmbed = false;
  1605. this.ctxMenuStatus = false;
  1606. this.ctxMenuRelationship = false;
  1607. this.$refs.ctxModal.hide();
  1608. this.$refs.ctxReport.hide();
  1609. this.$refs.ctxReportOther.hide();
  1610. this.closeModals();
  1611. },
  1612. ctxMenuCopyLink() {
  1613. let status = this.ctxMenuStatus;
  1614. navigator.clipboard.writeText(status.url);
  1615. this.closeModals();
  1616. return;
  1617. },
  1618. ctxMenuGoToPost() {
  1619. let status = this.ctxMenuStatus;
  1620. window.location.href = this.statusUrl(status);
  1621. this.closeCtxMenu();
  1622. return;
  1623. },
  1624. ctxMenuFollow() {
  1625. let id = this.ctxMenuStatus.account.id;
  1626. axios.post('/i/follow', {
  1627. item: id
  1628. }).then(res => {
  1629. let username = this.ctxMenuStatus.account.acct;
  1630. this.closeCtxMenu();
  1631. setTimeout(function() {
  1632. swal('Follow successful!', 'You are now following ' + username, 'success');
  1633. }, 500);
  1634. });
  1635. },
  1636. ctxMenuUnfollow() {
  1637. let id = this.ctxMenuStatus.account.id;
  1638. axios.post('/i/follow', {
  1639. item: id
  1640. }).then(res => {
  1641. let username = this.ctxMenuStatus.account.acct;
  1642. if(this.scope == 'home') {
  1643. this.feed = this.feed.filter(s => {
  1644. return s.account.id != this.ctxMenuStatus.account.id;
  1645. });
  1646. }
  1647. this.closeCtxMenu();
  1648. setTimeout(function() {
  1649. swal('Unfollow successful!', 'You are no longer following ' + username, 'success');
  1650. }, 500);
  1651. });
  1652. },
  1653. ctxMenuReportPost() {
  1654. this.$refs.ctxModal.hide();
  1655. this.$refs.ctxReport.show();
  1656. return;
  1657. // window.location.href = '/i/report?type=post&id=' + this.ctxMenuStatus.id;
  1658. },
  1659. ctxMenuEmbed() {
  1660. this.closeModals();
  1661. this.$refs.ctxEmbedModal.show();
  1662. },
  1663. ctxMenuShare() {
  1664. this.$refs.ctxModal.hide();
  1665. this.$refs.ctxShareModal.show();
  1666. },
  1667. closeCtxShareMenu() {
  1668. this.$refs.ctxShareModal.hide();
  1669. this.$refs.ctxModal.show();
  1670. },
  1671. ctxCopyEmbed() {
  1672. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1673. this.ctxEmbedShowCaption = true;
  1674. this.ctxEmbedShowLikes = false;
  1675. this.ctxEmbedCompactMode = false;
  1676. this.$refs.ctxEmbedModal.hide();
  1677. },
  1678. ctxModMenuShow() {
  1679. this.$refs.ctxModal.hide();
  1680. this.$refs.ctxModModal.show();
  1681. },
  1682. ctxModOtherMenuShow() {
  1683. this.$refs.ctxModal.hide();
  1684. this.$refs.ctxModModal.hide();
  1685. this.$refs.ctxModOtherModal.show();
  1686. },
  1687. ctxModMenu() {
  1688. this.$refs.ctxModal.hide();
  1689. },
  1690. ctxModMenuClose() {
  1691. this.closeModals();
  1692. this.$refs.ctxModal.show();
  1693. },
  1694. ctxModOtherMenuClose() {
  1695. this.closeModals();
  1696. this.$refs.ctxModModal.show();
  1697. },
  1698. formatCount(count) {
  1699. return App.util.format.count(count);
  1700. },
  1701. statusUrl(status) {
  1702. if(status.local == true) {
  1703. return status.url;
  1704. }
  1705. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1706. },
  1707. profileUrl(status) {
  1708. if(status.local == true) {
  1709. return status.account.url;
  1710. }
  1711. return '/i/web/profile/_/' + status.account.id;
  1712. },
  1713. statusCardUsernameFormat(status) {
  1714. if(status.account.local == true) {
  1715. return status.account.username;
  1716. }
  1717. let fmt = window.App.config.username.remote.format;
  1718. let txt = window.App.config.username.remote.custom;
  1719. let usr = status.account.username;
  1720. let dom = document.createElement('a');
  1721. dom.href = status.account.url;
  1722. dom = dom.hostname;
  1723. switch(fmt) {
  1724. case '@':
  1725. return usr + '<span class="text-lighter font-weight-bold">@' + dom + '</span>';
  1726. break;
  1727. case 'from':
  1728. return usr + '<span class="text-lighter font-weight-bold"> <span class="font-weight-normal">from</span> ' + dom + '</span>';
  1729. break;
  1730. case 'custom':
  1731. return usr + '<span class="text-lighter font-weight-bold"> ' + txt + ' ' + dom + '</span>';
  1732. break;
  1733. default:
  1734. return usr + '<span class="text-lighter font-weight-bold">@' + dom + '</span>';
  1735. break;
  1736. }
  1737. },
  1738. previewUrl(status) {
  1739. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  1740. },
  1741. previewBackground(status) {
  1742. let preview = this.previewUrl(status);
  1743. return 'background-image: url(' + preview + ');';
  1744. },
  1745. trimCaption(caption, len = 60) {
  1746. return _.truncate(caption, {
  1747. length: len
  1748. });
  1749. },
  1750. hasStory() {
  1751. axios.get('/api/stories/v0/exists/'+this.profile.id)
  1752. .then(res => {
  1753. this.userStory = res.data;
  1754. })
  1755. },
  1756. // real time watcher
  1757. rtw() {
  1758. this.mpPoller = setInterval(() => {
  1759. let apiUrl = false;
  1760. this.mpCount++;
  1761. if(this.mpCount > 10) {
  1762. this.mpInterval = 30000;
  1763. }
  1764. if(this.mpCount > 50) {
  1765. this.mpInterval = (5 * 60 * 1000);
  1766. }
  1767. switch(this.scope) {
  1768. case 'home':
  1769. apiUrl = '/api/pixelfed/v1/timelines/home';
  1770. break;
  1771. case 'local':
  1772. apiUrl = '/api/pixelfed/v1/timelines/public';
  1773. break;
  1774. case 'network':
  1775. apiUrl = '/api/pixelfed/v1/timelines/network';
  1776. break;
  1777. }
  1778. axios.get(apiUrl, {
  1779. params: {
  1780. max_id: 0,
  1781. limit: 20
  1782. }
  1783. }).then(res => {
  1784. let self = this;
  1785. let tids = this.feed.map(status => status.id);
  1786. let data = res.data.filter(d => {
  1787. return d.id > self.min_id && tids.indexOf(d.id) == -1;
  1788. });
  1789. let ids = data.map(status => status.id);
  1790. let max = Math.max(...ids).toString();
  1791. let newer = max > this.min_id;
  1792. if(newer) {
  1793. this.morePostsAvailable = true;
  1794. this.mpData = data;
  1795. }
  1796. });
  1797. }, this.mpInterval);
  1798. },
  1799. syncNewPosts() {
  1800. let self = this;
  1801. let data = this.mpData;
  1802. let ids = data.map(s => s.id);
  1803. this.min_id = Math.max(...ids).toString();
  1804. this.max_id = Math.min(...ids).toString();
  1805. this.feed.unshift(...data);
  1806. this.morePostsAvailable = false;
  1807. this.mpData = null;
  1808. },
  1809. switchFeedLayout(toggle) {
  1810. this.loading = true;
  1811. this.layout = toggle;
  1812. let self = this;
  1813. setTimeout(function() {
  1814. self.loading = false;
  1815. }, 500);
  1816. },
  1817. labelRedirect(type) {
  1818. let url = '/i/redirect?url=' + encodeURI(this.config.features.label.covid.url);
  1819. window.location.href = url;
  1820. },
  1821. openCtxReportOtherMenu() {
  1822. let s = this.ctxMenuStatus;
  1823. this.closeCtxMenu();
  1824. this.ctxMenuStatus = s;
  1825. this.$refs.ctxReportOther.show();
  1826. },
  1827. ctxReportMenuGoBack() {
  1828. this.$refs.ctxReportOther.hide();
  1829. this.$refs.ctxReport.hide();
  1830. this.$refs.ctxModal.show();
  1831. },
  1832. ctxReportOtherMenuGoBack() {
  1833. this.$refs.ctxReportOther.hide();
  1834. this.$refs.ctxModal.hide();
  1835. this.$refs.ctxReport.show();
  1836. },
  1837. sendReport(type) {
  1838. let id = this.ctxMenuStatus.id;
  1839. swal({
  1840. 'title': 'Confirm Report',
  1841. 'text': 'Are you sure you want to report this post?',
  1842. 'icon': 'warning',
  1843. 'buttons': true,
  1844. 'dangerMode': true
  1845. }).then((res) => {
  1846. if(res) {
  1847. axios.post('/i/report/', {
  1848. 'report': type,
  1849. 'type': 'post',
  1850. 'id': id,
  1851. }).then(res => {
  1852. this.closeCtxMenu();
  1853. swal('Report Sent!', 'We have successfully received your report.', 'success');
  1854. }).catch(err => {
  1855. swal('Oops!', 'There was an issue reporting this post.', 'error');
  1856. })
  1857. } else {
  1858. this.closeCtxMenu();
  1859. }
  1860. });
  1861. },
  1862. closeModals() {
  1863. this.$refs.ctxModal.hide();
  1864. this.$refs.ctxModModal.hide();
  1865. this.$refs.ctxModOtherModal.hide();
  1866. this.$refs.ctxShareModal.hide();
  1867. this.$refs.ctxEmbedModal.hide();
  1868. this.$refs.ctxReport.hide();
  1869. this.$refs.ctxReportOther.hide();
  1870. this.$refs.ctxConfirm.hide();
  1871. this.$refs.lightboxModal.hide();
  1872. this.$refs.replyModal.hide();
  1873. this.$refs.ctxStatusModal.hide();
  1874. },
  1875. openCtxStatusModal() {
  1876. this.closeModals();
  1877. this.$refs.ctxStatusModal.show();
  1878. },
  1879. openConfirmModal() {
  1880. this.closeModals();
  1881. this.$refs.ctxConfirm.show();
  1882. },
  1883. closeConfirmModal() {
  1884. this.closeModals();
  1885. this.confirmModalTitle = 'Are you sure?';
  1886. this.confirmModalType = false;
  1887. this.confirmModalIdentifer = null;
  1888. },
  1889. confirmModalConfirm() {
  1890. switch(this.confirmModalType) {
  1891. case 'post.delete':
  1892. axios.post('/i/delete', {
  1893. type: 'status',
  1894. item: this.confirmModalIdentifer
  1895. }).then(res => {
  1896. this.feed = this.feed.filter(s => {
  1897. return s.id != this.confirmModalIdentifer;
  1898. });
  1899. this.closeConfirmModal();
  1900. }).catch(err => {
  1901. this.closeConfirmModal();
  1902. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1903. });
  1904. break;
  1905. }
  1906. this.closeConfirmModal();
  1907. },
  1908. confirmModalCancel() {
  1909. this.closeConfirmModal();
  1910. },
  1911. timeAgo(ts) {
  1912. return App.util.format.timeAgo(ts);
  1913. },
  1914. toggleReplies(reply) {
  1915. if(reply.thread) {
  1916. reply.thread = false;
  1917. } else {
  1918. if(reply.replies.length > 0) {
  1919. reply.thread = true;
  1920. return;
  1921. }
  1922. let url = '/api/v2/comments/'+reply.account.id+'/status/'+reply.id;
  1923. axios.get(url)
  1924. .then(response => {
  1925. reply.replies = _.reverse(response.data.data);
  1926. reply.thread = true;
  1927. });
  1928. }
  1929. },
  1930. likeReply(status, $event) {
  1931. if($('body').hasClass('loggedIn') == false) {
  1932. swal('Login', 'Please login to perform this action.', 'info');
  1933. return;
  1934. }
  1935. axios.post('/i/like', {
  1936. item: status.id
  1937. }).then(res => {
  1938. status.favourites_count = res.data.count;
  1939. if(status.favourited == true) {
  1940. status.favourited = false;
  1941. } else {
  1942. status.favourited = true;
  1943. }
  1944. }).catch(err => {
  1945. swal('Error', 'Something went wrong, please try again later.', 'error');
  1946. });
  1947. },
  1948. replyFocus(e, index, prependUsername = false) {
  1949. if($('body').hasClass('loggedIn') == false) {
  1950. this.redirect('/login?next=' + encodeURIComponent(window.location.pathname));
  1951. return;
  1952. }
  1953. if(this.status.comments_disabled) {
  1954. return;
  1955. }
  1956. this.replyToIndex = index;
  1957. this.replyingToId = e.id;
  1958. this.replyingToUsername = e.account.username;
  1959. this.reply_to_profile_id = e.account.id;
  1960. let username = e.account.local ? '@' + e.account.username + ' '
  1961. : '@' + e.account.acct + ' ';
  1962. if(prependUsername == true) {
  1963. this.replyText = username;
  1964. }
  1965. this.$refs.replyModal.show();
  1966. setTimeout(function() {
  1967. $('.replyModalTextarea').focus();
  1968. }, 500);
  1969. },
  1970. loadMoreComments() {
  1971. if(this.pagination.total_pages == 1 || this.pagination.current_page == this.pagination.total_pages) {
  1972. $('.load-more-link').addClass('d-none');
  1973. return;
  1974. }
  1975. $('.load-more-link').addClass('d-none');
  1976. $('.postCommentsLoader').removeClass('d-none');
  1977. let next = this.pagination.links.next;
  1978. axios.get(next)
  1979. .then(response => {
  1980. let self = this;
  1981. let res = response.data.data;
  1982. $('.postCommentsLoader').addClass('d-none');
  1983. for(let i=0; i < res.length; i++) {
  1984. this.replies.unshift(res[i]);
  1985. }
  1986. this.pagination = response.data.meta.pagination;
  1987. $('.load-more-link').removeClass('d-none');
  1988. });
  1989. }
  1990. },
  1991. beforeDestroy () {
  1992. clearInterval(this.mpInterval);
  1993. }
  1994. }
  1995. </script>
  1996. <style type="text/css" scoped>
  1997. .postPresenterContainer {
  1998. display: flex;
  1999. align-items: center;
  2000. background: #fff;
  2001. }
  2002. .word-break {
  2003. word-break: break-all;
  2004. }
  2005. .small .custom-control-label {
  2006. padding-top: 3px;
  2007. }
  2008. /*.reply-btn {
  2009. position: absolute;
  2010. bottom: 30px;
  2011. right: 20px;
  2012. width: 60px;
  2013. text-align: center;
  2014. font-size: 13px;
  2015. border-radius: 0 3px 3px 0;
  2016. }*/
  2017. .emoji-reactions .nav-item {
  2018. font-size: 1.2rem;
  2019. padding: 9px;
  2020. cursor: pointer;
  2021. }
  2022. .emoji-reactions::-webkit-scrollbar {
  2023. width: 0px;
  2024. height: 0px;
  2025. background: transparent;
  2026. }
  2027. .reply-btn[disabled] {
  2028. opacity: .3;
  2029. color: #3897f0;
  2030. }
  2031. .replyModalTextarea {
  2032. border: none;
  2033. font-size: 18px;
  2034. resize: none;
  2035. white-space: pre-wrap;
  2036. outline: none;
  2037. }
  2038. .has-story {
  2039. width: 64px;
  2040. height: 64px;
  2041. border-radius: 50%;
  2042. padding: 2px;
  2043. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  2044. }
  2045. .has-story img {
  2046. width: 60px;
  2047. height: 60px;
  2048. border-radius: 50%;
  2049. padding: 3px;
  2050. background: #fff;
  2051. }
  2052. .has-story.has-story-sm {
  2053. width: 32px;
  2054. height: 32px;
  2055. border-radius: 50%;
  2056. padding: 2px;
  2057. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  2058. }
  2059. .has-story.has-story-sm img {
  2060. width: 28px;
  2061. height: 28px;
  2062. border-radius: 50%;
  2063. padding: 3px;
  2064. background: #fff;
  2065. }
  2066. #ctx-reply-modal .form-control:focus {
  2067. border: none;
  2068. outline: 0;
  2069. box-shadow: none;
  2070. }
  2071. </style>