Profile.vue 43 KB

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