Timeline.vue 40 KB

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