Profile.vue 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. <template>
  2. <div class="w-100 h-100">
  3. <div v-if="isMobile" class="bg-white p-3 border-bottom">
  4. <div class="d-flex justify-content-between align-items-center">
  5. <div @click="goBack" class="cursor-pointer">
  6. <i class="fas fa-chevron-left fa-lg"></i>
  7. </div>
  8. <div class="font-weight-bold">
  9. {{this.profileUsername}}
  10. </div>
  11. <div>
  12. <a class="fas fa-ellipsis-v fa-lg text-muted text-decoration-none" href="#" @click.prevent="visitorMenu"></a>
  13. </div>
  14. </div>
  15. </div>
  16. <div v-if="relationship && relationship.blocking && warning" class="bg-white pt-3 border-bottom">
  17. <div class="container">
  18. <p class="text-center font-weight-bold">{{ $t("profile.blocking")}}</p>
  19. <p class="text-center font-weight-bold">Click <a href="#" class="cursor-pointer" @click.prevent="warning = false;">here</a> to view profile</p>
  20. </div>
  21. </div>
  22. <div v-if="loading" style="height: 80vh;" class="d-flex justify-content-center align-items-center">
  23. <img src="/img/pixelfed-icon-grey.svg" class="">
  24. </div>
  25. <div v-if="!loading && !warning">
  26. <div v-if="layout == 'metro'" class="container">
  27. <div :class="isMobile ? 'pt-5' : 'pt-5 border-bottom'">
  28. <div class="container px-0">
  29. <div class="row">
  30. <div class="col-12 col-md-4 d-md-flex">
  31. <div class="profile-avatar mx-md-auto">
  32. <!-- MOBILE PROFILE PICTURE -->
  33. <div class="d-block d-md-none mt-n3 mb-3">
  34. <div class="row">
  35. <div class="col-4">
  36. <div v-if="hasStory" class="has-story cursor-pointer shadow-sm" @click="storyRedirect()">
  37. <img :alt="profileUsername + '\'s profile picture'" class="rounded-circle" :src="profile.avatar" width="77px" height="77px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
  38. </div>
  39. <div v-else>
  40. <img :alt="profileUsername + '\'s profile picture'" class="rounded-circle border" :src="profile.avatar" width="77px" height="77px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
  41. </div>
  42. </div>
  43. <div class="col-8">
  44. <div class="d-block d-md-none mt-3 py-2">
  45. <ul class="nav d-flex justify-content-between">
  46. <li class="nav-item">
  47. <div class="font-weight-light">
  48. <span class="text-dark text-center">
  49. <p class="font-weight-bold mb-0">{{formatCount(profile.statuses_count)}}</p>
  50. <p class="text-muted mb-0 small">{{ $t("profile.posts")}}</p>
  51. </span>
  52. </div>
  53. </li>
  54. <li class="nav-item">
  55. <div v-if="profileSettings.followers.count" class="font-weight-light">
  56. <a class="text-dark cursor-pointer text-center" v-on:click="followersModal()">
  57. <p class="font-weight-bold mb-0">{{formatCount(profile.followers_count)}}</p>
  58. <p class="text-muted mb-0 small">{{ $t("profile.followers")}}</p>
  59. </a>
  60. </div>
  61. </li>
  62. <li class="nav-item">
  63. <div v-if="profileSettings.following.count" class="font-weight-light">
  64. <a class="text-dark cursor-pointer text-center" v-on:click="followingModal()">
  65. <p class="font-weight-bold mb-0">{{formatCount(profile.following_count)}}</p>
  66. <p class="text-muted mb-0 small">{{ $t("profile.following")}}</p>
  67. </a>
  68. </div>
  69. </li>
  70. </ul>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <!-- DESKTOP PROFILE PICTURE -->
  76. <div class="d-none d-md-block pb-3">
  77. <div v-if="hasStory" class="has-story-lg cursor-pointer shadow-sm" @click="storyRedirect()">
  78. <img :alt="profileUsername + '\'s profile picture'" class="rounded-circle box-shadow cursor-pointer" :src="profile.avatar" width="150px" height="150px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
  79. </div>
  80. <div v-else>
  81. <img :alt="profileUsername + '\'s profile picture'" class="rounded-circle box-shadow" :src="profile.avatar" width="150px" height="150px" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
  82. </div>
  83. <p v-if="sponsorList.patreon || sponsorList.liberapay || sponsorList.opencollective" class="text-center mt-3">
  84. <button type="button" @click="showSponsorModal" class="btn btn-outline-secondary font-weight-bold py-0">
  85. <i class="fas fa-heart text-danger"></i>
  86. {{ $t("profile.sponsor")}}
  87. </button>
  88. </p>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="col-12 col-md-8 d-flex align-items-center">
  93. <div class="profile-details">
  94. <div class="d-none d-md-flex username-bar pb-3 align-items-center">
  95. <span class="font-weight-ultralight h3 mb-0">{{profile.username}}</span>
  96. <span v-if="profile.id != user.id && user.hasOwnProperty('id')">
  97. <span class="pl-4" v-if="relationship.following == true">
  98. <a :href="'/account/direct/t/'+profile.id" class="btn btn-outline-secondary font-weight-bold btn-sm py-1 text-dark mr-2 px-3 btn-sec-alt" style="border:1px solid #dbdbdb;" data-toggle="tooltip" title="Message">Message</a>
  99. <button type="button" class="btn btn-outline-secondary font-weight-bold btn-sm py-1 text-dark btn-sec-alt" style="border:1px solid #dbdbdb;" v-on:click="followProfile" data-toggle="tooltip" title="Unfollow"><i class="fas fa-user-check mx-3"></i></button>
  100. </span>
  101. <span class="pl-4" v-if="!relationship.following">
  102. <button type="button" class="btn btn-primary font-weight-bold btn-sm py-1 px-3" v-on:click="followProfile" data-toggle="tooltip" title="Follow">Follow</button>
  103. </span>
  104. </span>
  105. <span class="pl-4" v-if="owner && user.hasOwnProperty('id')">
  106. <a class="btn btn-outline-secondary btn-sm" href="/settings/home" style="font-weight: 600;">{{ $t("profile.editProfile") }}</a>
  107. </span>
  108. <span class="pl-4">
  109. <a class="fas fa-ellipsis-h fa-lg text-dark text-decoration-none" href="#" @click.prevent="visitorMenu"></a>
  110. </span>
  111. </div>
  112. <div class="font-size-16px">
  113. <div class="d-none d-md-inline-flex profile-stats pb-3">
  114. <div class="font-weight-light pr-5">
  115. <span class="text-dark">
  116. <span class="font-weight-bold">{{formatCount(profile.statuses_count)}}</span>
  117. {{ $t("profile.posts")}}
  118. </span>
  119. </div>
  120. <div v-if="profileSettings.followers.count" class="font-weight-light pr-5">
  121. <a class="text-dark cursor-pointer" v-on:click="followersModal()">
  122. <span class="font-weight-bold">{{formatCount(profile.followers_count)}}</span>
  123. {{ $t("profile.followers")}}
  124. </a>
  125. </div>
  126. <div v-if="profileSettings.following.count" class="font-weight-light">
  127. <a class="text-dark cursor-pointer" v-on:click="followingModal()">
  128. <span class="font-weight-bold">{{formatCount(profile.following_count)}}</span>
  129. {{ $t("profile.following")}}
  130. </a>
  131. </div>
  132. </div>
  133. <div class="d-md-flex align-items-center mb-1 text-break">
  134. <div class="font-weight-bold mr-1">{{profile.display_name}}</div>
  135. <div v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</div>
  136. </div>
  137. <p v-if="profile.note" class="mb-0" v-html="profile.note"></p>
  138. <p v-if="profile.website"><a :href="profile.website" class="profile-website small" rel="me external nofollow noopener" target="_blank">{{formatWebsite(profile.website)}}</a></p>
  139. <p class="d-flex small text-muted align-items-center">
  140. <span v-if="profile.is_admin" class="btn btn-outline-danger btn-sm py-0 mr-3" title="Admin Account" data-toggle="tooltip">
  141. {{ $t("profile.admin") }}
  142. </span>
  143. <span v-if="relationship && relationship.followed_by" class="btn btn-outline-muted btn-sm py-0 mr-3">{{ $t("profile.followYou") }}</span>
  144. <span>
  145. {{$t("profile.joined")}} {{joinedAtFormat(profile.created_at)}}
  146. </span>
  147. </p>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <div v-if="user && user.hasOwnProperty('id')" class="d-block d-md-none my-0 pt-3 border-bottom">
  155. <p class="pt-3">
  156. <button v-if="owner" class="btn btn-outline-secondary bg-white btn-sm py-1 btn-block text-center font-weight-bold text-dark border border-lighter" @click.prevent="redirect('/settings/home')">{{ $t("profile.editProfile")}}</button>
  157. <button v-if="!owner && relationship.following" class="btn btn-outline-secondary bg-white btn-sm py-1 px-5 font-weight-bold text-dark border border-lighter" @click="followProfile">&nbsp;&nbsp; Unfollow &nbsp;&nbsp;</button>
  158. <button v-if="!owner && !relationship.following" class="btn btn-primary btn-sm py-1 px-5 font-weight-bold" @click="followProfile">{{relationship.followed_by ? 'Follow Back' : '&nbsp;&nbsp;&nbsp;&nbsp; Follow &nbsp;&nbsp;&nbsp;&nbsp;'}}</button>
  159. <!-- <button v-if="!owner" class="btn btn-outline-secondary bg-white btn-sm py-1 px-5 font-weight-bold text-dark border border-lighter mx-2">Message</button>
  160. <button v-if="!owner" class="btn btn-outline-secondary bg-white btn-sm py-1 font-weight-bold text-dark border border-lighter"><i class="fas fa-chevron-down fa-sm"></i></button> -->
  161. </p>
  162. </div>
  163. <div class="">
  164. <ul class="nav nav-topbar d-flex justify-content-center border-0">
  165. <li class="nav-item border-top">
  166. <a :class="this.mode == 'grid' ? 'nav-link text-dark' : 'nav-link'" href="#" v-on:click.prevent="switchMode('grid')"><i class="fas fa-th"></i> <span class="d-none d-md-inline-block small pl-1">POSTS</span></a>
  167. </li>
  168. <li class="nav-item px-0 border-top">
  169. <a :class="this.mode == 'collections' ? 'nav-link text-dark' : 'nav-link'" href="#" v-on:click.prevent="switchMode('collections')"><i class="fas fa-images"></i> <span class="d-none d-md-inline-block small pl-1">COLLECTIONS</span></a>
  170. </li>
  171. <li v-if="owner" class="nav-item border-top">
  172. <a :class="this.mode == 'bookmarks' ? 'nav-link text-dark' : 'nav-link'" href="#" v-on:click.prevent="switchMode('bookmarks')"><i class="fas fa-bookmark"></i> <span class="d-none d-md-inline-block small pl-1">SAVED</span></a>
  173. </li>
  174. <li v-if="owner" class="nav-item border-top">
  175. <a :class="this.mode == 'archives' ? 'nav-link text-dark' : 'nav-link'" href="#" v-on:click.prevent="switchMode('archives')"><i class="far fa-folder-open"></i> <span class="d-none d-md-inline-block small pl-1">ARCHIVES</span></a>
  176. </li>
  177. </ul>
  178. </div>
  179. <div class="container px-0">
  180. <div class="profile-timeline mt-md-4">
  181. <div v-if="mode == 'grid'">
  182. <div class="row">
  183. <div class="col-4 p-1 p-md-3" v-for="(s, index) in timeline" :key="'tlob:'+index">
  184. <a class="card info-overlay card-md-border-0" :href="statusUrl(s)">
  185. <div class="square">
  186. <div v-if="s.sensitive" class="square-content">
  187. <div class="info-overlay-text-label">
  188. <h5 class="text-white m-auto font-weight-bold">
  189. <span>
  190. <span class="far fa-eye-slash fa-lg p-2 d-flex-inline"></span>
  191. </span>
  192. </h5>
  193. </div>
  194. <blur-hash-canvas
  195. width="32"
  196. height="32"
  197. :hash="s.media_attachments[0].blurhash"
  198. />
  199. </div>
  200. <div v-else class="square-content">
  201. <blur-hash-image
  202. width="32"
  203. height="32"
  204. :hash="s.media_attachments[0].blurhash"
  205. :src="s.media_attachments[0].preview_url"
  206. />
  207. </div>
  208. <span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
  209. <span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
  210. <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
  211. <div class="info-overlay-text">
  212. <h5 class="text-white m-auto font-weight-bold">
  213. <span>
  214. <span class="far fa-comment fa-lg p-2 d-flex-inline"></span>
  215. <span class="d-flex-inline">{{formatCount(s.reply_count)}}</span>
  216. </span>
  217. </h5>
  218. </div>
  219. </div>
  220. </a>
  221. </div>
  222. <div v-if="timeline.length == 0" class="col-12">
  223. <div class="py-5 text-center text-muted">
  224. <p><i class="fas fa-camera-retro fa-2x"></i></p>
  225. <p class="h2 font-weight-light pt-3">No posts yet</p>
  226. </div>
  227. </div>
  228. </div>
  229. <div v-if="timeline.length">
  230. <infinite-loading @infinite="infiniteTimeline">
  231. <div slot="no-more"></div>
  232. <div slot="no-results"></div>
  233. </infinite-loading>
  234. </div>
  235. </div>
  236. <div v-if="mode == 'bookmarks'">
  237. <div v-if="bookmarksLoading">
  238. <div class="row">
  239. <div class="col-12">
  240. <div class="p-1 p-sm-2 p-md-3 d-flex justify-content-center align-items-center" style="height: 30vh;">
  241. <img src="/img/pixelfed-icon-grey.svg" class="">
  242. </div>
  243. </div>
  244. </div>
  245. </div>
  246. <div v-else>
  247. <div v-if="bookmarks.length" class="row">
  248. <div class="col-4 p-1 p-sm-2 p-md-3" v-for="(s, index) in bookmarks">
  249. <a class="card info-overlay card-md-border-0" :href="s.url">
  250. <div class="square">
  251. <span v-if="s.pf_type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
  252. <span v-if="s.pf_type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
  253. <span v-if="s.pf_type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
  254. <div class="square-content" v-bind:style="previewBackground(s)">
  255. </div>
  256. <div class="info-overlay-text">
  257. <h5 class="text-white m-auto font-weight-bold">
  258. <span>
  259. <span class="fas fa-retweet fa-lg p-2 d-flex-inline"></span>
  260. <span class="d-flex-inline">{{s.reblogs_count}}</span>
  261. </span>
  262. </h5>
  263. </div>
  264. </div>
  265. </a>
  266. </div>
  267. </div>
  268. <div v-else class="col-12">
  269. <div class="py-5 text-center text-muted">
  270. <p><i class="fas fa-bookmark fa-2x"></i></p>
  271. <p class="h2 font-weight-light pt-3">No saved bookmarks</p>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. <div v-if="mode == 'collections'">
  277. <div v-if="collections.length && collectionsLoaded" class="row">
  278. <div class="col-4 p-1 p-sm-2 p-md-3" v-for="(c, index) in collections">
  279. <a class="card info-overlay card-md-border-0" :href="c.url">
  280. <div class="square">
  281. <div class="square-content" v-bind:style="'background-image: url(' + c.thumb + ');'">
  282. </div>
  283. </div>
  284. </a>
  285. </div>
  286. </div>
  287. <div v-else>
  288. <div class="py-5 text-center text-muted">
  289. <p><i class="fas fa-images fa-2x"></i></p>
  290. <p class="h2 font-weight-light pt-3">No collections yet</p>
  291. </div>
  292. </div>
  293. </div>
  294. <div v-if="mode == 'archives'">
  295. <div v-if="archives.length" class="col-12 col-md-8 offset-md-2 px-0 mb-sm-3 timeline mt-5">
  296. <div class="alert alert-info">
  297. <p class="mb-0">Posts you archive can only be seen by you.</p>
  298. <p class="mb-0">For more information see the <a href="/site/kb/sharing-media">Sharing Media</a> help center page.</p>
  299. </div>
  300. <div v-for="(status, index) in archives">
  301. <status-card
  302. :class="{ 'border-top': index === 0 }"
  303. :status="status"
  304. :reaction-bar="false"
  305. />
  306. </div>
  307. <infinite-loading @infinite="archivesInfiniteLoader">
  308. <div slot="no-more"></div>
  309. <div slot="no-results"></div>
  310. </infinite-loading>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. <b-modal
  318. v-if="profile && following"
  319. ref="followingModal"
  320. id="following-modal"
  321. hide-footer
  322. centered
  323. scrollable
  324. title="Following"
  325. body-class="list-group-flush py-3 px-0"
  326. dialog-class="follow-modal">
  327. <div v-if="!followingLoading" class="list-group" style="max-height: 60vh;">
  328. <div v-if="!following.length" class="list-group-item border-0">
  329. <p class="text-center mb-0 font-weight-bold text-muted py-5">
  330. <span class="text-dark">{{profileUsername}}</span> is not following yet</p>
  331. </div>
  332. <div v-else>
  333. <div class="list-group-item border-0 py-1 mb-1" v-for="(user, index) in following" :key="'following_'+index">
  334. <div class="media">
  335. <a :href="profileUrlRedirect(user)">
  336. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" loading="lazy" onerror="this.src='/storage/avatars/default.jpg?v=0';this.onerror=null;" v-once>
  337. </a>
  338. <div class="media-body text-truncate">
  339. <p class="mb-0" style="font-size: 14px">
  340. <a :href="profileUrlRedirect(user)" class="font-weight-bold text-dark">
  341. {{user.username}}
  342. </a>
  343. </p>
  344. <p v-if="!user.local" class="text-muted mb-0 text-break mr-3" style="font-size: 14px" :title="user.acct" data-toggle="dropdown" data-placement="bottom">
  345. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  346. </p>
  347. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  348. {{user.display_name ? user.display_name : user.username}}
  349. </p>
  350. </div>
  351. <div v-if="owner">
  352. <a class="btn btn-outline-dark btn-sm font-weight-bold" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Following</a>
  353. </div>
  354. </div>
  355. </div>
  356. <div v-if="!followingLoading && following.length == 0" class="list-group-item border-0">
  357. <div class="list-group-item border-0 pt-5">
  358. <p class="p-3 text-center mb-0 lead">No Results Found</p>
  359. </div>
  360. </div>
  361. <div v-if="following.length > 0 && followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  362. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  363. </div>
  364. </div>
  365. </div>
  366. <div v-else class="text-center py-5">
  367. <div class="spinner-border" role="status">
  368. <span class="sr-only">Loading...</span>
  369. </div>
  370. </div>
  371. </b-modal>
  372. <b-modal ref="followerModal"
  373. id="follower-modal"
  374. hide-footer
  375. centered
  376. scrollable
  377. title="Followers"
  378. body-class="list-group-flush py-3 px-0"
  379. dialog-class="follow-modal"
  380. >
  381. <div v-if="!followerLoading" class="list-group" style="max-height: 60vh;">
  382. <div v-if="!followerLoading && !followers.length" class="list-group-item border-0">
  383. <p class="text-center mb-0 font-weight-bold text-muted py-5">
  384. <span class="text-dark">{{profileUsername}}</span> has no followers yet</p>
  385. </div>
  386. <div v-else>
  387. <div class="list-group-item border-0 py-1 mb-1" v-for="(user, index) in followers" :key="'follower_'+index">
  388. <div class="media mb-0">
  389. <a :href="profileUrlRedirect(user)">
  390. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" height="30px" loading="lazy" onerror="this.src='/storage/avatars/default.jpg?v=0';this.onerror=null;" v-once>
  391. </a>
  392. <div class="media-body mb-0">
  393. <p class="mb-0" style="font-size: 14px">
  394. <a :href="profileUrlRedirect(user)" class="font-weight-bold text-dark">
  395. {{user.username}}
  396. </a>
  397. </p>
  398. <p v-if="!user.local" class="text-muted mb-0 text-break mr-3" style="font-size: 14px" :title="user.acct" data-toggle="dropdown" data-placement="bottom">
  399. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  400. </p>
  401. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  402. {{user.display_name ? user.display_name : user.username}}
  403. </p>
  404. </div>
  405. <!-- <button class="btn btn-primary font-weight-bold btn-sm py-1">FOLLOW</button> -->
  406. </div>
  407. </div>
  408. <div v-if="followers.length && followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  409. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  410. </div>
  411. </div>
  412. </div>
  413. <div v-else class="text-center py-5">
  414. <div class="spinner-border" role="status">
  415. <span class="sr-only">Loading...</span>
  416. </div>
  417. </div>
  418. </b-modal>
  419. <b-modal ref="visitorContextMenu"
  420. id="visitor-context-menu"
  421. hide-footer
  422. hide-header
  423. centered
  424. size="sm"
  425. body-class="list-group-flush p-0">
  426. <div class="list-group" v-if="relationship">
  427. <div class="list-group-item cursor-pointer text-center rounded text-dark" @click="copyProfileLink">
  428. Copy Link
  429. </div>
  430. <div v-if="profile.locked == false" class="list-group-item cursor-pointer text-center rounded text-dark" @click="showEmbedProfileModal">
  431. Embed
  432. </div>
  433. <div v-if="user && !owner && !relationship.following" class="list-group-item cursor-pointer text-center rounded text-dark" @click="followProfile">
  434. Follow
  435. </div>
  436. <div v-if="user && !owner && relationship.following" class="list-group-item cursor-pointer text-center rounded" @click="followProfile">
  437. Unfollow
  438. </div>
  439. <div v-if="user && !owner && !relationship.muting" class="list-group-item cursor-pointer text-center rounded" @click="muteProfile">
  440. Mute
  441. </div>
  442. <div v-if="user && !owner && relationship.muting" class="list-group-item cursor-pointer text-center rounded" @click="unmuteProfile">
  443. Unmute
  444. </div>
  445. <div v-if="user && !owner" class="list-group-item cursor-pointer text-center rounded text-dark" @click="reportProfile">
  446. Report User
  447. </div>
  448. <div v-if="user && !owner && !relationship.blocking" class="list-group-item cursor-pointer text-center rounded text-dark" @click="blockProfile">
  449. Block
  450. </div>
  451. <div v-if="user && !owner && relationship.blocking" class="list-group-item cursor-pointer text-center rounded text-dark" @click="unblockProfile">
  452. Unblock
  453. </div>
  454. <div v-if="user && owner" class="list-group-item cursor-pointer text-center rounded text-dark" @click="redirect('/settings/home')">
  455. Settings
  456. </div>
  457. <div class="list-group-item cursor-pointer text-center rounded text-dark" @click="redirect('/users/' + profileUsername + '.atom')">
  458. Atom Feed
  459. </div>
  460. <div class="list-group-item cursor-pointer text-center rounded text-muted font-weight-bold" @click="$refs.visitorContextMenu.hide()">
  461. Close
  462. </div>
  463. </div>
  464. </b-modal>
  465. <b-modal ref="sponsorModal"
  466. id="sponsor-modal"
  467. hide-footer
  468. :title="'Sponsor ' + profileUsername"
  469. centered
  470. size="md"
  471. body-class="px-5">
  472. <div>
  473. <p class="font-weight-bold">External Links</p>
  474. <p v-if="sponsorList.patreon" class="pt-2">
  475. <a :href="'https://' + sponsorList.patreon" rel="nofollow" class="font-weight-bold">{{sponsorList.patreon}}</a>
  476. </p>
  477. <p v-if="sponsorList.liberapay" class="pt-2">
  478. <a :href="'https://' + sponsorList.liberapay" rel="nofollow" class="font-weight-bold">{{sponsorList.liberapay}}</a>
  479. </p>
  480. <p v-if="sponsorList.opencollective" class="pt-2">
  481. <a :href="'https://' + sponsorList.opencollective" rel="nofollow" class="font-weight-bold">{{sponsorList.opencollective}}</a>
  482. </p>
  483. </div>
  484. </b-modal>
  485. <b-modal ref="embedModal"
  486. id="ctx-embed-modal"
  487. hide-header
  488. hide-footer
  489. centered
  490. rounded
  491. size="md"
  492. body-class="p-2 rounded">
  493. <div>
  494. <textarea class="form-control disabled text-monospace" rows="6" style="overflow-y:hidden;border: 1px solid #efefef; font-size: 12px; line-height: 18px; margin: 0 0 7px;resize:none;" v-model="ctxEmbedPayload" disabled=""></textarea>
  495. <hr>
  496. <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>
  497. <p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
  498. </div>
  499. </b-modal>
  500. </div>
  501. </template>
  502. <style type="text/css" scoped>
  503. .o-square {
  504. max-width: 320px;
  505. }
  506. .o-portrait {
  507. max-width: 320px;
  508. }
  509. .o-landscape {
  510. max-width: 320px;
  511. }
  512. .post-icon {
  513. color: #fff;
  514. position:relative;
  515. margin-top: 10px;
  516. z-index: 9;
  517. opacity: 0.6;
  518. text-shadow: 3px 3px 16px #272634;
  519. }
  520. .font-size-16px {
  521. font-size: 16px;
  522. }
  523. .profile-website {
  524. color: #003569;
  525. text-decoration: none;
  526. font-weight: 600;
  527. }
  528. .nav-topbar .nav-link {
  529. color: #999;
  530. }
  531. .nav-topbar .nav-link .small {
  532. font-weight: 600;
  533. }
  534. .has-story {
  535. width: 84px;
  536. height: 84px;
  537. border-radius: 50%;
  538. padding: 4px;
  539. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  540. }
  541. .has-story img {
  542. width: 76px;
  543. height: 76px;
  544. border-radius: 50%;
  545. padding: 6px;
  546. background: #fff;
  547. }
  548. .has-story-lg {
  549. width: 159px;
  550. height: 159px;
  551. border-radius: 50%;
  552. padding: 4px;
  553. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  554. }
  555. .has-story-lg img {
  556. width: 150px;
  557. height: 150px;
  558. border-radius: 50%;
  559. padding: 6px;
  560. background:#fff;
  561. }
  562. .no-focus {
  563. border-color: none;
  564. outline: 0;
  565. box-shadow: none;
  566. }
  567. .modal-tab-active {
  568. border-bottom: 1px solid #08d;
  569. }
  570. .btn-sec-alt:hover {
  571. color: #ccc;
  572. opacity: .7;
  573. background-color: transparent;
  574. border-color: #6c757d;
  575. }
  576. </style>
  577. <script type="text/javascript">
  578. import VueMasonry from 'vue-masonry-css'
  579. import StatusCard from './partials/StatusCard.vue';
  580. import { parseLinkHeader } from '@web3-storage/parse-link-header';
  581. export default {
  582. props: [
  583. 'profile-id',
  584. 'profile-layout',
  585. 'profile-settings',
  586. 'profile-username'
  587. ],
  588. components: {
  589. StatusCard,
  590. },
  591. data() {
  592. return {
  593. ids: [],
  594. profile: {},
  595. user: false,
  596. timeline: [],
  597. timelinePage: 2,
  598. cursor: undefined,
  599. loading: true,
  600. canLoadMore: false,
  601. owner: false,
  602. layout: 'metro',
  603. mode: 'grid',
  604. modes: ['grid', 'collections', 'bookmarks', 'archives'],
  605. modalStatus: false,
  606. relationship: {},
  607. followers: [],
  608. followerCursor: null,
  609. followerMore: true,
  610. followerLoading: true,
  611. following: [],
  612. followingCursor: null,
  613. followingMore: true,
  614. followingLoading: true,
  615. warning: false,
  616. sponsorList: [],
  617. bookmarks: [],
  618. bookmarksPage: 2,
  619. collections: [],
  620. collectionsLoaded: false,
  621. collectionsPage: 2,
  622. isMobile: false,
  623. ctxEmbedPayload: null,
  624. copiedEmbed: false,
  625. hasStory: null,
  626. followingModalTab: 'following',
  627. bookmarksLoading: true,
  628. archives: [],
  629. archivesPage: 2
  630. }
  631. },
  632. beforeMount() {
  633. this.fetchProfile();
  634. let u = new URLSearchParams(window.location.search);
  635. this.layout = 'metro';
  636. if(this.layout == 'metro' && u.has('t')) {
  637. if(this.modes.indexOf(u.get('t')) != -1) {
  638. if(u.get('t') == 'bookmarks') {
  639. return;
  640. }
  641. this.mode = u.get('t');
  642. }
  643. }
  644. if(u.has('m') && this.modes.includes(u.get('m'))) {
  645. this.mode = u.get('m');
  646. if(this.mode == 'bookmarks') {
  647. axios.get('/api/local/bookmarks')
  648. .then(res => {
  649. this.bookmarks = res.data;
  650. this.bookmarksLoading = false;
  651. }).catch(err => {
  652. this.mode = 'grid';
  653. });
  654. }
  655. if(this.mode == 'collections') {
  656. axios.get('/api/local/profile/collections/' + this.profileId)
  657. .then(res => {
  658. this.collections = res.data
  659. this.collectionsLoaded = true;
  660. }).catch(err => {
  661. this.mode = 'grid';
  662. });
  663. }
  664. if(this.mode == 'archives') {
  665. axios.get('/api/pixelfed/v2/statuses/archives')
  666. .then(res => {
  667. this.archives = res.data;
  668. }).catch(err => {
  669. this.mode = 'grid';
  670. });
  671. }
  672. }
  673. },
  674. mounted() {
  675. let u = new URLSearchParams(window.location.search);
  676. if(u.has('md') && u.get('md') == 'followers') {
  677. this.followersModal();
  678. }
  679. if(u.has('md') && u.get('md') == 'following') {
  680. this.followingModal();
  681. }
  682. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  683. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  684. this.user = res.data;
  685. window._sharedData.curUser = res.data;
  686. window.App.util.navatar();
  687. this.fetchRelationships();
  688. });
  689. }
  690. },
  691. updated() {
  692. $('[data-toggle="tooltip"]').tooltip();
  693. },
  694. methods: {
  695. fetchProfile() {
  696. axios.get('/api/pixelfed/v1/accounts/' + this.profileId).then(res => {
  697. this.profile = res.data;
  698. }).then(res => {
  699. this.fetchPosts();
  700. });
  701. },
  702. fetchPosts() {
  703. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  704. axios.get(apiUrl, {
  705. params: {
  706. limit: 9,
  707. pinned: true,
  708. only_media: true,
  709. }
  710. })
  711. .then(res => {
  712. let data = res.data.filter(status => status.media_attachments.length > 0);
  713. let ids = data.map(status => status.id);
  714. this.ids = ids;
  715. if(res.headers && res.headers.link) {
  716. const links = parseLinkHeader(res.headers.link);
  717. if(links.prev) {
  718. this.cursor = links.prev.cursor;
  719. this.canLoadMore = true;
  720. } else {
  721. this.cursor = null;
  722. this.canLoadMore = false;
  723. $state.complete();
  724. }
  725. } else {
  726. this.cursor = null;
  727. this.canLoadMore = false;
  728. }
  729. this.modalStatus = _.first(res.data);
  730. this.timeline = data;
  731. this.ownerCheck();
  732. this.loading = false;
  733. }).catch(err => {
  734. swal('Oops, something went wrong',
  735. 'Please release the page.',
  736. 'error');
  737. });
  738. },
  739. ownerCheck() {
  740. if($('body').hasClass('loggedIn') == false) {
  741. this.owner = false;
  742. return;
  743. }
  744. this.owner = this.profile.id === this.user.id;
  745. },
  746. infiniteTimeline($state) {
  747. if(this.loading || !this.cursor || !this.canLoadMore) {
  748. // $state.complete();
  749. return;
  750. }
  751. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  752. axios.get(apiUrl, {
  753. params: {
  754. limit: 9,
  755. pinned: true,
  756. only_media: true,
  757. cursor: this.cursor,
  758. },
  759. }).then(res => {
  760. if (res.data.length) {
  761. let data = res.data;
  762. let self = this;
  763. data.forEach(d => {
  764. if(self.ids.indexOf(d.id) == -1) {
  765. self.timeline.push(d);
  766. self.ids.push(d.id);
  767. }
  768. });
  769. if(res.headers && res.headers.link) {
  770. const links = parseLinkHeader(res.headers.link);
  771. if(links.prev) {
  772. this.cursor = links.prev.cursor;
  773. this.canLoadMore = true;
  774. } else {
  775. this.cursor = null;
  776. this.canLoadMore = false;
  777. $state.complete();
  778. }
  779. } else {
  780. this.cursor = null;
  781. this.canLoadMore = false;
  782. }
  783. $state.loaded();
  784. this.loading = false;
  785. } else {
  786. $state.complete();
  787. }
  788. });
  789. },
  790. previewUrl(status) {
  791. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  792. },
  793. previewBackground(status) {
  794. let preview = this.previewUrl(status);
  795. return 'background-image: url(' + preview + ');';
  796. },
  797. blurhHashMedia(status) {
  798. return status.sensitive ? null :
  799. status.media_attachments[0].preview_url;
  800. },
  801. switchMode(mode) {
  802. if(mode == 'grid') {
  803. this.mode = mode;
  804. } else if(mode == 'bookmarks' && this.bookmarks.length) {
  805. this.mode = 'bookmarks';
  806. } else if(mode == 'collections' && this.collections.length) {
  807. this.mode = 'collections';
  808. } else {
  809. window.location.href = '/' + this.profileUsername + '?m=' + mode;
  810. return;
  811. }
  812. },
  813. reportProfile() {
  814. let id = this.profile.id;
  815. window.location.href = '/i/report?type=user&id=' + id;
  816. },
  817. reportUrl(status) {
  818. let type = status.in_reply_to ? 'comment' : 'post';
  819. let id = status.id;
  820. return '/i/report?type=' + type + '&id=' + id;
  821. },
  822. commentFocus(status, $event) {
  823. let el = event.target;
  824. let card = el.parentElement.parentElement.parentElement;
  825. let comments = card.getElementsByClassName('comments')[0];
  826. if(comments.children.length == 0) {
  827. comments.classList.add('mb-2');
  828. this.fetchStatusComments(status, card);
  829. }
  830. let footer = card.querySelectorAll('.card-footer')[0];
  831. let input = card.querySelectorAll('.status-reply-input')[0];
  832. if(footer.classList.contains('d-none') == true) {
  833. footer.classList.remove('d-none');
  834. input.focus();
  835. } else {
  836. footer.classList.add('d-none');
  837. input.blur();
  838. }
  839. },
  840. likeStatus(status, $event) {
  841. if($('body').hasClass('loggedIn') == false) {
  842. return;
  843. }
  844. axios.post('/i/like', {
  845. item: status.id
  846. }).then(res => {
  847. status.favourites_count = res.data.count;
  848. if(status.favourited == true) {
  849. status.favourited = false;
  850. } else {
  851. status.favourited = true;
  852. }
  853. }).catch(err => {
  854. swal('Error', 'Something went wrong, please try again later.', 'error');
  855. });
  856. },
  857. shareStatus(status, $event) {
  858. if($('body').hasClass('loggedIn') == false) {
  859. return;
  860. }
  861. axios.post('/i/share', {
  862. item: status.id
  863. }).then(res => {
  864. status.reblogs_count = res.data.count;
  865. if(status.reblogged == true) {
  866. status.reblogged = false;
  867. } else {
  868. status.reblogged = true;
  869. }
  870. }).catch(err => {
  871. swal('Error', 'Something went wrong, please try again later.', 'error');
  872. });
  873. },
  874. timestampFormat(timestamp) {
  875. let ts = new Date(timestamp);
  876. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  877. },
  878. editUrl(status) {
  879. return status.url + '/edit';
  880. },
  881. redirect(url) {
  882. window.location.href = url;
  883. return;
  884. },
  885. remoteRedirect(url) {
  886. window.location.href = window.App.config.site.url + '/i/redirect?url=' + encodeURIComponent(url);
  887. return;
  888. },
  889. replyUrl(status) {
  890. let username = this.profile.username;
  891. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  892. return '/p/' + username + '/' + id;
  893. },
  894. mentionUrl(status) {
  895. let username = status.account.username;
  896. let id = status.id;
  897. return '/p/' + username + '/' + id;
  898. },
  899. statusOwner(status) {
  900. let sid = status.account.id;
  901. let uid = this.profile.id;
  902. if(sid == uid) {
  903. return true;
  904. } else {
  905. return false;
  906. }
  907. },
  908. fetchRelationships() {
  909. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  910. return;
  911. }
  912. axios.get('/api/pixelfed/v1/accounts/relationships', {
  913. params: {
  914. 'id[]': this.profileId
  915. }
  916. }).then(res => {
  917. if(res.data.length) {
  918. this.relationship = res.data[0];
  919. if(res.data[0].blocking == true) {
  920. this.warning = true;
  921. }
  922. }
  923. if(this.user.id == this.profileId || this.relationship.following == true) {
  924. axios.get('/api/web/stories/v1/exists/' + this.profileId)
  925. .then(res => {
  926. this.hasStory = (res.data == true);
  927. })
  928. }
  929. });
  930. },
  931. muteProfile(status = null) {
  932. if($('body').hasClass('loggedIn') == false) {
  933. return;
  934. }
  935. let id = this.profileId;
  936. axios.post('/i/mute', {
  937. type: 'user',
  938. item: id
  939. }).then(res => {
  940. this.fetchRelationships();
  941. this.$refs.visitorContextMenu.hide();
  942. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  943. }).catch(err => {
  944. if(err.response.status == 422) {
  945. swal('Error', err.response.data.error, 'error');
  946. } else {
  947. swal('Error', 'Something went wrong. Please try again later.', 'error');
  948. }
  949. });
  950. },
  951. unmuteProfile(status = null) {
  952. if($('body').hasClass('loggedIn') == false) {
  953. return;
  954. }
  955. let id = this.profileId;
  956. axios.post('/i/unmute', {
  957. type: 'user',
  958. item: id
  959. }).then(res => {
  960. this.fetchRelationships();
  961. this.$refs.visitorContextMenu.hide();
  962. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  963. }).catch(err => {
  964. swal('Error', 'Something went wrong. Please try again later.', 'error');
  965. });
  966. },
  967. blockProfile(status = null) {
  968. if($('body').hasClass('loggedIn') == false) {
  969. return;
  970. }
  971. let id = this.profileId;
  972. axios.post('/i/block', {
  973. type: 'user',
  974. item: id
  975. }).then(res => {
  976. this.warning = true;
  977. this.fetchRelationships();
  978. this.$refs.visitorContextMenu.hide();
  979. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  980. }).catch(err => {
  981. if(err.response.status == 422) {
  982. swal('Error', err.response.data.error, 'error');
  983. } else {
  984. swal('Error', 'Something went wrong. Please try again later.', 'error');
  985. }
  986. });
  987. },
  988. unblockProfile(status = null) {
  989. if($('body').hasClass('loggedIn') == false) {
  990. return;
  991. }
  992. let id = this.profileId;
  993. axios.post('/i/unblock', {
  994. type: 'user',
  995. item: id
  996. }).then(res => {
  997. this.fetchRelationships();
  998. this.$refs.visitorContextMenu.hide();
  999. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  1000. }).catch(err => {
  1001. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1002. });
  1003. },
  1004. deletePost(status, index) {
  1005. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  1006. return;
  1007. }
  1008. axios.post('/i/delete', {
  1009. type: 'status',
  1010. item: status.id
  1011. }).then(res => {
  1012. this.timeline.splice(index,1);
  1013. swal('Success', 'You have successfully deleted this post', 'success');
  1014. }).catch(err => {
  1015. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1016. });
  1017. },
  1018. followProfile() {
  1019. if($('body').hasClass('loggedIn') == false) {
  1020. return;
  1021. }
  1022. this.$refs.visitorContextMenu.hide();
  1023. const curState = this.relationship.following;
  1024. const apiUrl = curState ?
  1025. '/api/v1/accounts/' + this.profileId + '/unfollow' :
  1026. '/api/v1/accounts/' + this.profileId + '/follow';
  1027. axios.post(apiUrl)
  1028. .then(res => {
  1029. if(curState) {
  1030. this.profile.followers_count--;
  1031. if(this.profile.locked) {
  1032. location.reload();
  1033. }
  1034. } else {
  1035. this.profile.followers_count++;
  1036. }
  1037. this.relationship = res.data;
  1038. }).catch(err => {
  1039. if(err.response.data.message) {
  1040. swal('Error', err.response.data.message, 'error');
  1041. }
  1042. });
  1043. },
  1044. followingModal() {
  1045. if($('body').hasClass('loggedIn') == false) {
  1046. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1047. return;
  1048. }
  1049. if(this.profileSettings.following.list == false) {
  1050. return;
  1051. }
  1052. if(this.followingCursor) {
  1053. this.$refs.followingModal.show();
  1054. return;
  1055. } else {
  1056. axios.get('/api/v1/accounts/'+this.profileId+'/following', {
  1057. params: {
  1058. cursor: this.followingCursor,
  1059. limit: 40,
  1060. '_pe': 1
  1061. }
  1062. })
  1063. .then(res => {
  1064. this.following = res.data;
  1065. if(res.headers && res.headers.link) {
  1066. const links = parseLinkHeader(res.headers.link);
  1067. if(links.prev) {
  1068. this.followingCursor = links.prev.cursor;
  1069. this.followingMore = true;
  1070. } else {
  1071. this.followingMore = false;
  1072. }
  1073. } else {
  1074. this.followingMore = false;
  1075. }
  1076. })
  1077. .then(() => {
  1078. setTimeout(() => { this.followingLoading = false }, 1000);
  1079. });
  1080. this.$refs.followingModal.show();
  1081. return;
  1082. }
  1083. },
  1084. followersModal() {
  1085. if($('body').hasClass('loggedIn') == false) {
  1086. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1087. return;
  1088. }
  1089. if(this.profileSettings.followers.list == false) {
  1090. return;
  1091. }
  1092. if(this.followerCursor > 1) {
  1093. this.$refs.followerModal.show();
  1094. return;
  1095. } else {
  1096. axios.get('/api/v1/accounts/'+this.profileId+'/followers', {
  1097. params: {
  1098. cursor: this.followerCursor,
  1099. limit: 40,
  1100. '_pe': 1
  1101. }
  1102. })
  1103. .then(res => {
  1104. this.followers.push(...res.data);
  1105. if(res.headers && res.headers.link) {
  1106. const links = parseLinkHeader(res.headers.link);
  1107. if(links.prev) {
  1108. this.followerCursor = links.prev.cursor;
  1109. this.followerMore = true;
  1110. } else {
  1111. this.followerMore = false;
  1112. }
  1113. } else {
  1114. this.followerMore = false;
  1115. }
  1116. })
  1117. .then(() => {
  1118. setTimeout(() => { this.followerLoading = false }, 1000);
  1119. });
  1120. this.$refs.followerModal.show();
  1121. return;
  1122. }
  1123. },
  1124. followingLoadMore() {
  1125. if($('body').hasClass('loggedIn') == false) {
  1126. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  1127. return;
  1128. }
  1129. axios.get('/api/v1/accounts/'+this.profile.id+'/following', {
  1130. params: {
  1131. cursor: this.followingCursor,
  1132. limit: 40,
  1133. '_pe': 1
  1134. }
  1135. })
  1136. .then(res => {
  1137. if(res.data.length > 0) {
  1138. this.following.push(...res.data);
  1139. }
  1140. if(res.headers && res.headers.link) {
  1141. const links = parseLinkHeader(res.headers.link);
  1142. if(links.prev) {
  1143. this.followingCursor = links.prev.cursor;
  1144. this.followingMore = true;
  1145. } else {
  1146. this.followingMore = false;
  1147. }
  1148. } else {
  1149. this.followingMore = false;
  1150. }
  1151. });
  1152. },
  1153. followersLoadMore() {
  1154. if($('body').hasClass('loggedIn') == false) {
  1155. return;
  1156. }
  1157. axios.get('/api/v1/accounts/'+this.profile.id+'/followers', {
  1158. params: {
  1159. cursor: this.followerCursor,
  1160. limit: 40,
  1161. '_pe': 1
  1162. }
  1163. })
  1164. .then(res => {
  1165. if(res.data.length > 0) {
  1166. this.followers.push(...res.data);
  1167. }
  1168. if(res.headers && res.headers.link) {
  1169. const links = parseLinkHeader(res.headers.link);
  1170. if(links.prev) {
  1171. this.followerCursor = links.prev.cursor;
  1172. this.followerMore = true;
  1173. } else {
  1174. this.followerMore = false;
  1175. }
  1176. } else {
  1177. this.followerMore = false;
  1178. }
  1179. });
  1180. },
  1181. visitorMenu() {
  1182. this.$refs.visitorContextMenu.show();
  1183. },
  1184. followModalAction(id, index, type = 'following') {
  1185. const apiUrl = type === 'following' ?
  1186. '/api/v1/accounts/' + id + '/unfollow' :
  1187. '/api/v1/accounts/' + id + '/follow';
  1188. axios.post(apiUrl)
  1189. .then(res => {
  1190. if(type == 'following') {
  1191. this.following.splice(index, 1);
  1192. this.profile.following_count--;
  1193. }
  1194. }).catch(err => {
  1195. if(err.response.data.message) {
  1196. swal('Error', err.response.data.message, 'error');
  1197. }
  1198. });
  1199. },
  1200. momentBackground() {
  1201. let c = 'w-100 h-100 mt-n3 ';
  1202. if(this.profile.header_bg) {
  1203. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1204. } else {
  1205. c += 'bg-pixelfed';
  1206. }
  1207. return c;
  1208. },
  1209. loadSponsor() {
  1210. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1211. .then(res => {
  1212. this.sponsorList = res.data;
  1213. });
  1214. },
  1215. showSponsorModal() {
  1216. this.$refs.sponsorModal.show();
  1217. },
  1218. goBack() {
  1219. if(window.history.length > 2) {
  1220. window.history.back();
  1221. return;
  1222. } else {
  1223. window.location.href = '/';
  1224. return;
  1225. }
  1226. },
  1227. copyProfileLink() {
  1228. navigator.clipboard.writeText(window.location.href);
  1229. this.$refs.visitorContextMenu.hide();
  1230. },
  1231. formatCount(count) {
  1232. return App.util.format.count(count);
  1233. },
  1234. statusUrl(status) {
  1235. return status.url;
  1236. if(status.local == true) {
  1237. return status.url;
  1238. }
  1239. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1240. },
  1241. profileUrl(status) {
  1242. return status.url;
  1243. if(status.local == true) {
  1244. return status.account.url;
  1245. }
  1246. return '/i/web/profile/_/' + status.account.id;
  1247. },
  1248. profileUrlRedirect(profile) {
  1249. if(profile.local == true) {
  1250. return profile.url;
  1251. }
  1252. return '/i/web/profile/_/' + profile.id;
  1253. },
  1254. showEmbedProfileModal() {
  1255. this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url);
  1256. this.$refs.visitorContextMenu.hide();
  1257. this.$refs.embedModal.show();
  1258. },
  1259. ctxCopyEmbed() {
  1260. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1261. this.$refs.embedModal.hide();
  1262. this.$refs.visitorContextMenu.hide();
  1263. },
  1264. storyRedirect() {
  1265. window.location.href = '/stories/' + this.profileUsername + '?t=4';
  1266. },
  1267. truncate(str, len) {
  1268. return _.truncate(str, {
  1269. length: len
  1270. });
  1271. },
  1272. formatWebsite(site) {
  1273. if(site.slice(0, 8) === 'https://') {
  1274. site = site.substr(8);
  1275. } else if(site.slice(0, 7) === 'http://') {
  1276. site = site.substr(7);
  1277. } else {
  1278. this.profile.website = null;
  1279. return;
  1280. }
  1281. return this.truncate(site, 60);
  1282. },
  1283. joinedAtFormat(created) {
  1284. return new Date(created).toLocaleDateString(this.$i18n.locale, {
  1285. year: 'numeric',
  1286. month: 'long',
  1287. });
  1288. },
  1289. archivesInfiniteLoader($state) {
  1290. axios.get('/api/pixelfed/v2/statuses/archives', {
  1291. params: {
  1292. page: this.archivesPage
  1293. }
  1294. }).then(res => {
  1295. if(res.data.length) {
  1296. this.archives.push(...res.data);
  1297. this.archivesPage++;
  1298. $state.loaded();
  1299. } else {
  1300. $state.complete();
  1301. }
  1302. });
  1303. }
  1304. }
  1305. }
  1306. </script>