Timeline.vue 44 KB

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