Timeline.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  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. formatCount(count) {
  880. return App.util.format.count(count);
  881. },
  882. hasStory() {
  883. axios.get('/api/stories/v0/exists/'+this.profile.id)
  884. .then(res => {
  885. this.userStory = res.data;
  886. })
  887. },
  888. // real time watcher
  889. rtw() {
  890. this.mpPoller = setInterval(() => {
  891. let apiUrl = false;
  892. this.mpCount++;
  893. if(this.mpCount > 10) {
  894. this.mpInterval = 30000;
  895. }
  896. if(this.mpCount > 50) {
  897. this.mpInterval = (5 * 60 * 1000);
  898. }
  899. switch(this.scope) {
  900. case 'home':
  901. apiUrl = '/api/pixelfed/v1/timelines/home';
  902. break;
  903. case 'local':
  904. apiUrl = '/api/pixelfed/v1/timelines/public';
  905. break;
  906. case 'network':
  907. apiUrl = '/api/pixelfed/v1/timelines/network';
  908. break;
  909. }
  910. axios.get(apiUrl, {
  911. params: {
  912. max_id: 0,
  913. limit: 20,
  914. recent_feed: this.recentFeed
  915. }
  916. }).then(res => {
  917. let self = this;
  918. let tids = this.feed.map(status => status.id);
  919. let data = res.data.filter(d => {
  920. return d.id > self.min_id && tids.indexOf(d.id) == -1;
  921. });
  922. let ids = data.map(status => status.id);
  923. let max = Math.max(...ids).toString();
  924. let newer = max > this.min_id;
  925. if(newer) {
  926. this.morePostsAvailable = true;
  927. this.mpData = data;
  928. }
  929. });
  930. }, this.mpInterval);
  931. },
  932. syncNewPosts() {
  933. let self = this;
  934. let data = this.mpData;
  935. let ids = data.map(s => s.id);
  936. this.min_id = Math.max(...ids).toString();
  937. this.max_id = Math.min(...ids).toString();
  938. this.feed.unshift(...data);
  939. this.morePostsAvailable = false;
  940. this.mpData = null;
  941. },
  942. toggleReplies(reply) {
  943. if(reply.thread) {
  944. reply.thread = false;
  945. } else {
  946. if(reply.replies.length > 0) {
  947. reply.thread = true;
  948. return;
  949. }
  950. let url = '/api/v2/comments/'+reply.account.id+'/status/'+reply.id;
  951. axios.get(url)
  952. .then(response => {
  953. reply.replies = _.reverse(response.data.data);
  954. reply.thread = true;
  955. });
  956. }
  957. },
  958. replyFocus(e, index, prependUsername = false) {
  959. if($('body').hasClass('loggedIn') == false) {
  960. this.redirect('/login?next=' + encodeURIComponent(window.location.pathname));
  961. return;
  962. }
  963. if(this.status.comments_disabled) {
  964. return;
  965. }
  966. this.replyToIndex = index;
  967. this.replyingToId = e.id;
  968. this.replyingToUsername = e.account.username;
  969. this.reply_to_profile_id = e.account.id;
  970. let username = e.account.local ? '@' + e.account.username + ' '
  971. : '@' + e.account.acct + ' ';
  972. if(prependUsername == true) {
  973. this.replyText = username;
  974. }
  975. this.$refs.replyModal.show();
  976. setTimeout(function() {
  977. $('.replyModalTextarea').focus();
  978. }, 500);
  979. },
  980. alwaysViewOlderPosts() {
  981. // Set Feed:Always View Older Posts
  982. window.localStorage.setItem('pf.feed:avop', 'always');
  983. window.location.href = '/';
  984. },
  985. setCurrentLayout(layout) {
  986. this.currentLayout = layout;
  987. },
  988. deleteStatus(status) {
  989. this.feed = this.feed.filter(s => {
  990. return s.id != status;
  991. });
  992. }
  993. },
  994. beforeDestroy () {
  995. clearInterval(this.mpInterval);
  996. }
  997. }
  998. </script>
  999. <style type="text/css" scoped>
  1000. .postPresenterContainer {
  1001. display: flex;
  1002. align-items: center;
  1003. background: #fff;
  1004. }
  1005. .word-break {
  1006. word-break: break-all;
  1007. }
  1008. .small .custom-control-label {
  1009. padding-top: 3px;
  1010. }
  1011. /*.reply-btn {
  1012. position: absolute;
  1013. bottom: 30px;
  1014. right: 20px;
  1015. width: 60px;
  1016. text-align: center;
  1017. font-size: 13px;
  1018. border-radius: 0 3px 3px 0;
  1019. }*/
  1020. .reply-btn[disabled] {
  1021. opacity: .3;
  1022. color: #3897f0;
  1023. }
  1024. .replyModalTextarea {
  1025. border: none;
  1026. font-size: 18px;
  1027. resize: none;
  1028. white-space: pre-wrap;
  1029. outline: none;
  1030. }
  1031. .has-story {
  1032. width: 64px;
  1033. height: 64px;
  1034. border-radius: 50%;
  1035. padding: 2px;
  1036. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  1037. }
  1038. .has-story img {
  1039. width: 60px;
  1040. height: 60px;
  1041. border-radius: 50%;
  1042. padding: 3px;
  1043. background: #fff;
  1044. }
  1045. .has-story.has-story-sm {
  1046. width: 32px;
  1047. height: 32px;
  1048. border-radius: 50%;
  1049. padding: 2px;
  1050. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  1051. }
  1052. .has-story.has-story-sm img {
  1053. width: 28px;
  1054. height: 28px;
  1055. border-radius: 50%;
  1056. padding: 3px;
  1057. background: #fff;
  1058. }
  1059. #ctx-reply-modal .form-control:focus {
  1060. border: none;
  1061. outline: 0;
  1062. box-shadow: none;
  1063. }
  1064. </style>