Timeline.vue 77 KB

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