Timeline.vue 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201
  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="`feed-${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. <status-card
  102. :status="status"
  103. :reaction-bar="reactionBar"
  104. v-on:status-delete="deleteStatus"
  105. v-on:comment-focus="commentFocus"
  106. />
  107. </div>
  108. <div v-if="!loading && feed.length">
  109. <div class="card rounded-0 border-top-0 status-card card-md-rounded-0 shadow-none border">
  110. <div class="card-body py-5 my-5">
  111. <infinite-loading @infinite="infiniteTimeline" :distance="800">
  112. <div slot="no-more">
  113. <div v-if="recentFeed">
  114. <p class="text-center"><i class="far fa-check-circle fa-8x text-lighter"></i></p>
  115. <p class="text-center h3 font-weight-light">You're All Caught Up!</p>
  116. <p class="text-center text-muted font-weight-light">You've seen all the new posts from the accounts you follow.</p>
  117. <p class="text-center mb-0">
  118. <a class="btn btn-link font-weight-bold px-4" href="/?a=vop">View Older Posts</a>
  119. </p>
  120. <p class="text-center mb-0">
  121. <a class="btn btn-link font-weight-bold px-4" href="/" @click.prevent="alwaysViewOlderPosts()">Always show older posts on this device</a>
  122. </p>
  123. </div>
  124. <div v-else>
  125. <p class="text-center h3 font-weight-light">You've reached the end of this feed</p>
  126. <p class="text-center mb-0">
  127. <a class="btn btn-link font-weight-bold px-4" href="/discover">Discover new posts and people</a>
  128. </p>
  129. </div>
  130. </div>
  131. <div slot="no-results">
  132. <div v-if="recentFeed">
  133. <p class="text-center"><i class="far fa-check-circle fa-8x text-lighter"></i></p>
  134. <p class="text-center h3 font-weight-light">You're All Caught Up!</p>
  135. <p class="text-center text-muted font-weight-light">You've seen all the new posts from the accounts you follow.</p>
  136. <p class="text-center mb-0">
  137. <a class="btn btn-link font-weight-bold px-4" href="/?a=vop">View Older Posts</a>
  138. </p>
  139. <p class="text-center mb-0">
  140. <a class="btn btn-link font-weight-bold px-4" href="/" @click.prevent="alwaysViewOlderPosts()">Always show older posts on this device</a>
  141. </p>
  142. </div>
  143. <div v-else>
  144. <p class="text-center h3 font-weight-light">You've reached the end of this feed</p>
  145. <p class="text-center mb-0">
  146. <a class="btn btn-link font-weight-bold px-4" href="/discover">Discover new posts and people</a>
  147. </p>
  148. </div>
  149. </div>
  150. </infinite-loading>
  151. </div>
  152. </div>
  153. </div>
  154. <div v-if="!loading && scope == 'home' && feed.length == 0">
  155. <div class="card rounded-0 mt-4 status-card card-md-rounded-0 shadow-none border">
  156. <div v-if="profile.following_count != '0'" class="card-body py-5 my-5">
  157. <p class="text-center"><i class="far fa-check-circle fa-8x text-lighter"></i></p>
  158. <p class="text-center h3 font-weight-light">You're All Caught Up!</p>
  159. <p class="text-center text-muted font-weight-light">You've seen all the new posts from the accounts you follow.</p>
  160. <p class="text-center mb-0">
  161. <a class="btn btn-link font-weight-bold px-4" href="/?a=vop">View Older Posts</a>
  162. </p>
  163. <p class="text-center mb-0">
  164. <a class="btn btn-link font-weight-bold px-4" href="/" @click.prevent="alwaysViewOlderPosts()">Always show older posts on this device</a>
  165. </p>
  166. </div>
  167. <div v-else class="card-body py-5 my-5">
  168. <p class="text-center"><i class="far fa-smile fa-8x text-lighter"></i></p>
  169. <p class="text-center h3 font-weight-light">Hello {{profile.username}}</p>
  170. <p class="text-center text-muted font-weight-light">Accounts you follow will appear in this feed.</p>
  171. <p class="text-center mb-0">
  172. <a class="btn btn-link font-weight-bold px-4" href="/discover">Discover new posts and people</a>
  173. </p>
  174. </div>
  175. </div>
  176. </div>
  177. <div v-if="!loading && scope == 'home' && recentFeed && discover_feed.length" class="pt-3">
  178. <p class="h5 font-weight-bold py-3 d-flex justify-content-between align-items-center">
  179. <span>Suggested Posts</span>
  180. <a href="/?a=vop" class="small font-weight-bold">Older Posts</a>
  181. </p>
  182. </div>
  183. <div
  184. v-if="!loading && scope == 'home' && recentFeed && discover_feed.length"
  185. :data-status-id="status.id"
  186. v-for="(status, index) in discover_feed"
  187. :key="`discover_feed-${index}-${status.id}`">
  188. <div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0 shadow-none border">
  189. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  190. <h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
  191. <span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
  192. </div>
  193. <div class="card-body row mx-0">
  194. <div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
  195. <div class="card">
  196. <div class="card-body text-center pt-3">
  197. <p class="mb-0">
  198. <a :href="'/'+rec.username">
  199. <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">
  200. </a>
  201. </p>
  202. <div class="py-3">
  203. <p class="font-weight-bold text-dark cursor-pointer mb-0">
  204. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  205. {{rec.username}}
  206. </a>
  207. </p>
  208. <p class="small text-muted mb-0">{{rec.message}}</p>
  209. </div>
  210. <p class="mb-0">
  211. <a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  212. </p>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. <div v-if="index == 4 && showHashtagPosts && hashtagPosts.length" class="card status-card rounded-0 shadow-none border-top-0 border">
  219. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  220. <span></span>
  221. <h6 class="text-muted font-weight-bold mb-0"><a :href="'/discover/tags/'+hashtagPostsName+'?src=tr'">#{{hashtagPostsName}}</a></h6>
  222. <span class="cursor-pointer text-muted" v-on:click="showHashtagPosts = false"><i class="fas fa-times"></i></span>
  223. </div>
  224. <div class="card-body row mx-0">
  225. <div v-for="(tag, index) in hashtagPosts" class="col-4 p-0 p-sm-2 p-md-3 hashtag-post-square">
  226. <a class="card info-overlay card-md-border-0" :href="tag.status.url">
  227. <div :class="[tag.status.filter ? 'square ' + tag.status.filter : 'square']">
  228. <div v-if="tag.status.sensitive" class="square-content">
  229. <div class="info-overlay-text-label">
  230. <h5 class="text-white m-auto font-weight-bold">
  231. <span>
  232. <span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
  233. </span>
  234. </h5>
  235. </div>
  236. <blur-hash-canvas
  237. width="32"
  238. height="32"
  239. :hash="tag.status.media_attachments[0].blurhash"
  240. />
  241. </div>
  242. <div v-else class="square-content">
  243. <blur-hash-image
  244. width="32"
  245. height="32"
  246. :hash="tag.status.media_attachments[0].blurhash"
  247. :src="tag.status.media_attachments[0].preview_url"
  248. />
  249. </div>
  250. <div class="info-overlay-text">
  251. <h5 class="text-white m-auto font-weight-bold">
  252. <span class="pr-4">
  253. <span class="far fa-heart fa-lg pr-1"></span> {{formatCount(tag.status.favourites_count)}}
  254. </span>
  255. <span>
  256. <span class="far fa-comment fa-lg pr-1"></span> {{formatCount(tag.status.reply_count)}}
  257. </span>
  258. </h5>
  259. </div>
  260. </div>
  261. </a>
  262. </div>
  263. </div>
  264. </div>
  265. <status-card :status="status" :recommended="true" />
  266. </div>
  267. </div>
  268. </div>
  269. <div class="col-md-4 col-lg-4 my-4 order-1 order-md-2 d-none d-md-block">
  270. <div>
  271. <!-- <div class="mb-4">
  272. <a class="btn btn-block btn-primary btn-sm font-weight-bold mb-3 border" href="/i/compose" data-toggle="modal" data-target="#composeModal">
  273. <i class="far fa-plus-square pr-3 fa-lg pt-1"></i> New Post
  274. </a>
  275. </div> -->
  276. <div class="mb-4">
  277. <div v-show="!loading" class="">
  278. <div class="pb-2">
  279. <div class="media d-flex align-items-center">
  280. <a :href="!userStory ? profile.url : '/stories/' + profile.acct" class="mr-3">
  281. <!-- <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'"> -->
  282. <div v-if="userStory" class="has-story cursor-pointer shadow-sm" @click="storyRedirect()">
  283. <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">
  284. </div>
  285. <div v-else>
  286. <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">
  287. </div>
  288. </a>
  289. <div class="media-body d-flex justify-content-between word-break" >
  290. <div>
  291. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
  292. <p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
  293. </div>
  294. <div class="ml-2">
  295. <a class="text-muted" href="/settings/home">
  296. <i class="fas fa-cog fa-lg"></i>
  297. <span class="sr-only">User Settings</span>
  298. </a>
  299. </div>
  300. </div>
  301. </div>
  302. </div>
  303. <!-- <div class="card-footer bg-transparent border-top mt-2 py-1">
  304. <div class="d-flex justify-content-between text-center">
  305. <span class="cursor-pointer" @click="redirect(profile.url)">
  306. <p class="mb-0 font-weight-bold">{{formatCount(profile.statuses_count)}}</p>
  307. <p class="mb-0 small text-muted">Posts</p>
  308. </span>
  309. <span class="cursor-pointer" @click="redirect(profile.url+'?md=followers')">
  310. <p class="mb-0 font-weight-bold">{{formatCount(profile.followers_count)}}</p>
  311. <p class="mb-0 small text-muted">Followers</p>
  312. </span>
  313. <span class="cursor-pointer" @click="redirect(profile.url+'?md=following')">
  314. <p class="mb-0 font-weight-bold">{{formatCount(profile.following_count)}}</p>
  315. <p class="mb-0 small text-muted">Following</p>
  316. </span>
  317. </div>
  318. </div> -->
  319. </div>
  320. <div class="card-footer bg-transparent border-0 pt-0 pb-1">
  321. <div class="d-flex justify-content-between text-center">
  322. <span class="cursor-pointer" @click="redirect(profile.url)">
  323. <p class="mb-0 font-weight-bold">{{formatCount(profile.statuses_count)}}</p>
  324. <p class="mb-0 small text-muted">Posts</p>
  325. </span>
  326. <span class="cursor-pointer" @click="redirect(profile.url+'?md=followers')">
  327. <p class="mb-0 font-weight-bold">{{formatCount(profile.followers_count)}}</p>
  328. <p class="mb-0 small text-muted">Followers</p>
  329. </span>
  330. <span class="cursor-pointer" @click="redirect(profile.url+'?md=following')">
  331. <p class="mb-0 font-weight-bold">{{formatCount(profile.following_count)}}</p>
  332. <p class="mb-0 small text-muted">Following</p>
  333. </span>
  334. </div>
  335. </div>
  336. </div>
  337. <div v-show="modes.notify == true && !loading" class="mb-4">
  338. <notification-card></notification-card>
  339. </div>
  340. <div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
  341. <div class="card shadow-none border">
  342. <div class="card-header bg-white d-flex align-items-center justify-content-between">
  343. <a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
  344. <div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
  345. <div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
  346. </div>
  347. <div class="card-body pt-0">
  348. <div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
  349. <a :href="'/'+rec.username">
  350. <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">
  351. </a>
  352. <div class="media-body">
  353. <p class="mb-0 font-weight-bold small">
  354. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  355. {{rec.username}}
  356. </a>
  357. </p>
  358. <p class="mb-0 small text-muted">{{rec.message}}</p>
  359. </div>
  360. <a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  361. </div>
  362. </div>
  363. </div>
  364. </div>
  365. <footer>
  366. <div class="container px-0 pb-5">
  367. <p class="mb-2 small text-justify">
  368. <a href="/site/about" class="text-lighter pr-2">About</a>
  369. <a href="/site/help" class="text-lighter pr-2">Help</a>
  370. <a href="/site/language" class="text-lighter pr-2">Language</a>
  371. <a href="/discover/places" class="text-lighter pr-2">Places</a>
  372. <a href="/site/privacy" class="text-lighter pr-2">Privacy</a>
  373. <a href="/site/terms" class="text-lighter pr-2">Terms</a>
  374. </p>
  375. <p class="mb-0 text-uppercase text-muted small">
  376. <a href="http://pixelfed.org" class="text-lighter" rel="noopener" title="" data-toggle="tooltip">Powered by Pixelfed</a>
  377. </p>
  378. </div>
  379. </footer>
  380. </div>
  381. </div>
  382. </div>
  383. </div>
  384. <comment-card
  385. v-if="replyStatus && replyStatus.hasOwnProperty('id')"
  386. :status="replyStatus"
  387. :profile="profile"
  388. v-on:current-layout="setCurrentLayout"
  389. />
  390. <div class="modal-stack">
  391. <b-modal ref="replyModal"
  392. id="ctx-reply-modal"
  393. hide-footer
  394. centered
  395. rounded
  396. :title-html="replyStatus.account ? 'Reply to <span class=text-dark>' + replyStatus.account.username + '</span>' : ''"
  397. title-tag="p"
  398. title-class="font-weight-bold text-muted"
  399. size="md"
  400. body-class="p-2 rounded">
  401. <div>
  402. <vue-tribute :options="tributeSettings">
  403. <textarea
  404. class="form-control replyModalTextarea"
  405. rows="4"
  406. v-model="replyText">
  407. </textarea>
  408. </vue-tribute>
  409. <div class="border-top border-bottom my-2">
  410. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  411. <li class="nav-item" v-on:click="emojiReaction(status)" v-for="e in emoji">{{e}}</li>
  412. </ul>
  413. </div>
  414. <div class="d-flex justify-content-between align-items-center">
  415. <div>
  416. <span class="pl-2 small text-muted font-weight-bold text-monospace">
  417. <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}}
  418. </span>
  419. </div>
  420. <div class="d-flex align-items-center">
  421. <div class="custom-control custom-switch mr-3">
  422. <input type="checkbox" class="custom-control-input" id="replyModalCWSwitch" v-model="replyNsfw">
  423. <label :class="[replyNsfw ? 'custom-control-label font-weight-bold text-dark':'custom-control-label text-lighter']" for="replyModalCWSwitch">Mark as NSFW</label>
  424. </div>
  425. <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">
  426. {{replySending == true ? 'POSTING' : 'POST'}}
  427. </button>
  428. </div>
  429. </div>
  430. </div>
  431. </b-modal>
  432. <b-modal ref="ctxStatusModal"
  433. id="ctx-status-modal"
  434. hide-header
  435. hide-footer
  436. centered
  437. rounded
  438. size="xl"
  439. body-class="list-group-flush p-0 m-0 rounded">
  440. <!-- <post-component
  441. v-if="ctxMenuStatus"
  442. :status-template="ctxMenuStatus.pf_type"
  443. :status-id="ctxMenuStatus.id"
  444. :status-username="ctxMenuStatus.account.username"
  445. :status-url="ctxMenuStatus.url"
  446. :status-profile-url="ctxMenuStatus.account.url"
  447. :status-avatar="ctxMenuStatus.account.avatar"
  448. :status-profile-id="ctxMenuStatus.account.id"
  449. profile-layout="metro">
  450. </post-component> -->
  451. </b-modal>
  452. </div>
  453. </div>
  454. </template>
  455. <script type="text/javascript">
  456. import VueTribute from 'vue-tribute'
  457. import StatusCard from './partials/StatusCard.vue';
  458. import CommentCard from './partials/CommentCard.vue';
  459. export default {
  460. props: ['scope', 'layout'],
  461. components: {
  462. VueTribute,
  463. StatusCard,
  464. CommentCard
  465. },
  466. data() {
  467. return {
  468. ids: [],
  469. config: window.App.config,
  470. page: 2,
  471. feed: [],
  472. profile: {},
  473. min_id: 0,
  474. max_id: 0,
  475. suggestions: {},
  476. loading: true,
  477. replies: [],
  478. replyId: null,
  479. modes: {
  480. 'mod': false,
  481. 'dark': false,
  482. 'notify': true,
  483. 'distractionFree': false
  484. },
  485. followers: [],
  486. followerCursor: 1,
  487. followerMore: true,
  488. following: [],
  489. followingCursor: 1,
  490. followingMore: true,
  491. lightboxMedia: false,
  492. showSuggestions: true,
  493. showReadMore: true,
  494. replyStatus: {},
  495. replyText: '',
  496. replyNsfw: false,
  497. emoji: window.App.util.emoji,
  498. showHashtagPosts: false,
  499. hashtagPosts: [],
  500. hashtagPostsName: '',
  501. copiedEmbed: false,
  502. showTips: true,
  503. userStory: false,
  504. replySending: false,
  505. morePostsAvailable: false,
  506. mpCount: 0,
  507. mpData: false,
  508. mpInterval: 15000,
  509. mpEnabled: false,
  510. mpPoller: null,
  511. confirmModalTitle: 'Are you sure?',
  512. confirmModalIdentifer: null,
  513. confirmModalType: false,
  514. currentLayout: 'feed',
  515. pagination: {},
  516. tributeSettings: {
  517. collection: [
  518. {
  519. trigger: '@',
  520. menuShowMinLength: 2,
  521. values: (function (text, cb) {
  522. let url = '/api/compose/v0/search/mention';
  523. axios.get(url, { params: { q: text }})
  524. .then(res => {
  525. cb(res.data);
  526. })
  527. .catch(err => {
  528. console.log(err);
  529. })
  530. })
  531. },
  532. {
  533. trigger: '#',
  534. menuShowMinLength: 2,
  535. values: (function (text, cb) {
  536. let url = '/api/compose/v0/search/hashtag';
  537. axios.get(url, { params: { q: text }})
  538. .then(res => {
  539. cb(res.data);
  540. })
  541. .catch(err => {
  542. console.log(err);
  543. })
  544. })
  545. }
  546. ]
  547. },
  548. discover_min_id: 0,
  549. discover_max_id: 0,
  550. discover_feed: [],
  551. recentFeed: this.scope === 'home' ? true : false,
  552. recentFeedMin: null,
  553. recentFeedMax: null,
  554. reactionBar: true
  555. }
  556. },
  557. beforeMount() {
  558. let avop = window.localStorage.getItem('pf.feed:avop') === 'always';
  559. let u = new URLSearchParams(window.location.search);
  560. if(u.has('a')) {
  561. switch(u.get('a')) {
  562. case 'recent_feed':
  563. if(this.scope === 'home') {
  564. this.recentFeed = true;
  565. }
  566. break;
  567. case 'vop':
  568. this.recentFeed = false;
  569. break;
  570. }
  571. }
  572. this.recentFeed = avop ? false : this.recentFeed;
  573. this.fetchProfile();
  574. this.fetchTimelineApi();
  575. },
  576. mounted() {
  577. // todo: release after dark mode updates
  578. /* if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches || $('link[data-stylesheet="dark"]').length != 0) {
  579. this.modes.dark = true;
  580. let el = document.querySelector('link[data-stylesheet="light"]');
  581. el.setAttribute('href', '/css/appdark.css?id=' + Date.now());
  582. el.setAttribute('data-stylesheet', 'dark');
  583. }*/
  584. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  585. this.showSuggestions = false;
  586. } else {
  587. this.showSuggestions = true;
  588. }
  589. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  590. this.showReadMore = false;
  591. } else {
  592. this.showReadMore = true;
  593. }
  594. if(localStorage.getItem('metro-tips') == 'false') {
  595. this.showTips = false;
  596. }
  597. this.$nextTick(function () {
  598. $('[data-toggle="tooltip"]').tooltip();
  599. let u = new URLSearchParams(window.location.search);
  600. if(u.has('a')) {
  601. switch(u.get('a')) {
  602. case 'co':
  603. $('#composeModal').modal('show');
  604. break;
  605. }
  606. }
  607. });
  608. },
  609. updated() {
  610. if(this.showReadMore == true) {
  611. pixelfed.readmore();
  612. }
  613. },
  614. methods: {
  615. fetchProfile() {
  616. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  617. this.profile = res.data;
  618. if(this.profile.is_admin == true) {
  619. this.modes.mod = true;
  620. }
  621. window._sharedData.curUser = res.data;
  622. window.App.util.navatar();
  623. this.hasStory();
  624. // this.expRec();
  625. }).catch(err => {
  626. swal(
  627. 'Oops, something went wrong',
  628. 'Please reload the page.',
  629. 'error'
  630. );
  631. });
  632. },
  633. fetchTimelineApi() {
  634. let apiUrl = false;
  635. switch(this.scope) {
  636. case 'home':
  637. apiUrl = '/api/pixelfed/v1/timelines/home';
  638. break;
  639. case 'local':
  640. apiUrl = '/api/pixelfed/v1/timelines/public';
  641. break;
  642. case 'network':
  643. apiUrl = '/api/pixelfed/v1/timelines/network';
  644. break;
  645. }
  646. axios.get(apiUrl, {
  647. params: {
  648. max_id: this.max_id,
  649. limit: 3,
  650. recent_feed: this.recentFeed
  651. }
  652. }).then(res => {
  653. let data = res.data;
  654. this.feed.push(...data);
  655. let ids = data.map(status => status.id);
  656. this.ids = ids;
  657. this.min_id = Math.max(...ids).toString();
  658. this.max_id = Math.min(...ids).toString();
  659. this.loading = false;
  660. $('.timeline .pagination').removeClass('d-none');
  661. if(this.hashtagPosts.length == 0) {
  662. this.fetchHashtagPosts();
  663. }
  664. // this.fetchStories();
  665. // this.rtw();
  666. setTimeout(function() {
  667. document.querySelectorAll('.timeline .card-body .comments .comment-body a').forEach(function(i, e) {
  668. i.href = App.util.format.rewriteLinks(i);
  669. });
  670. }, 500);
  671. axios.get('/api/pixelfed/v2/discover/posts/trending', {
  672. params: {
  673. range: 'daily'
  674. }
  675. }).then(res => {
  676. let data = res.data.filter(post => this.ids.indexOf(post.id) === -1);
  677. this.discover_feed = data;
  678. });
  679. }).catch(err => {
  680. swal(
  681. 'Oops, something went wrong',
  682. 'Please reload the page.',
  683. 'error'
  684. );
  685. });
  686. },
  687. infiniteTimeline($state) {
  688. if(this.loading) {
  689. $state.complete();
  690. return;
  691. }
  692. if(this.page > 40) {
  693. this.loading = false;
  694. $state.complete();
  695. }
  696. let apiUrl = false;
  697. switch(this.scope) {
  698. case 'home':
  699. apiUrl = '/api/pixelfed/v1/timelines/home';
  700. break;
  701. case 'local':
  702. apiUrl = '/api/pixelfed/v1/timelines/public';
  703. break;
  704. case 'network':
  705. apiUrl = '/api/pixelfed/v1/timelines/network';
  706. break;
  707. }
  708. axios.get(apiUrl, {
  709. params: {
  710. max_id: this.max_id,
  711. limit: 6,
  712. recent_feed: this.recentFeed
  713. },
  714. }).then(res => {
  715. if (res.data.length && this.loading == false) {
  716. let data = res.data;
  717. let self = this;
  718. let vids = [];
  719. if(self.recentFeed && self.ids.indexOf(data[0].id) != -1) {
  720. this.loading = false;
  721. $state.complete();
  722. return;
  723. }
  724. data.forEach((d, index) => {
  725. if(self.ids.indexOf(d.id) == -1) {
  726. self.feed.push(d);
  727. self.ids.push(d.id);
  728. // vids.push({
  729. // sid: d.id,
  730. // pid: d.account.id
  731. // });
  732. }
  733. });
  734. this.min_id = Math.max(...this.ids).toString();
  735. this.max_id = Math.min(...this.ids).toString();
  736. this.page += 1;
  737. $state.loaded();
  738. this.loading = false;
  739. // axios.post('/api/status/view', {
  740. // '_v': vids,
  741. // });
  742. } else {
  743. $state.complete();
  744. }
  745. }).catch(err => {
  746. this.loading = false;
  747. $state.complete();
  748. });
  749. },
  750. redirect(url) {
  751. window.location.href = url;
  752. return;
  753. },
  754. expRec() {
  755. //return;
  756. if(this.config.ab.rec == false) {
  757. return;
  758. }
  759. axios.get('/api/local/exp/rec')
  760. .then(res => {
  761. this.suggestions = res.data;
  762. })
  763. },
  764. expRecFollow(id, index) {
  765. return;
  766. if(this.config.ab.rec == false) {
  767. return;
  768. }
  769. axios.post('/i/follow', {
  770. item: id
  771. }).then(res => {
  772. this.suggestions.splice(index, 1);
  773. }).catch(err => {
  774. if(err.response.data.message) {
  775. swal('Error', err.response.data.message, 'error');
  776. }
  777. });
  778. },
  779. owner(status) {
  780. return this.profile.id === status.account.id;
  781. },
  782. admin() {
  783. return this.profile.is_admin == true;
  784. },
  785. ownerOrAdmin(status) {
  786. return this.owner(status) || this.admin();
  787. },
  788. hideSuggestions() {
  789. localStorage.setItem('pf_metro_ui.exp.rec', false);
  790. this.showSuggestions = false;
  791. },
  792. emojiReaction(status) {
  793. let em = event.target.innerText;
  794. if(this.replyText.length == 0) {
  795. this.replyText = em + ' ';
  796. $('textarea[name="comment"]').focus();
  797. } else {
  798. this.replyText += em + ' ';
  799. $('textarea[name="comment"]').focus();
  800. }
  801. },
  802. refreshSuggestions() {
  803. return;
  804. let el = event.target.parentNode;
  805. if(el.classList.contains('disabled') == true) {
  806. return;
  807. }
  808. axios.get('/api/local/exp/rec', {
  809. params: {
  810. refresh: true
  811. }
  812. })
  813. .then(res => {
  814. this.suggestions = res.data;
  815. if (el.classList) {
  816. el.classList.add('disabled');
  817. el.classList.add('text-light');
  818. }
  819. else {
  820. el.className += ' ' + 'disabled text-light';
  821. }
  822. setTimeout(function() {
  823. el.setAttribute('href', '#');
  824. if (el.classList) {
  825. el.classList.remove('disabled');
  826. el.classList.remove('text-light');
  827. }
  828. else {
  829. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  830. }
  831. }, 10000);
  832. });
  833. },
  834. fetchHashtagPosts() {
  835. axios.get('/api/local/discover/tag/list')
  836. .then(res => {
  837. let tags = res.data;
  838. if(tags.length == 0) {
  839. return;
  840. }
  841. let hashtag = tags[Math.floor(Math.random(), tags.length)];
  842. this.hashtagPostsName = hashtag;
  843. axios.get('/api/v2/discover/tag', {
  844. params: {
  845. hashtag: hashtag
  846. }
  847. }).then(res => {
  848. if(res.data.tags.length > 3) {
  849. this.showHashtagPosts = true;
  850. this.hashtagPosts = res.data.tags.splice(0,3);
  851. }
  852. })
  853. })
  854. },
  855. commentFocus(status, $event) {
  856. if(status.comments_disabled) {
  857. return;
  858. }
  859. // if(this.status && this.status.id == status.id) {
  860. // this.$refs.replyModal.show();
  861. // return;
  862. // }
  863. this.status = status;
  864. this.replies = {};
  865. this.replyStatus = {};
  866. this.replyText = '';
  867. this.replyId = status.id;
  868. this.replyStatus = status;
  869. // this.$refs.replyModal.show();
  870. this.fetchStatusComments(status, '');
  871. $('nav').hide();
  872. $('footer').hide();
  873. $('.mobile-footer-spacer').attr('style', 'display:none !important');
  874. $('.mobile-footer').attr('style', 'display:none !important');
  875. this.currentLayout = 'comments';
  876. window.history.pushState({}, '', this.statusUrl(status));
  877. return;
  878. },
  879. fetchStatusComments(status, card) {
  880. let url = '/api/v2/comments/'+status.account.id+'/status/'+status.id;
  881. axios.get(url)
  882. .then(response => {
  883. let self = this;
  884. this.replies = _.reverse(response.data.data);
  885. this.pagination = response.data.meta.pagination;
  886. if(this.replies.length > 0) {
  887. $('.load-more-link').removeClass('d-none');
  888. }
  889. $('.postCommentsLoader').addClass('d-none');
  890. $('.postCommentsContainer').removeClass('d-none');
  891. // setTimeout(function() {
  892. // document.querySelectorAll('.status-comment .postCommentsContainer .comment-body a').forEach(function(i, e) {
  893. // i.href = App.util.format.rewriteLinks(i);
  894. // });
  895. // }, 500);
  896. }).catch(error => {
  897. if(!error.response) {
  898. $('.postCommentsLoader .lds-ring')
  899. .attr('style','width:100%')
  900. .addClass('pt-4 font-weight-bold text-muted')
  901. .text('An error occurred, cannot fetch comments. Please try again later.');
  902. } else {
  903. switch(error.response.status) {
  904. case 401:
  905. $('.postCommentsLoader .lds-ring')
  906. .attr('style','width:100%')
  907. .addClass('pt-4 font-weight-bold text-muted')
  908. .text('Please login to view.');
  909. break;
  910. default:
  911. $('.postCommentsLoader .lds-ring')
  912. .attr('style','width:100%')
  913. .addClass('pt-4 font-weight-bold text-muted')
  914. .text('An error occurred, cannot fetch comments. Please try again later.');
  915. break;
  916. }
  917. }
  918. });
  919. },
  920. statusUrl(status) {
  921. if(status.local == true) {
  922. return status.url;
  923. }
  924. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  925. },
  926. profileUrl(status) {
  927. if(status.local == true) {
  928. return status.account.url;
  929. }
  930. return '/i/web/profile/_/' + status.account.id;
  931. },
  932. formatCount(count) {
  933. return App.util.format.count(count);
  934. },
  935. hasStory() {
  936. axios.get('/api/stories/v0/exists/'+this.profile.id)
  937. .then(res => {
  938. this.userStory = res.data;
  939. })
  940. },
  941. // real time watcher
  942. rtw() {
  943. this.mpPoller = setInterval(() => {
  944. let apiUrl = false;
  945. this.mpCount++;
  946. if(this.mpCount > 10) {
  947. this.mpInterval = 30000;
  948. }
  949. if(this.mpCount > 50) {
  950. this.mpInterval = (5 * 60 * 1000);
  951. }
  952. switch(this.scope) {
  953. case 'home':
  954. apiUrl = '/api/pixelfed/v1/timelines/home';
  955. break;
  956. case 'local':
  957. apiUrl = '/api/pixelfed/v1/timelines/public';
  958. break;
  959. case 'network':
  960. apiUrl = '/api/pixelfed/v1/timelines/network';
  961. break;
  962. }
  963. axios.get(apiUrl, {
  964. params: {
  965. max_id: 0,
  966. limit: 20,
  967. recent_feed: this.recentFeed
  968. }
  969. }).then(res => {
  970. let self = this;
  971. let tids = this.feed.map(status => status.id);
  972. let data = res.data.filter(d => {
  973. return d.id > self.min_id && tids.indexOf(d.id) == -1;
  974. });
  975. let ids = data.map(status => status.id);
  976. let max = Math.max(...ids).toString();
  977. let newer = max > this.min_id;
  978. if(newer) {
  979. this.morePostsAvailable = true;
  980. this.mpData = data;
  981. }
  982. });
  983. }, this.mpInterval);
  984. },
  985. syncNewPosts() {
  986. let self = this;
  987. let data = this.mpData;
  988. let ids = data.map(s => s.id);
  989. this.min_id = Math.max(...ids).toString();
  990. this.max_id = Math.min(...ids).toString();
  991. this.feed.unshift(...data);
  992. this.morePostsAvailable = false;
  993. this.mpData = null;
  994. },
  995. toggleReplies(reply) {
  996. if(reply.thread) {
  997. reply.thread = false;
  998. } else {
  999. if(reply.replies.length > 0) {
  1000. reply.thread = true;
  1001. return;
  1002. }
  1003. let url = '/api/v2/comments/'+reply.account.id+'/status/'+reply.id;
  1004. axios.get(url)
  1005. .then(response => {
  1006. reply.replies = _.reverse(response.data.data);
  1007. reply.thread = true;
  1008. });
  1009. }
  1010. },
  1011. replyFocus(e, index, prependUsername = false) {
  1012. if($('body').hasClass('loggedIn') == false) {
  1013. this.redirect('/login?next=' + encodeURIComponent(window.location.pathname));
  1014. return;
  1015. }
  1016. if(this.status.comments_disabled) {
  1017. return;
  1018. }
  1019. this.replyToIndex = index;
  1020. this.replyingToId = e.id;
  1021. this.replyingToUsername = e.account.username;
  1022. this.reply_to_profile_id = e.account.id;
  1023. let username = e.account.local ? '@' + e.account.username + ' '
  1024. : '@' + e.account.acct + ' ';
  1025. if(prependUsername == true) {
  1026. this.replyText = username;
  1027. }
  1028. this.$refs.replyModal.show();
  1029. setTimeout(function() {
  1030. $('.replyModalTextarea').focus();
  1031. }, 500);
  1032. },
  1033. alwaysViewOlderPosts() {
  1034. // Set Feed:Always View Older Posts
  1035. window.localStorage.setItem('pf.feed:avop', 'always');
  1036. window.location.href = '/';
  1037. },
  1038. setCurrentLayout(layout) {
  1039. this.currentLayout = layout;
  1040. },
  1041. deleteStatus(status) {
  1042. this.feed = this.feed.filter(s => {
  1043. return s.id != status;
  1044. });
  1045. }
  1046. },
  1047. beforeDestroy () {
  1048. clearInterval(this.mpInterval);
  1049. }
  1050. }
  1051. </script>
  1052. <style type="text/css" scoped>
  1053. .postPresenterContainer {
  1054. display: flex;
  1055. align-items: center;
  1056. background: #fff;
  1057. }
  1058. .word-break {
  1059. word-break: break-all;
  1060. }
  1061. .small .custom-control-label {
  1062. padding-top: 3px;
  1063. }
  1064. /*.reply-btn {
  1065. position: absolute;
  1066. bottom: 30px;
  1067. right: 20px;
  1068. width: 60px;
  1069. text-align: center;
  1070. font-size: 13px;
  1071. border-radius: 0 3px 3px 0;
  1072. }*/
  1073. .reply-btn[disabled] {
  1074. opacity: .3;
  1075. color: #3897f0;
  1076. }
  1077. .replyModalTextarea {
  1078. border: none;
  1079. font-size: 18px;
  1080. resize: none;
  1081. white-space: pre-wrap;
  1082. outline: none;
  1083. }
  1084. .has-story {
  1085. width: 64px;
  1086. height: 64px;
  1087. border-radius: 50%;
  1088. padding: 2px;
  1089. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  1090. }
  1091. .has-story img {
  1092. width: 60px;
  1093. height: 60px;
  1094. border-radius: 50%;
  1095. padding: 3px;
  1096. background: #fff;
  1097. }
  1098. .has-story.has-story-sm {
  1099. width: 32px;
  1100. height: 32px;
  1101. border-radius: 50%;
  1102. padding: 2px;
  1103. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  1104. }
  1105. .has-story.has-story-sm img {
  1106. width: 28px;
  1107. height: 28px;
  1108. border-radius: 50%;
  1109. padding: 3px;
  1110. background: #fff;
  1111. }
  1112. #ctx-reply-modal .form-control:focus {
  1113. border: none;
  1114. outline: 0;
  1115. box-shadow: none;
  1116. }
  1117. </style>