NetworkTimeline.vue 76 KB

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