Profile.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  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">You are blocking this account</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">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">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">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. Donate
  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;">Edit Profile</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. 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. 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. Following
  130. </a>
  131. </div>
  132. </div>
  133. <p class="d-flex align-items-center mb-1">
  134. <span class="font-weight-bold mr-1">{{profile.display_name}}</span>
  135. <span v-if="profile.pronouns" class="text-muted small">{{profile.pronouns.join('/')}}</span>
  136. </p>
  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. Admin
  142. </span>
  143. <span v-if="relationship && relationship.followed_by" class="btn btn-outline-muted btn-sm py-0 mr-3">Follows You</span>
  144. <span>
  145. Joined {{joinedAtFormat(profile.created_at)}}
  146. </span>
  147. </p>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <div class="d-block d-md-none my-0 pt-3 border-bottom">
  155. <p v-if="user && user.hasOwnProperty('id')" 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')">Edit Profile</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 v-if="owner == true" class="list-group-item border-0 pt-0 px-0 mt-n2 mb-3">
  334. <span class="d-flex px-4 pb-0 align-items-center">
  335. <i class="fas fa-search text-lighter"></i>
  336. <input type="text" class="form-control border-0 shadow-0 no-focus" placeholder="Search Following..." v-model="followingModalSearch" v-on:keyup="followingModalSearchHandler">
  337. </span>
  338. </div>
  339. <div class="list-group-item border-0 py-1 mb-1" v-for="(user, index) in following" :key="'following_'+index">
  340. <div class="media">
  341. <a :href="profileUrlRedirect(user)">
  342. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" loading="lazy" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0'">
  343. </a>
  344. <div class="media-body text-truncate">
  345. <p class="mb-0" style="font-size: 14px">
  346. <a :href="profileUrlRedirect(user)" class="font-weight-bold text-dark">
  347. {{user.username}}
  348. </a>
  349. </p>
  350. <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">
  351. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  352. </p>
  353. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  354. {{user.display_name ? user.display_name : user.username}}
  355. </p>
  356. </div>
  357. <div v-if="owner">
  358. <a class="btn btn-outline-dark btn-sm font-weight-bold" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Following</a>
  359. </div>
  360. </div>
  361. </div>
  362. <div v-if="followingModalSearch && following.length == 0" class="list-group-item border-0">
  363. <div class="list-group-item border-0 pt-5">
  364. <p class="p-3 text-center mb-0 lead">No Results Found</p>
  365. </div>
  366. </div>
  367. <div v-if="following.length > 0 && followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
  368. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  369. </div>
  370. </div>
  371. </div>
  372. <div v-else class="text-center py-5">
  373. <div class="spinner-border" role="status">
  374. <span class="sr-only">Loading...</span>
  375. </div>
  376. </div>
  377. </b-modal>
  378. <b-modal ref="followerModal"
  379. id="follower-modal"
  380. hide-footer
  381. centered
  382. scrollable
  383. title="Followers"
  384. body-class="list-group-flush py-3 px-0"
  385. dialog-class="follow-modal"
  386. >
  387. <div v-if="!followerLoading" class="list-group" style="max-height: 60vh;">
  388. <div v-if="!followers.length" class="list-group-item border-0">
  389. <p class="text-center mb-0 font-weight-bold text-muted py-5">
  390. <span class="text-dark">{{profileUsername}}</span> has no followers yet</p>
  391. </div>
  392. <div v-else>
  393. <div class="list-group-item border-0 py-1 mb-1" v-for="(user, index) in followers" :key="'follower_'+index">
  394. <div class="media mb-0">
  395. <a :href="profileUrlRedirect(user)">
  396. <img class="mr-3 rounded-circle box-shadow" :src="user.avatar" :alt="user.username + '’s avatar'" width="30px" height="30px" loading="lazy" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0'">
  397. </a>
  398. <div class="media-body mb-0">
  399. <p class="mb-0" style="font-size: 14px">
  400. <a :href="profileUrlRedirect(user)" class="font-weight-bold text-dark">
  401. {{user.username}}
  402. </a>
  403. </p>
  404. <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">
  405. <span class="font-weight-bold">{{user.acct.split('@')[0]}}</span><span class="text-lighter">&commat;{{user.acct.split('@')[1]}}</span>
  406. </p>
  407. <p v-else class="text-muted mb-0 text-truncate" style="font-size: 14px">
  408. {{user.display_name ? user.display_name : user.username}}
  409. </p>
  410. </div>
  411. <!-- <button class="btn btn-primary font-weight-bold btn-sm py-1">FOLLOW</button> -->
  412. </div>
  413. </div>
  414. <div v-if="followers.length && followerMore" class="list-group-item text-center" v-on:click="followersLoadMore()">
  415. <p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
  416. </div>
  417. </div>
  418. </div>
  419. <div v-else class="text-center py-5">
  420. <div class="spinner-border" role="status">
  421. <span class="sr-only">Loading...</span>
  422. </div>
  423. </div>
  424. </b-modal>
  425. <b-modal ref="visitorContextMenu"
  426. id="visitor-context-menu"
  427. hide-footer
  428. hide-header
  429. centered
  430. size="sm"
  431. body-class="list-group-flush p-0">
  432. <div class="list-group" v-if="relationship">
  433. <div class="list-group-item cursor-pointer text-center rounded text-dark" @click="copyProfileLink">
  434. Copy Link
  435. </div>
  436. <div v-if="profile.locked == false" class="list-group-item cursor-pointer text-center rounded text-dark" @click="showEmbedProfileModal">
  437. Embed
  438. </div>
  439. <div v-if="user && !owner && !relationship.following" class="list-group-item cursor-pointer text-center rounded text-dark" @click="followProfile">
  440. Follow
  441. </div>
  442. <div v-if="user && !owner && relationship.following" class="list-group-item cursor-pointer text-center rounded" @click="followProfile">
  443. Unfollow
  444. </div>
  445. <div v-if="user && !owner && !relationship.muting" class="list-group-item cursor-pointer text-center rounded" @click="muteProfile">
  446. Mute
  447. </div>
  448. <div v-if="user && !owner && relationship.muting" class="list-group-item cursor-pointer text-center rounded" @click="unmuteProfile">
  449. Unmute
  450. </div>
  451. <div v-if="user && !owner" class="list-group-item cursor-pointer text-center rounded text-dark" @click="reportProfile">
  452. Report User
  453. </div>
  454. <div v-if="user && !owner && !relationship.blocking" class="list-group-item cursor-pointer text-center rounded text-dark" @click="blockProfile">
  455. Block
  456. </div>
  457. <div v-if="user && !owner && relationship.blocking" class="list-group-item cursor-pointer text-center rounded text-dark" @click="unblockProfile">
  458. Unblock
  459. </div>
  460. <div v-if="user && owner" class="list-group-item cursor-pointer text-center rounded text-dark" @click="redirect('/settings/home')">
  461. Settings
  462. </div>
  463. <div class="list-group-item cursor-pointer text-center rounded text-dark" @click="redirect('/users/' + profileUsername + '.atom')">
  464. Atom Feed
  465. </div>
  466. <div class="list-group-item cursor-pointer text-center rounded text-muted font-weight-bold" @click="$refs.visitorContextMenu.hide()">
  467. Close
  468. </div>
  469. </div>
  470. </b-modal>
  471. <b-modal ref="sponsorModal"
  472. id="sponsor-modal"
  473. hide-footer
  474. :title="'Sponsor ' + profileUsername"
  475. centered
  476. size="md"
  477. body-class="px-5">
  478. <div>
  479. <p class="font-weight-bold">External Links</p>
  480. <p v-if="sponsorList.patreon" class="pt-2">
  481. <a :href="'https://' + sponsorList.patreon" rel="nofollow" class="font-weight-bold">{{sponsorList.patreon}}</a>
  482. </p>
  483. <p v-if="sponsorList.liberapay" class="pt-2">
  484. <a :href="'https://' + sponsorList.liberapay" rel="nofollow" class="font-weight-bold">{{sponsorList.liberapay}}</a>
  485. </p>
  486. <p v-if="sponsorList.opencollective" class="pt-2">
  487. <a :href="'https://' + sponsorList.opencollective" rel="nofollow" class="font-weight-bold">{{sponsorList.opencollective}}</a>
  488. </p>
  489. </div>
  490. </b-modal>
  491. <b-modal ref="embedModal"
  492. id="ctx-embed-modal"
  493. hide-header
  494. hide-footer
  495. centered
  496. rounded
  497. size="md"
  498. body-class="p-2 rounded">
  499. <div>
  500. <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>
  501. <hr>
  502. <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>
  503. <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>
  504. </div>
  505. </b-modal>
  506. </div>
  507. </template>
  508. <style type="text/css" scoped>
  509. .o-square {
  510. max-width: 320px;
  511. }
  512. .o-portrait {
  513. max-width: 320px;
  514. }
  515. .o-landscape {
  516. max-width: 320px;
  517. }
  518. .post-icon {
  519. color: #fff;
  520. position:relative;
  521. margin-top: 10px;
  522. z-index: 9;
  523. opacity: 0.6;
  524. text-shadow: 3px 3px 16px #272634;
  525. }
  526. .font-size-16px {
  527. font-size: 16px;
  528. }
  529. .profile-website {
  530. color: #003569;
  531. text-decoration: none;
  532. font-weight: 600;
  533. }
  534. .nav-topbar .nav-link {
  535. color: #999;
  536. }
  537. .nav-topbar .nav-link .small {
  538. font-weight: 600;
  539. }
  540. .has-story {
  541. width: 84px;
  542. height: 84px;
  543. border-radius: 50%;
  544. padding: 4px;
  545. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  546. }
  547. .has-story img {
  548. width: 76px;
  549. height: 76px;
  550. border-radius: 50%;
  551. padding: 6px;
  552. background: #fff;
  553. }
  554. .has-story-lg {
  555. width: 159px;
  556. height: 159px;
  557. border-radius: 50%;
  558. padding: 4px;
  559. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  560. }
  561. .has-story-lg img {
  562. width: 150px;
  563. height: 150px;
  564. border-radius: 50%;
  565. padding: 6px;
  566. background:#fff;
  567. }
  568. .no-focus {
  569. border-color: none;
  570. outline: 0;
  571. box-shadow: none;
  572. }
  573. .modal-tab-active {
  574. border-bottom: 1px solid #08d;
  575. }
  576. .btn-sec-alt:hover {
  577. color: #ccc;
  578. opacity: .7;
  579. background-color: transparent;
  580. border-color: #6c757d;
  581. }
  582. </style>
  583. <script type="text/javascript">
  584. import VueMasonry from 'vue-masonry-css'
  585. import StatusCard from './partials/StatusCard.vue';
  586. export default {
  587. props: [
  588. 'profile-id',
  589. 'profile-layout',
  590. 'profile-settings',
  591. 'profile-username'
  592. ],
  593. components: {
  594. StatusCard,
  595. },
  596. data() {
  597. return {
  598. ids: [],
  599. profile: {},
  600. user: false,
  601. timeline: [],
  602. timelinePage: 2,
  603. min_id: 0,
  604. max_id: 0,
  605. loading: true,
  606. owner: false,
  607. layout: 'metro',
  608. mode: 'grid',
  609. modes: ['grid', 'collections', 'bookmarks', 'archives'],
  610. modalStatus: false,
  611. relationship: {},
  612. followers: [],
  613. followerCursor: 1,
  614. followerMore: true,
  615. followerLoading: true,
  616. following: [],
  617. followingCursor: 1,
  618. followingMore: true,
  619. followingLoading: true,
  620. warning: false,
  621. sponsorList: [],
  622. bookmarks: [],
  623. bookmarksPage: 2,
  624. collections: [],
  625. collectionsLoaded: false,
  626. collectionsPage: 2,
  627. isMobile: false,
  628. ctxEmbedPayload: null,
  629. copiedEmbed: false,
  630. hasStory: null,
  631. followingModalSearch: null,
  632. followingModalSearchCache: null,
  633. followingModalTab: 'following',
  634. bookmarksLoading: true,
  635. archives: [],
  636. archivesPage: 2
  637. }
  638. },
  639. beforeMount() {
  640. this.fetchProfile();
  641. let u = new URLSearchParams(window.location.search);
  642. this.layout = 'metro';
  643. if(this.layout == 'metro' && u.has('t')) {
  644. if(this.modes.indexOf(u.get('t')) != -1) {
  645. if(u.get('t') == 'bookmarks') {
  646. return;
  647. }
  648. this.mode = u.get('t');
  649. }
  650. }
  651. if(u.has('m') && this.modes.includes(u.get('m'))) {
  652. this.mode = u.get('m');
  653. if(this.mode == 'bookmarks') {
  654. axios.get('/api/local/bookmarks')
  655. .then(res => {
  656. this.bookmarks = res.data;
  657. this.bookmarksLoading = false;
  658. }).catch(err => {
  659. this.mode = 'grid';
  660. });
  661. }
  662. if(this.mode == 'collections') {
  663. axios.get('/api/local/profile/collections/' + this.profileId)
  664. .then(res => {
  665. this.collections = res.data
  666. this.collectionsLoaded = true;
  667. }).catch(err => {
  668. this.mode = 'grid';
  669. });
  670. }
  671. if(this.mode == 'archives') {
  672. axios.get('/api/pixelfed/v2/statuses/archives')
  673. .then(res => {
  674. this.archives = res.data;
  675. }).catch(err => {
  676. this.mode = 'grid';
  677. });
  678. }
  679. }
  680. },
  681. mounted() {
  682. let u = new URLSearchParams(window.location.search);
  683. if(u.has('md') && u.get('md') == 'followers') {
  684. this.followersModal();
  685. }
  686. if(u.has('md') && u.get('md') == 'following') {
  687. this.followingModal();
  688. }
  689. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  690. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  691. this.user = res.data;
  692. window._sharedData.curUser = res.data;
  693. window.App.util.navatar();
  694. this.fetchRelationships();
  695. });
  696. }
  697. },
  698. updated() {
  699. $('[data-toggle="tooltip"]').tooltip();
  700. },
  701. methods: {
  702. fetchProfile() {
  703. axios.get('/api/pixelfed/v1/accounts/' + this.profileId).then(res => {
  704. this.profile = res.data;
  705. }).then(res => {
  706. this.fetchPosts();
  707. });
  708. },
  709. fetchPosts() {
  710. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  711. axios.get(apiUrl, {
  712. params: {
  713. only_media: true,
  714. min_id: 1,
  715. }
  716. })
  717. .then(res => {
  718. let data = res.data.filter(status => status.media_attachments.length > 0);
  719. let ids = data.map(status => status.id);
  720. this.ids = ids;
  721. this.min_id = Math.max(...ids);
  722. this.max_id = Math.min(...ids);
  723. this.modalStatus = _.first(res.data);
  724. this.timeline = data;
  725. this.ownerCheck();
  726. this.loading = false;
  727. //this.loadSponsor();
  728. }).catch(err => {
  729. swal('Oops, something went wrong',
  730. 'Please release the page.',
  731. 'error');
  732. });
  733. },
  734. ownerCheck() {
  735. if($('body').hasClass('loggedIn') == false) {
  736. this.owner = false;
  737. return;
  738. }
  739. this.owner = this.profile.id === this.user.id;
  740. },
  741. infiniteTimeline($state) {
  742. if(this.loading || this.timeline.length < 9) {
  743. $state.complete();
  744. return;
  745. }
  746. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  747. axios.get(apiUrl, {
  748. params: {
  749. only_media: true,
  750. max_id: this.max_id
  751. },
  752. }).then(res => {
  753. if (res.data.length && this.loading == false) {
  754. let data = res.data;
  755. let self = this;
  756. data.forEach(d => {
  757. if(self.ids.indexOf(d.id) == -1) {
  758. self.timeline.push(d);
  759. self.ids.push(d.id);
  760. }
  761. });
  762. let max = Math.min(...this.ids);
  763. if(max == this.max_id) {
  764. $state.complete();
  765. return;
  766. }
  767. this.min_id = Math.max(...this.ids);
  768. this.max_id = max;
  769. $state.loaded();
  770. this.loading = false;
  771. } else {
  772. $state.complete();
  773. }
  774. });
  775. },
  776. previewUrl(status) {
  777. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  778. },
  779. previewBackground(status) {
  780. let preview = this.previewUrl(status);
  781. return 'background-image: url(' + preview + ');';
  782. },
  783. blurhHashMedia(status) {
  784. return status.sensitive ? null :
  785. status.media_attachments[0].preview_url;
  786. },
  787. switchMode(mode) {
  788. if(mode == 'grid') {
  789. this.mode = mode;
  790. } else if(mode == 'bookmarks' && this.bookmarks.length) {
  791. this.mode = 'bookmarks';
  792. } else if(mode == 'collections' && this.collections.length) {
  793. this.mode = 'collections';
  794. } else {
  795. window.location.href = '/' + this.profileUsername + '?m=' + mode;
  796. return;
  797. }
  798. },
  799. reportProfile() {
  800. let id = this.profile.id;
  801. window.location.href = '/i/report?type=user&id=' + id;
  802. },
  803. reportUrl(status) {
  804. let type = status.in_reply_to ? 'comment' : 'post';
  805. let id = status.id;
  806. return '/i/report?type=' + type + '&id=' + id;
  807. },
  808. commentFocus(status, $event) {
  809. let el = event.target;
  810. let card = el.parentElement.parentElement.parentElement;
  811. let comments = card.getElementsByClassName('comments')[0];
  812. if(comments.children.length == 0) {
  813. comments.classList.add('mb-2');
  814. this.fetchStatusComments(status, card);
  815. }
  816. let footer = card.querySelectorAll('.card-footer')[0];
  817. let input = card.querySelectorAll('.status-reply-input')[0];
  818. if(footer.classList.contains('d-none') == true) {
  819. footer.classList.remove('d-none');
  820. input.focus();
  821. } else {
  822. footer.classList.add('d-none');
  823. input.blur();
  824. }
  825. },
  826. likeStatus(status, $event) {
  827. if($('body').hasClass('loggedIn') == false) {
  828. return;
  829. }
  830. axios.post('/i/like', {
  831. item: status.id
  832. }).then(res => {
  833. status.favourites_count = res.data.count;
  834. if(status.favourited == true) {
  835. status.favourited = false;
  836. } else {
  837. status.favourited = true;
  838. }
  839. }).catch(err => {
  840. swal('Error', 'Something went wrong, please try again later.', 'error');
  841. });
  842. },
  843. shareStatus(status, $event) {
  844. if($('body').hasClass('loggedIn') == false) {
  845. return;
  846. }
  847. axios.post('/i/share', {
  848. item: status.id
  849. }).then(res => {
  850. status.reblogs_count = res.data.count;
  851. if(status.reblogged == true) {
  852. status.reblogged = false;
  853. } else {
  854. status.reblogged = true;
  855. }
  856. }).catch(err => {
  857. swal('Error', 'Something went wrong, please try again later.', 'error');
  858. });
  859. },
  860. timestampFormat(timestamp) {
  861. let ts = new Date(timestamp);
  862. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  863. },
  864. editUrl(status) {
  865. return status.url + '/edit';
  866. },
  867. redirect(url) {
  868. window.location.href = url;
  869. return;
  870. },
  871. remoteRedirect(url) {
  872. window.location.href = window.App.config.site.url + '/i/redirect?url=' + encodeURIComponent(url);
  873. return;
  874. },
  875. replyUrl(status) {
  876. let username = this.profile.username;
  877. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  878. return '/p/' + username + '/' + id;
  879. },
  880. mentionUrl(status) {
  881. let username = status.account.username;
  882. let id = status.id;
  883. return '/p/' + username + '/' + id;
  884. },
  885. statusOwner(status) {
  886. let sid = status.account.id;
  887. let uid = this.profile.id;
  888. if(sid == uid) {
  889. return true;
  890. } else {
  891. return false;
  892. }
  893. },
  894. fetchRelationships() {
  895. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  896. return;
  897. }
  898. axios.get('/api/pixelfed/v1/accounts/relationships', {
  899. params: {
  900. 'id[]': this.profileId
  901. }
  902. }).then(res => {
  903. if(res.data.length) {
  904. this.relationship = res.data[0];
  905. if(res.data[0].blocking == true) {
  906. this.warning = true;
  907. }
  908. }
  909. if(this.user.id == this.profileId || this.relationship.following == true) {
  910. axios.get('/api/web/stories/v1/exists/' + this.profileId)
  911. .then(res => {
  912. this.hasStory = (res.data == true);
  913. })
  914. }
  915. });
  916. },
  917. muteProfile(status = null) {
  918. if($('body').hasClass('loggedIn') == false) {
  919. return;
  920. }
  921. let id = this.profileId;
  922. axios.post('/i/mute', {
  923. type: 'user',
  924. item: id
  925. }).then(res => {
  926. this.fetchRelationships();
  927. this.$refs.visitorContextMenu.hide();
  928. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  929. }).catch(err => {
  930. if(err.response.status == 422) {
  931. swal('Error', err.response.data.error, 'error');
  932. } else {
  933. swal('Error', 'Something went wrong. Please try again later.', 'error');
  934. }
  935. });
  936. },
  937. unmuteProfile(status = null) {
  938. if($('body').hasClass('loggedIn') == false) {
  939. return;
  940. }
  941. let id = this.profileId;
  942. axios.post('/i/unmute', {
  943. type: 'user',
  944. item: id
  945. }).then(res => {
  946. this.fetchRelationships();
  947. this.$refs.visitorContextMenu.hide();
  948. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  949. }).catch(err => {
  950. swal('Error', 'Something went wrong. Please try again later.', 'error');
  951. });
  952. },
  953. blockProfile(status = null) {
  954. if($('body').hasClass('loggedIn') == false) {
  955. return;
  956. }
  957. let id = this.profileId;
  958. axios.post('/i/block', {
  959. type: 'user',
  960. item: id
  961. }).then(res => {
  962. this.warning = true;
  963. this.fetchRelationships();
  964. this.$refs.visitorContextMenu.hide();
  965. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  966. }).catch(err => {
  967. if(err.response.status == 422) {
  968. swal('Error', err.response.data.error, 'error');
  969. } else {
  970. swal('Error', 'Something went wrong. Please try again later.', 'error');
  971. }
  972. });
  973. },
  974. unblockProfile(status = null) {
  975. if($('body').hasClass('loggedIn') == false) {
  976. return;
  977. }
  978. let id = this.profileId;
  979. axios.post('/i/unblock', {
  980. type: 'user',
  981. item: id
  982. }).then(res => {
  983. this.fetchRelationships();
  984. this.$refs.visitorContextMenu.hide();
  985. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  986. }).catch(err => {
  987. swal('Error', 'Something went wrong. Please try again later.', 'error');
  988. });
  989. },
  990. deletePost(status, index) {
  991. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  992. return;
  993. }
  994. axios.post('/i/delete', {
  995. type: 'status',
  996. item: status.id
  997. }).then(res => {
  998. this.timeline.splice(index,1);
  999. swal('Success', 'You have successfully deleted this post', 'success');
  1000. }).catch(err => {
  1001. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1002. });
  1003. },
  1004. followProfile() {
  1005. if($('body').hasClass('loggedIn') == false) {
  1006. return;
  1007. }
  1008. axios.post('/i/follow', {
  1009. item: this.profileId
  1010. }).then(res => {
  1011. this.$refs.visitorContextMenu.hide();
  1012. if(this.relationship.following) {
  1013. this.profile.followers_count--;
  1014. if(this.profile.locked == true) {
  1015. window.location.href = '/';
  1016. }
  1017. } else {
  1018. this.profile.followers_count++;
  1019. }
  1020. this.relationship.following = !this.relationship.following;
  1021. }).catch(err => {
  1022. if(err.response.data.message) {
  1023. swal('Error', err.response.data.message, 'error');
  1024. }
  1025. });
  1026. },
  1027. followingModal() {
  1028. if($('body').hasClass('loggedIn') == false) {
  1029. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1030. return;
  1031. }
  1032. if(this.profileSettings.following.list == false) {
  1033. return;
  1034. }
  1035. if(this.followingCursor > 1) {
  1036. this.$refs.followingModal.show();
  1037. return;
  1038. } else {
  1039. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/following', {
  1040. params: {
  1041. page: this.followingCursor
  1042. }
  1043. })
  1044. .then(res => {
  1045. this.following = res.data;
  1046. this.followingModalSearchCache = res.data;
  1047. this.followingCursor++;
  1048. if(res.data.length < 10) {
  1049. this.followingMore = false;
  1050. }
  1051. this.followingLoading = false;
  1052. });
  1053. this.$refs.followingModal.show();
  1054. return;
  1055. }
  1056. },
  1057. followersModal() {
  1058. if($('body').hasClass('loggedIn') == false) {
  1059. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1060. return;
  1061. }
  1062. if(this.profileSettings.followers.list == false) {
  1063. return;
  1064. }
  1065. if(this.followerCursor > 1) {
  1066. this.$refs.followerModal.show();
  1067. return;
  1068. } else {
  1069. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/followers', {
  1070. params: {
  1071. page: this.followerCursor
  1072. }
  1073. })
  1074. .then(res => {
  1075. this.followers.push(...res.data);
  1076. this.followerCursor++;
  1077. if(res.data.length < 10) {
  1078. this.followerMore = false;
  1079. }
  1080. this.followerLoading = false;
  1081. })
  1082. this.$refs.followerModal.show();
  1083. return;
  1084. }
  1085. },
  1086. followingLoadMore() {
  1087. if($('body').hasClass('loggedIn') == false) {
  1088. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  1089. return;
  1090. }
  1091. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  1092. params: {
  1093. page: this.followingCursor,
  1094. fbu: this.followingModalSearch
  1095. }
  1096. })
  1097. .then(res => {
  1098. if(res.data.length > 0) {
  1099. this.following.push(...res.data);
  1100. this.followingCursor++;
  1101. this.followingModalSearchCache = this.following;
  1102. }
  1103. if(res.data.length < 10) {
  1104. this.followingModalSearchCache = this.following;
  1105. this.followingMore = false;
  1106. }
  1107. });
  1108. },
  1109. followersLoadMore() {
  1110. if($('body').hasClass('loggedIn') == false) {
  1111. return;
  1112. }
  1113. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  1114. params: {
  1115. page: this.followerCursor
  1116. }
  1117. })
  1118. .then(res => {
  1119. if(res.data.length > 0) {
  1120. this.followers.push(...res.data);
  1121. this.followerCursor++;
  1122. }
  1123. if(res.data.length < 10) {
  1124. this.followerMore = false;
  1125. }
  1126. });
  1127. },
  1128. visitorMenu() {
  1129. this.$refs.visitorContextMenu.show();
  1130. },
  1131. followModalAction(id, index, type = 'following') {
  1132. axios.post('/i/follow', {
  1133. item: id
  1134. }).then(res => {
  1135. if(type == 'following') {
  1136. this.following.splice(index, 1);
  1137. this.profile.following_count--;
  1138. }
  1139. }).catch(err => {
  1140. if(err.response.data.message) {
  1141. swal('Error', err.response.data.message, 'error');
  1142. }
  1143. });
  1144. },
  1145. momentBackground() {
  1146. let c = 'w-100 h-100 mt-n3 ';
  1147. if(this.profile.header_bg) {
  1148. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1149. } else {
  1150. c += 'bg-pixelfed';
  1151. }
  1152. return c;
  1153. },
  1154. loadSponsor() {
  1155. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1156. .then(res => {
  1157. this.sponsorList = res.data;
  1158. });
  1159. },
  1160. showSponsorModal() {
  1161. this.$refs.sponsorModal.show();
  1162. },
  1163. goBack() {
  1164. if(window.history.length > 2) {
  1165. window.history.back();
  1166. return;
  1167. } else {
  1168. window.location.href = '/';
  1169. return;
  1170. }
  1171. },
  1172. copyProfileLink() {
  1173. navigator.clipboard.writeText(window.location.href);
  1174. this.$refs.visitorContextMenu.hide();
  1175. },
  1176. formatCount(count) {
  1177. return App.util.format.count(count);
  1178. },
  1179. statusUrl(status) {
  1180. return status.url;
  1181. if(status.local == true) {
  1182. return status.url;
  1183. }
  1184. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1185. },
  1186. profileUrl(status) {
  1187. return status.url;
  1188. if(status.local == true) {
  1189. return status.account.url;
  1190. }
  1191. return '/i/web/profile/_/' + status.account.id;
  1192. },
  1193. profileUrlRedirect(profile) {
  1194. if(profile.local == true) {
  1195. return profile.url;
  1196. }
  1197. return '/i/web/profile/_/' + profile.id;
  1198. },
  1199. showEmbedProfileModal() {
  1200. this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url);
  1201. this.$refs.visitorContextMenu.hide();
  1202. this.$refs.embedModal.show();
  1203. },
  1204. ctxCopyEmbed() {
  1205. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1206. this.$refs.embedModal.hide();
  1207. this.$refs.visitorContextMenu.hide();
  1208. },
  1209. storyRedirect() {
  1210. window.location.href = '/stories/' + this.profileUsername + '?t=4';
  1211. },
  1212. followingModalSearchHandler() {
  1213. let self = this;
  1214. let q = this.followingModalSearch;
  1215. if(q.length == 0) {
  1216. this.following = this.followingModalSearchCache;
  1217. this.followingModalSearch = null;
  1218. }
  1219. if(q.length > 0) {
  1220. let url = '/api/pixelfed/v1/accounts/' +
  1221. self.profileId + '/following?page=1&fbu=' +
  1222. q;
  1223. axios.get(url).then(res => {
  1224. this.following = res.data;
  1225. }).catch(err => {
  1226. self.following = self.followingModalSearchCache;
  1227. self.followingModalSearch = null;
  1228. });
  1229. }
  1230. },
  1231. truncate(str, len) {
  1232. return _.truncate(str, {
  1233. length: len
  1234. });
  1235. },
  1236. formatWebsite(site) {
  1237. if(site.slice(0, 8) === 'https://') {
  1238. site = site.substr(8);
  1239. } else if(site.slice(0, 7) === 'http://') {
  1240. site = site.substr(7);
  1241. } else {
  1242. this.profile.website = null;
  1243. return;
  1244. }
  1245. return this.truncate(site, 60);
  1246. },
  1247. joinedAtFormat(created) {
  1248. let d = new Date(created);
  1249. return d.toDateString();
  1250. },
  1251. archivesInfiniteLoader($state) {
  1252. axios.get('/api/pixelfed/v2/statuses/archives', {
  1253. params: {
  1254. page: this.archivesPage
  1255. }
  1256. }).then(res => {
  1257. if(res.data.length) {
  1258. this.archives.push(...res.data);
  1259. this.archivesPage++;
  1260. $state.loaded();
  1261. } else {
  1262. $state.complete();
  1263. }
  1264. });
  1265. }
  1266. }
  1267. }
  1268. </script>