1
0

Profile.vue 43 KB

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