Timeline.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158
  1. <template>
  2. <div class="container" style="">
  3. <div class="row">
  4. <div :class="[modes.distractionFree ? 'col-md-8 col-lg-8 offset-md-2 pt-sm-2 px-0 my-sm-3 timeline order-2 order-md-1':'col-md-8 col-lg-8 pt-sm-2 px-0 my-sm-3 timeline order-2 order-md-1']">
  5. <div style="padding-top:10px;">
  6. <div v-if="loading" class="text-center">
  7. <div class="spinner-border" role="status">
  8. <span class="sr-only">Loading...</span>
  9. </div>
  10. </div>
  11. <div :data-status-id="status.id" v-for="(status, index) in feed" :key="`${index}-${status.id}`">
  12. <div v-if="index == 2 && showSuggestions == true && suggestions.length" class="card mb-sm-4 status-card card-md-rounded-0">
  13. <div class="card-header d-flex align-items-center justify-content-between bg-white border-0 pb-0">
  14. <h6 class="text-muted font-weight-bold mb-0">Suggestions For You</h6>
  15. <span class="cursor-pointer text-muted" v-on:click="hideSuggestions"><i class="fas fa-times"></i></span>
  16. </div>
  17. <div class="card-body row mx-0">
  18. <div class="col-12 col-md-4 mb-3" v-for="(rec, index) in suggestions">
  19. <div class="card">
  20. <div class="card-body text-center pt-3">
  21. <p class="mb-0">
  22. <a :href="'/'+rec.username">
  23. <img :src="rec.avatar" class="img-fluid rounded-circle cursor-pointer" width="45px" height="45px">
  24. </a>
  25. </p>
  26. <div class="py-3">
  27. <p class="font-weight-bold text-dark cursor-pointer mb-0">
  28. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  29. {{rec.username}}
  30. </a>
  31. </p>
  32. <p class="small text-muted mb-0">{{rec.message}}</p>
  33. </div>
  34. <p class="mb-0">
  35. <a class="btn btn-primary btn-block font-weight-bold py-0" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  36. </p>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <div class="card mb-sm-4 status-card card-md-rounded-0">
  43. <div v-if="!modes.distractionFree" class="card-header d-inline-flex align-items-center bg-white">
  44. <img v-bind:src="status.account.avatar" width="32px" height="32px" style="border-radius: 32px;">
  45. <a class="username font-weight-bold pl-2 text-dark" v-bind:href="status.account.url">
  46. {{status.account.username}}
  47. </a>
  48. <div class="text-right" style="flex-grow:1;">
  49. <button class="btn btn-link text-dark no-caret dropdown-toggle py-0" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="Post options">
  50. <span class="fas fa-ellipsis-v fa-lg text-muted"></span>
  51. </button>
  52. <div class="dropdown-menu dropdown-menu-right">
  53. <a class="dropdown-item font-weight-bold" :href="status.url">Go to post</a>
  54. <!-- <a class="dropdown-item font-weight-bold" href="#">Share</a>
  55. <a class="dropdown-item font-weight-bold" href="#">Embed</a> -->
  56. <span v-if="statusOwner(status) == false">
  57. <a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
  58. <a class="dropdown-item font-weight-bold" v-on:click="muteProfile(status)">Mute Profile</a>
  59. <a class="dropdown-item font-weight-bold" v-on:click="blockProfile(status)">Block Profile</a>
  60. </span>
  61. <span v-if="statusOwner(status) == true">
  62. <a class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  63. </span>
  64. <span v-if="profile.is_admin == true && modes.mod == true">
  65. <div class="dropdown-divider"></div>
  66. <a v-if="!statusOwner(status)" class="dropdown-item font-weight-bold text-danger" v-on:click="deletePost(status)">Delete</a>
  67. <div class="dropdown-divider"></div>
  68. <h6 class="dropdown-header">Mod Tools</h6>
  69. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'autocw')">
  70. <p class="mb-0" data-toggle="tooltip" data-placement="bottom" title="Adds a CW to every post made by this account.">Enforce CW</p>
  71. </a>
  72. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'noautolink')">
  73. <p class="mb-0" title="Do not transform mentions, hashtags or urls into HTML.">No Autolinking</p>
  74. </a>
  75. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'unlisted')">
  76. <p class="mb-0" title="Removes account from public/network timelines.">Unlisted Posts</p>
  77. </a>
  78. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'disable')">
  79. <p class="mb-0" title="Temporarily disable account until next time user log in.">Disable Account</p>
  80. </a>
  81. <a class="dropdown-item font-weight-bold" v-on:click="moderatePost(status, 'suspend')">
  82. <p class="mb-0" title="This prevents any new interactions, without deleting existing data.">Suspend Account</p>
  83. </a>
  84. </span>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="postPresenterContainer" v-on:dblclick="likeStatus(status)">
  89. <div v-if="status.pf_type === 'photo'" class="w-100">
  90. <photo-presenter :status="status" v-on:lightbox="lightbox"></photo-presenter>
  91. </div>
  92. <div v-else-if="status.pf_type === 'video'" class="w-100">
  93. <video-presenter :status="status"></video-presenter>
  94. </div>
  95. <div v-else-if="status.pf_type === 'photo:album'" class="w-100">
  96. <photo-album-presenter :status="status" v-on:lightbox="lightbox"></photo-album-presenter>
  97. </div>
  98. <div v-else-if="status.pf_type === 'video:album'" class="w-100">
  99. <video-album-presenter :status="status"></video-album-presenter>
  100. </div>
  101. <div v-else-if="status.pf_type === 'photo:video:album'" class="w-100">
  102. <mixed-album-presenter :status="status" v-on:lightbox="lightbox"></mixed-album-presenter>
  103. </div>
  104. <div v-else class="w-100">
  105. <p class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
  106. </div>
  107. </div>
  108. <div class="card-body">
  109. <div v-if="!modes.distractionFree" class="reactions my-1">
  110. <h3 v-bind:class="[status.favourited ? 'fas fa-heart text-danger pr-3 m-0 cursor-pointer' : 'far fa-heart pr-3 m-0 like-btn cursor-pointer']" title="Like" v-on:click="likeStatus(status, $event)"></h3>
  111. <h3 v-if="!status.comments_disabled" class="far fa-comment pr-3 m-0 cursor-pointer" title="Comment" v-on:click="commentFocus(status, $event)"></h3>
  112. <h3 v-bind:class="[status.reblogged ? 'far fa-share-square pr-3 m-0 text-primary cursor-pointer' : 'far fa-share-square pr-3 m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus(status, $event)"></h3>
  113. </div>
  114. <div class="likes font-weight-bold" v-if="expLc(status) == true && !modes.distractionFree">
  115. <span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}}
  116. </div>
  117. <div class="caption">
  118. <p class="mb-2 read-more" style="overflow: hidden;">
  119. <span class="username font-weight-bold">
  120. <bdi><a class="text-dark" :href="status.account.url">{{status.account.username}}</a></bdi>
  121. </span>
  122. <span v-html="status.content"></span>
  123. </p>
  124. </div>
  125. <div class="comments" v-if="status.id == replyId && !status.comments_disabled">
  126. <p class="mb-0 d-flex justify-content-between align-items-top read-more" style="overflow-y: hidden;" v-for="(reply, index) in replies">
  127. <span>
  128. <a class="text-dark font-weight-bold mr-1" :href="reply.account.url">{{reply.account.username}}</a>
  129. <span v-html="reply.content"></span>
  130. </span>
  131. <span class="mb-0" style="min-width:38px">
  132. <span v-on:click="likeStatus(reply, $event)"><i v-bind:class="[reply.favourited ? 'fas fa-heart fa-sm text-danger':'far fa-heart fa-sm text-lighter']"></i></span>
  133. <post-menu :status="reply" :profile="profile" size="sm" :modal="'true'" :feed="feed" class="d-inline-flex pl-2"></post-menu>
  134. </span>
  135. </p>
  136. </div>
  137. <div class="timestamp mt-2">
  138. <p class="small text-uppercase mb-0">
  139. <a :href="status.url" class="text-muted">
  140. <timeago :datetime="status.created_at" :auto-update="60" :converter-options="{includeSeconds:true}" :title="timestampFormat(status.created_at)" v-b-tooltip.hover.bottom></timeago>
  141. </a>
  142. <a v-if="modes.distractionFree" class="float-right" :href="status.url">
  143. <i class="fas fa-ellipsis-h fa-lg text-muted"></i>
  144. </a>
  145. </p>
  146. </div>
  147. </div>
  148. <div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white px-2 py-0">
  149. <ul class="nav align-items-center emoji-reactions" style="overflow-x: scroll;flex-wrap: unset;">
  150. <li class="nav-item" v-on:click="emojiReaction(status)">😂</li>
  151. <li class="nav-item" v-on:click="emojiReaction(status)">💯</li>
  152. <li class="nav-item" v-on:click="emojiReaction(status)">❤️</li>
  153. <li class="nav-item" v-on:click="emojiReaction(status)">🙌</li>
  154. <li class="nav-item" v-on:click="emojiReaction(status)">👏</li>
  155. <li class="nav-item" v-on:click="emojiReaction(status)">😍</li>
  156. <li class="nav-item" v-on:click="emojiReaction(status)">😯</li>
  157. <li class="nav-item" v-on:click="emojiReaction(status)">😢</li>
  158. <li class="nav-item" v-on:click="emojiReaction(status)">😅</li>
  159. <li class="nav-item" v-on:click="emojiReaction(status)">😁</li>
  160. <li class="nav-item" v-on:click="emojiReaction(status)">🙂</li>
  161. <li class="nav-item" v-on:click="emojiReaction(status)">😎</li>
  162. </ul>
  163. </div>
  164. <div v-if="status.id == replyId && !status.comments_disabled" class="card-footer bg-white sticky-md-bottom p-0">
  165. <form class="border-0 rounded-0 align-middle" method="post" action="/i/comment" :data-id="status.id" data-truncate="false">
  166. <textarea class="form-control border-0 rounded-0" name="comment" placeholder="Add a comment…" autocomplete="off" autocorrect="off" style="height:56px;line-height: 18px;max-height:80px;resize: none; padding-right:4.2rem;" v-model="replyText"></textarea>
  167. <input type="button" value="Post" class="d-inline-block btn btn-link font-weight-bold reply-btn text-decoration-none" v-on:click.prevent="commentSubmit(status, $event)"/>
  168. </form>
  169. </div>
  170. </div>
  171. </div>
  172. <div v-if="modes.infinite == true && !loading && feed.length > 0">
  173. <div class="card">
  174. <div class="card-body">
  175. <infinite-loading @infinite="infiniteTimeline" :distance="800">
  176. <div slot="no-more" class="font-weight-bold">No more posts to load</div>
  177. <div slot="no-results" class="font-weight-bold">No posts found</div>
  178. </infinite-loading>
  179. </div>
  180. </div>
  181. </div>
  182. <div v-if="modes.infinite == false && !loading && feed.length > 0" class="pagination">
  183. <p class="btn btn-outline-secondary font-weight-bold btn-block" v-on:click="loadMore">Load more posts</p>
  184. </div>
  185. <div v-if="!loading && scope == 'home' && feed.length == 0">
  186. <div class="card">
  187. <div class="card-body text-center">
  188. <p class="h2 font-weight-lighter p-5">Hello, {{profile.acct}}</p>
  189. <p class="text-lighter"><i class="fas fa-camera-retro fa-5x"></i></p>
  190. <p class="h3 font-weight-lighter p-5">Start following people to build your timeline.</p>
  191. <p><a href="/discover" class="btn btn-primary font-weight-bold py-0">Discover new people and posts</a></p>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. <div v-if="!modes.distractionFree" class="col-md-4 col-lg-4 pt-2 my-3 order-1 order-md-2 d-none d-md-block">
  198. <div class="position-sticky" style="top:68px;">
  199. <div class="mb-4">
  200. <div class="">
  201. <div class="">
  202. <div class="media d-flex align-items-center">
  203. <a :href="profile.url">
  204. <img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
  205. </a>
  206. <div class="media-body d-flex justify-content-between word-break" >
  207. <div>
  208. <p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">{{profile.username || 'loading...'}}</a></p>
  209. <p class="my-0 text-muted pb-0">{{profile.display_name || 'loading...'}}</p>
  210. </div>
  211. <div class="ml-2">
  212. <a :class="[optionMenuState == true ? 'text-primary' :'text-muted']" v-on:click="toggleOptionsMenu()"><i class="fas fa-cog fa-lg"></i></a>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. <!-- <div class="card-footer bg-white py-1 d-none">
  218. <div class="d-flex justify-content-between text-center">
  219. <span class="pl-3 cursor-pointer" v-on:click="redirect(profile.url)">
  220. <p class="mb-0 font-weight-bold">{{profile.statuses_count}}</p>
  221. <p class="mb-0 small text-muted">Posts</p>
  222. </span>
  223. <span class="cursor-pointer" v-on:click="followersModal()">
  224. <p class="mb-0 font-weight-bold">{{profile.followers_count}}</p>
  225. <p class="mb-0 small text-muted">Followers</p>
  226. </span>
  227. <span class="pr-3 cursor-pointer" v-on:click="followingModal()">
  228. <p class="mb-0 font-weight-bold">{{profile.following_count}}</p>
  229. <p class="mb-0 small text-muted">Following</p>
  230. </span>
  231. </div>
  232. </div> -->
  233. </div>
  234. </div>
  235. <div v-if="optionMenuState == true" class="mb-4">
  236. <div class="card options-card">
  237. <div class="card-body small">
  238. <div v-if="profile.is_admin" class="custom-control custom-switch mb-3">
  239. <input type="checkbox" class="custom-control-input" id="mode-mod" v-on:click="modeModToggle()" v-model="modes.mod">
  240. <label class="custom-control-label font-weight-bold" for="mode-mod">Moderator Mode</label>
  241. </div>
  242. <!-- <div class="custom-control custom-switch mb-3">
  243. <input type="checkbox" class="custom-control-input" id="mode-notify" v-on:click="modeNotifyToggle()" v-model="!modes.notify">
  244. <label class="custom-control-label font-weight-bold" for="mode-notify">Disable Notifications</label>
  245. </div> -->
  246. <div class="custom-control custom-switch">
  247. <input type="checkbox" class="custom-control-input" id="mode-infinite" v-on:click="modeInfiniteToggle()" v-model="modes.infinite">
  248. <label class="custom-control-label font-weight-bold" for="mode-infinite">Enable Infinite Scroll</label>
  249. </div>
  250. <hr>
  251. <p class="font-weight-bold">BETA FEATURES</p>
  252. <div class="alert alert-primary font-weight-bold text-center">Experimental features have been moved to the <a href="/settings/labs">Labs</a> settings page.</div>
  253. </div>
  254. </div>
  255. </div>
  256. <div v-show="modes.notify == true" class="mb-4">
  257. <notification-card></notification-card>
  258. </div>
  259. <div v-show="showSuggestions == true && suggestions.length && config.ab && config.ab.rec == true" class="mb-4">
  260. <div class="card">
  261. <div class="card-header bg-white d-flex align-items-center justify-content-between">
  262. <a class="small text-muted cursor-pointer" href="#" @click.prevent="refreshSuggestions" ref="suggestionRefresh"><i class="fas fa-sync-alt"></i></a>
  263. <div class="small text-dark text-uppercase font-weight-bold">Suggestions</div>
  264. <div class="small text-muted cursor-pointer" v-on:click="hideSuggestions"><i class="fas fa-times"></i></div>
  265. </div>
  266. <div class="card-body pt-0">
  267. <div v-for="(rec, index) in suggestions" class="media align-items-center mt-3">
  268. <a :href="'/'+rec.username">
  269. <img :src="rec.avatar" width="32px" height="32px" class="rounded-circle mr-3">
  270. </a>
  271. <div class="media-body">
  272. <p class="mb-0 font-weight-bold small">
  273. <a :href="'/'+rec.username" class="text-decoration-none text-dark">
  274. {{rec.username}}
  275. </a>
  276. </p>
  277. <p class="mb-0 small text-muted">{{rec.message}}</p>
  278. </div>
  279. <a class="font-weight-bold small" href="#" @click.prevent="expRecFollow(rec.id, index)">Follow</a>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. <footer>
  285. <div class="container pb-5">
  286. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  287. <a href="/site/about" class="text-dark pr-2">About Us</a>
  288. <a href="/site/help" class="text-dark pr-2">Help</a>
  289. <a href="/site/open-source" class="text-dark pr-2">Open Source</a>
  290. <a href="/site/language" class="text-dark pr-2">Language</a>
  291. <a href="/site/terms" class="text-dark pr-2">Terms</a>
  292. <a href="/site/privacy" class="text-dark pr-2">Privacy</a>
  293. <a href="/site/platform" class="text-dark pr-2">API</a>
  294. </p>
  295. <p class="mb-0 text-uppercase font-weight-bold text-muted small">
  296. <a href="http://pixelfed.org" class="text-muted" rel="noopener" title="" data-toggle="tooltip">Powered by PixelFed</a>
  297. </p>
  298. </div>
  299. </footer>
  300. </div>
  301. </div>
  302. </div>
  303. <!-- <b-modal ref="followingModal"
  304. id="following-modal"
  305. hide-footer
  306. centered
  307. title="Following"
  308. body-class="list-group-flush p-0">
  309. <div class="list-group">
  310. <div class="list-group-item border-0" v-for="(user, index) in following" :key="'following_'+index">
  311. <div class="media">
  312. <a :href="user.url">
  313. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  314. </a>
  315. <div class="media-body">
  316. <p class="mb-0" style="font-size: 14px">
  317. <a :href="user.url" class="font-weight-bold text-dark">
  318. {{user.username}}
  319. </a>
  320. </p>
  321. <p class="text-muted mb-0" style="font-size: 14px">
  322. {{user.display_name}}
  323. </p>
  324. </div>
  325. <a class="btn btn-outline-secondary btn-sm" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Unfollow</a>
  326. </div>
  327. </div>
  328. <div v-if="following.length == 0" class="list-group-item border-0">
  329. <div class="list-group-item border-0">
  330. <p class="p-3 text-center mb-0 lead">You are not following anyone.</p>
  331. </div>
  332. </div>
  333. <div v-if="following.length != 0 && followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  334. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  335. </div>
  336. </div>
  337. </b-modal>
  338. <b-modal ref="followerModal"
  339. id="follower-modal"
  340. hide-footer
  341. centered
  342. title="Followers"
  343. body-class="list-group-flush p-0">
  344. <div class="list-group">
  345. <div class="list-group-item border-0" v-for="(user, index) in followers" :key="'follower_'+index">
  346. <div class="media">
  347. <a :href="user.url">
  348. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px">
  349. </a>
  350. <div class="media-body">
  351. <p class="mb-0" style="font-size: 14px">
  352. <a :href="user.url" class="font-weight-bold text-dark">
  353. {{user.username}}
  354. </a>
  355. </p>
  356. <p class="text-muted mb-0" style="font-size: 14px">
  357. {{user.display_name}}
  358. </p>
  359. </div>
  360. </div>
  361. </div>
  362. <div v-if="followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  363. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  364. </div>
  365. </div>
  366. </b-modal> -->
  367. <b-modal
  368. id="lightbox"
  369. ref="lightboxModal"
  370. hide-header
  371. hide-footer
  372. centered
  373. size="lg"
  374. body-class="p-0"
  375. >
  376. <div v-if="lightboxMedia" :class="lightboxMedia.filter_class">
  377. <img :src="lightboxMedia.url" class="img-fluid" style="min-height: 100%; min-width: 100%">
  378. </div>
  379. </b-modal>
  380. </div>
  381. </template>
  382. <style type="text/css" scoped>
  383. .postPresenterContainer {
  384. display: flex;
  385. align-items: center;
  386. background: #fff;
  387. }
  388. .word-break {
  389. word-break: break-all;
  390. }
  391. .small .custom-control-label {
  392. padding-top: 3px;
  393. }
  394. .reply-btn {
  395. position: absolute;
  396. bottom: 12px;
  397. right: 20px;
  398. width: 60px;
  399. text-align: center;
  400. border-radius: 0 3px 3px 0;
  401. }
  402. .emoji-reactions .nav-item {
  403. font-size: 1.2rem;
  404. padding: 9px;
  405. cursor: pointer;
  406. }
  407. .emoji-reactions::-webkit-scrollbar {
  408. width: 0px;
  409. height: 0px;
  410. background: transparent;
  411. }
  412. </style>
  413. <script type="text/javascript">
  414. export default {
  415. props: ['scope'],
  416. data() {
  417. return {
  418. ids: [],
  419. config: {},
  420. page: 2,
  421. feed: [],
  422. profile: {},
  423. min_id: 0,
  424. max_id: 0,
  425. stories: {},
  426. suggestions: {},
  427. loading: true,
  428. replies: [],
  429. replyId: null,
  430. optionMenuState: false,
  431. modes: {
  432. 'mod': false,
  433. 'dark': false,
  434. 'notify': true,
  435. 'infinite': true,
  436. 'distractionFree': false
  437. },
  438. followers: [],
  439. followerCursor: 1,
  440. followerMore: true,
  441. following: [],
  442. followingCursor: 1,
  443. followingMore: true,
  444. lightboxMedia: false,
  445. showSuggestions: false,
  446. showReadMore: true,
  447. replyStatus: {},
  448. replyText: ''
  449. }
  450. },
  451. beforeMount() {
  452. axios.get('/api/v2/config')
  453. .then(res => {
  454. this.config = res.data;
  455. this.fetchProfile();
  456. this.fetchTimelineApi();
  457. });
  458. },
  459. mounted() {
  460. if($('link[data-stylesheet="dark"]').length != 0) {
  461. this.modes.dark = true;
  462. }
  463. if(localStorage.getItem('pf_metro_ui.exp.rec') == 'false') {
  464. this.showSuggestions = false;
  465. } else {
  466. this.showSuggestions = true;
  467. }
  468. if(localStorage.getItem('pf_metro_ui.exp.rm') == 'false') {
  469. this.showReadMore = false;
  470. } else {
  471. this.showReadMore = true;
  472. }
  473. if(localStorage.getItem('pf_metro_ui.exp.df') == 'true') {
  474. this.modes.distractionFree = true;
  475. } else {
  476. this.modes.distractionFree = false;
  477. }
  478. this.$nextTick(function () {
  479. $('[data-toggle="tooltip"]').tooltip()
  480. });
  481. },
  482. updated() {
  483. if(this.showReadMore == true) {
  484. pixelfed.readmore();
  485. }
  486. },
  487. methods: {
  488. fetchProfile() {
  489. axios.get('/api/v1/accounts/verify_credentials').then(res => {
  490. this.profile = res.data;
  491. if(this.profile.is_admin == true) {
  492. this.modes.mod = true;
  493. }
  494. $('.profile-card .loader').addClass('d-none');
  495. $('.profile-card .contents').removeClass('d-none');
  496. $('.profile-card .card-footer').removeClass('d-none');
  497. this.expRec();
  498. }).catch(err => {
  499. swal(
  500. 'Oops, something went wrong',
  501. 'Please reload the page.',
  502. 'error'
  503. );
  504. });
  505. },
  506. fetchTimelineApi() {
  507. let apiUrl = false;
  508. switch(this.scope) {
  509. case 'home':
  510. apiUrl = '/api/v1/timelines/home';
  511. break;
  512. case 'local':
  513. apiUrl = '/api/v1/timelines/public';
  514. break;
  515. case 'network':
  516. apiUrl = '/api/v1/timelines/network';
  517. break;
  518. }
  519. axios.get(apiUrl, {
  520. params: {
  521. max_id: this.max_id,
  522. limit: 6
  523. }
  524. }).then(res => {
  525. let data = res.data;
  526. this.feed.push(...data);
  527. let ids = data.map(status => status.id);
  528. this.ids = ids;
  529. this.min_id = Math.max(...ids);
  530. this.max_id = Math.min(...ids);
  531. $('.timeline .pagination').removeClass('d-none');
  532. this.loading = false;
  533. }).catch(err => {
  534. });
  535. },
  536. infiniteTimeline($state) {
  537. if(this.loading) {
  538. return;
  539. }
  540. let apiUrl = false;
  541. switch(this.scope) {
  542. case 'home':
  543. apiUrl = '/api/v1/timelines/home';
  544. break;
  545. case 'local':
  546. apiUrl = '/api/v1/timelines/public';
  547. break;
  548. case 'network':
  549. apiUrl = '/api/v1/timelines/network';
  550. break;
  551. }
  552. axios.get(apiUrl, {
  553. params: {
  554. max_id: this.max_id,
  555. limit: 6
  556. },
  557. }).then(res => {
  558. if (res.data.length && this.loading == false) {
  559. let data = res.data;
  560. let self = this;
  561. data.forEach(d => {
  562. if(self.ids.indexOf(d.id) == -1) {
  563. self.feed.push(d);
  564. self.ids.push(d.id);
  565. }
  566. });
  567. this.min_id = Math.max(...this.ids);
  568. this.max_id = Math.min(...this.ids);
  569. this.page += 1;
  570. $state.loaded();
  571. this.loading = false;
  572. } else {
  573. $state.complete();
  574. }
  575. });
  576. },
  577. loadMore(event) {
  578. let homeTimeline = '/api/v1/timelines/home';
  579. let localTimeline = '/api/v1/timelines/public';
  580. let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline;
  581. event.target.innerText = 'Loading...';
  582. axios.get(apiUrl, {
  583. params: {
  584. page: this.page,
  585. },
  586. }).then(res => {
  587. if (res.data.length && this.loading == false) {
  588. let data = res.data;
  589. let ids = data.map(status => status.id);
  590. this.min_id = Math.min(...ids);
  591. if(this.page == 1) {
  592. this.max_id = Math.max(...ids);
  593. }
  594. this.feed.push(...data);
  595. this.page += 1;
  596. this.loading = false;
  597. event.target.innerText = 'Load more posts';
  598. } else {
  599. }
  600. });
  601. },
  602. reportUrl(status) {
  603. let type = status.in_reply_to ? 'comment' : 'post';
  604. let id = status.id;
  605. return '/i/report?type=' + type + '&id=' + id;
  606. },
  607. commentFocus(status, $event) {
  608. if(this.replyId == status.id || status.comments_disabled) {
  609. return;
  610. }
  611. this.replies = {};
  612. this.replyStatus = {};
  613. this.replyText = '';
  614. this.replyId = status.id;
  615. this.replyStatus = status;
  616. this.fetchStatusComments(status, '');
  617. },
  618. likeStatus(status) {
  619. if($('body').hasClass('loggedIn') == false) {
  620. return;
  621. }
  622. axios.post('/i/like', {
  623. item: status.id
  624. }).then(res => {
  625. status.favourites_count = res.data.count;
  626. status.favourited = !status.favourited;
  627. }).catch(err => {
  628. swal('Error', 'Something went wrong, please try again later.', 'error');
  629. });
  630. },
  631. shareStatus(status, $event) {
  632. if($('body').hasClass('loggedIn') == false) {
  633. return;
  634. }
  635. axios.post('/i/share', {
  636. item: status.id
  637. }).then(res => {
  638. status.reblogs_count = res.data.count;
  639. status.reblogged = !status.reblogged;
  640. }).catch(err => {
  641. swal('Error', 'Something went wrong, please try again later.', 'error');
  642. });
  643. },
  644. timestampFormat(timestamp) {
  645. let ts = new Date(timestamp);
  646. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  647. },
  648. editUrl(status) {
  649. return status.url + '/edit';
  650. },
  651. redirect(url) {
  652. window.location.href = url;
  653. return;
  654. },
  655. replyUrl(status) {
  656. let username = this.profile.username;
  657. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  658. return '/p/' + username + '/' + id;
  659. },
  660. mentionUrl(status) {
  661. let username = status.account.username;
  662. let id = status.id;
  663. return '/p/' + username + '/' + id;
  664. },
  665. statusOwner(status) {
  666. let sid = status.account.id;
  667. let uid = this.profile.id;
  668. if(sid == uid) {
  669. return true;
  670. } else {
  671. return false;
  672. }
  673. },
  674. fetchStatusComments(status, card) {
  675. axios.get('/api/v2/status/'+status.id+'/replies')
  676. .then(res => {
  677. let data = res.data;
  678. this.replies = _.reverse(data);
  679. }).catch(err => {
  680. })
  681. },
  682. muteProfile(status) {
  683. if($('body').hasClass('loggedIn') == false) {
  684. return;
  685. }
  686. axios.post('/i/mute', {
  687. type: 'user',
  688. item: status.account.id
  689. }).then(res => {
  690. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  691. swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
  692. }).catch(err => {
  693. swal('Error', 'Something went wrong. Please try again later.', 'error');
  694. });
  695. },
  696. blockProfile(status) {
  697. if($('body').hasClass('loggedIn') == false) {
  698. return;
  699. }
  700. axios.post('/i/block', {
  701. type: 'user',
  702. item: status.account.id
  703. }).then(res => {
  704. this.feed = this.feed.filter(s => s.account.id !== status.account.id);
  705. swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
  706. }).catch(err => {
  707. swal('Error', 'Something went wrong. Please try again later.', 'error');
  708. });
  709. },
  710. deletePost(status, index) {
  711. if($('body').hasClass('loggedIn') == false || this.ownerOrAdmin(status) == false) {
  712. return;
  713. }
  714. if(window.confirm('Are you sure you want to delete this post?') == false) {
  715. return;
  716. }
  717. axios.post('/i/delete', {
  718. type: 'status',
  719. item: status.id
  720. }).then(res => {
  721. this.feed.splice(index,1);
  722. swal('Success', 'You have successfully deleted this post', 'success');
  723. }).catch(err => {
  724. swal('Error', 'Something went wrong. Please try again later.', 'error');
  725. });
  726. },
  727. commentSubmit(status, $event) {
  728. let id = status.id;
  729. let comment = this.replyText;
  730. axios.post('/i/comment', {
  731. item: id,
  732. comment: comment
  733. }).then(res => {
  734. this.replyText = '';
  735. this.replies.push(res.data.entity);
  736. });
  737. },
  738. moderatePost(status, action, $event) {
  739. let username = status.account.username;
  740. console.log('action: ' + action + ' status id' + status.id);
  741. switch(action) {
  742. case 'autocw':
  743. let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
  744. swal({
  745. title: 'Confirm',
  746. text: msg,
  747. icon: 'warning',
  748. buttons: true,
  749. dangerMode: true
  750. }).then(res => {
  751. if(res) {
  752. axios.post('/api/v2/moderator/action', {
  753. action: action,
  754. item_id: status.id,
  755. item_type: 'status'
  756. }).then(res => {
  757. swal('Success', 'Successfully enforced CW for ' + username, 'success');
  758. }).catch(err => {
  759. swal(
  760. 'Error',
  761. 'Something went wrong, please try again later.',
  762. 'error'
  763. );
  764. });
  765. }
  766. });
  767. break;
  768. case 'noautolink':
  769. msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
  770. swal({
  771. title: 'Confirm',
  772. text: msg,
  773. icon: 'warning',
  774. buttons: true,
  775. dangerMode: true
  776. }).then(res => {
  777. if(res) {
  778. axios.post('/api/v2/moderator/action', {
  779. action: action,
  780. item_id: status.id,
  781. item_type: 'status'
  782. }).then(res => {
  783. swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
  784. }).catch(err => {
  785. swal(
  786. 'Error',
  787. 'Something went wrong, please try again later.',
  788. 'error'
  789. );
  790. });
  791. }
  792. });
  793. break;
  794. case 'unlisted':
  795. msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
  796. swal({
  797. title: 'Confirm',
  798. text: msg,
  799. icon: 'warning',
  800. buttons: true,
  801. dangerMode: true
  802. }).then(res => {
  803. if(res) {
  804. axios.post('/api/v2/moderator/action', {
  805. action: action,
  806. item_id: status.id,
  807. item_type: 'status'
  808. }).then(res => {
  809. swal('Success', 'Successfully unlisted for ' + username, 'success');
  810. }).catch(err => {
  811. swal(
  812. 'Error',
  813. 'Something went wrong, please try again later.',
  814. 'error'
  815. );
  816. });
  817. }
  818. });
  819. break;
  820. case 'disable':
  821. msg = 'Are you sure you want to disable ' + username + '’s account ?';
  822. swal({
  823. title: 'Confirm',
  824. text: msg,
  825. icon: 'warning',
  826. buttons: true,
  827. dangerMode: true
  828. }).then(res => {
  829. if(res) {
  830. axios.post('/api/v2/moderator/action', {
  831. action: action,
  832. item_id: status.id,
  833. item_type: 'status'
  834. }).then(res => {
  835. swal('Success', 'Successfully disabled ' + username + '’s account', 'success');
  836. }).catch(err => {
  837. swal(
  838. 'Error',
  839. 'Something went wrong, please try again later.',
  840. 'error'
  841. );
  842. });
  843. }
  844. });
  845. break;
  846. case 'suspend':
  847. msg = 'Are you sure you want to suspend ' + username + '’s account ?';
  848. swal({
  849. title: 'Confirm',
  850. text: msg,
  851. icon: 'warning',
  852. buttons: true,
  853. dangerMode: true
  854. }).then(res => {
  855. if(res) {
  856. axios.post('/api/v2/moderator/action', {
  857. action: action,
  858. item_id: status.id,
  859. item_type: 'status'
  860. }).then(res => {
  861. swal('Success', 'Successfully suspend ' + username + '’s account', 'success');
  862. }).catch(err => {
  863. swal(
  864. 'Error',
  865. 'Something went wrong, please try again later.',
  866. 'error'
  867. );
  868. });
  869. }
  870. });
  871. break;
  872. }
  873. },
  874. toggleOptionsMenu() {
  875. this.optionMenuState = !this.optionMenuState;
  876. },
  877. modeModToggle() {
  878. this.modes.mod = !this.modes.mod;
  879. //window.ls.set('pixelfed-classicui-settings', this.modes);
  880. },
  881. modeNotifyToggle() {
  882. this.modes.notify = !this.modes.notify;
  883. //window.ls.set('pixelfed-classicui-settings', this.modes);
  884. },
  885. modeDarkToggle() {
  886. // todo: more graceful stylesheet change
  887. if(this.modes.dark == true) {
  888. axios.post('/i/metro/dark-mode', {
  889. mode: 'light'
  890. }).then(res => {
  891. $('link[data-stylesheet=dark]')
  892. .attr('data-stylesheet', 'light')
  893. .attr('href', '/css/app.css?v=' + Date.now());
  894. this.modes.dark = false;
  895. });
  896. } else {
  897. axios.post('/i/metro/dark-mode', {
  898. mode: 'dark'
  899. }).then(res => {
  900. $('link[data-stylesheet=light]')
  901. .attr('data-stylesheet', 'dark')
  902. .attr('href', '/css/appdark.css?v=' + Date.now());
  903. this.modes.dark = true;
  904. });
  905. }
  906. //window.ls.set('pixelfed-classicui-settings', this.modes);
  907. },
  908. modeInfiniteToggle() {
  909. this.modes.infinite = !this.modes.infinite
  910. //window.ls.set('pixelfed-classicui-settings', this.modes);
  911. },
  912. followingModal() {
  913. if(this.following.length > 0) {
  914. this.$refs.followingModal.show();
  915. return;
  916. }
  917. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  918. params: {
  919. page: this.followingCursor
  920. }
  921. })
  922. .then(res => {
  923. this.following = res.data;
  924. this.followingCursor++;
  925. });
  926. if(res.data.length < 10) {
  927. this.followingMore = false;
  928. }
  929. this.$refs.followingModal.show();
  930. },
  931. followersModal() {
  932. if(this.followers.length > 0) {
  933. this.$refs.followerModal.show();
  934. return;
  935. }
  936. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  937. params: {
  938. page: this.followerCursor
  939. }
  940. })
  941. .then(res => {
  942. this.followers = res.data;
  943. this.followerCursor++;
  944. })
  945. if(res.data.length < 10) {
  946. this.followerMore = false;
  947. }
  948. this.$refs.followerModal.show();
  949. },
  950. followingLoadMore() {
  951. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  952. params: {
  953. page: this.followingCursor
  954. }
  955. })
  956. .then(res => {
  957. if(res.data.length > 0) {
  958. this.following.push(...res.data);
  959. this.followingCursor++;
  960. }
  961. if(res.data.length < 10) {
  962. this.followingMore = false;
  963. }
  964. });
  965. },
  966. followersLoadMore() {
  967. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  968. params: {
  969. page: this.followerCursor
  970. }
  971. })
  972. .then(res => {
  973. if(res.data.length > 0) {
  974. this.followers.push(...res.data);
  975. this.followerCursor++;
  976. }
  977. if(res.data.length < 10) {
  978. this.followerMore = false;
  979. }
  980. });
  981. },
  982. lightbox(src) {
  983. this.lightboxMedia = src;
  984. this.$refs.lightboxModal.show();
  985. },
  986. expLc(status) {
  987. if(this.config.ab.lc == false) {
  988. return true;
  989. }
  990. if(this.statusOwner(status) == true) {
  991. return true;
  992. }
  993. return false;
  994. },
  995. expRec() {
  996. if(this.config.ab.rec == false) {
  997. return;
  998. }
  999. axios.get('/api/local/exp/rec')
  1000. .then(res => {
  1001. this.suggestions = res.data;
  1002. })
  1003. },
  1004. expRecFollow(id, index) {
  1005. if(this.config.ab.rec == false) {
  1006. return;
  1007. }
  1008. axios.post('/i/follow', {
  1009. item: id
  1010. }).then(res => {
  1011. this.suggestions.splice(index, 1);
  1012. })
  1013. },
  1014. followModalAction(id, index, type = 'following') {
  1015. axios.post('/i/follow', {
  1016. item: id
  1017. }).then(res => {
  1018. if(type == 'following') {
  1019. this.following.splice(index, 1);
  1020. }
  1021. })
  1022. },
  1023. owner(status) {
  1024. return this.profile.id === status.account.id;
  1025. },
  1026. admin() {
  1027. return this.profile.is_admin == true;
  1028. },
  1029. ownerOrAdmin(status) {
  1030. return this.owner(status) || this.admin();
  1031. },
  1032. hideSuggestions() {
  1033. localStorage.setItem('pf_metro_ui.exp.rec', false);
  1034. this.showSuggestions = false;
  1035. },
  1036. emojiReaction(status) {
  1037. let em = event.target.innerText;
  1038. if(this.replyText.length == 0) {
  1039. this.replyText = em + ' ';
  1040. $('textarea[name="comment"]').focus();
  1041. } else {
  1042. this.replyText += em + ' ';
  1043. $('textarea[name="comment"]').focus();
  1044. }
  1045. },
  1046. refreshSuggestions() {
  1047. let el = event.target.parentNode;
  1048. if(el.classList.contains('disabled') == true) {
  1049. return;
  1050. }
  1051. axios.get('/api/local/exp/rec', {
  1052. params: {
  1053. refresh: true
  1054. }
  1055. })
  1056. .then(res => {
  1057. this.suggestions = res.data;
  1058. if (el.classList) {
  1059. el.classList.add('disabled');
  1060. el.classList.add('text-light');
  1061. }
  1062. else {
  1063. el.className += ' ' + 'disabled text-light';
  1064. }
  1065. setTimeout(function() {
  1066. el.setAttribute('href', '#');
  1067. if (el.classList) {
  1068. el.classList.remove('disabled');
  1069. el.classList.remove('text-light');
  1070. }
  1071. else {
  1072. el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), 'disabled text-light');
  1073. }
  1074. }, 10000);
  1075. });
  1076. }
  1077. }
  1078. }
  1079. </script>