Profile.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  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">{{truncate(profile.website,24)}}</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> <span class="d-none d-md-inline-block small pl-1">SAVED</span></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-dark" @click="redirect('/users/' + profileUsername + '.atom')">
  497. Atom Feed
  498. </div>
  499. <div class="list-group-item cursor-pointer text-center rounded text-muted font-weight-bold" @click="$refs.visitorContextMenu.hide()">
  500. Close
  501. </div>
  502. </div>
  503. </b-modal>
  504. <b-modal ref="sponsorModal"
  505. id="sponsor-modal"
  506. hide-footer
  507. :title="'Sponsor ' + profileUsername"
  508. centered
  509. size="md"
  510. body-class="px-5">
  511. <div>
  512. <p class="font-weight-bold">External Links</p>
  513. <p v-if="sponsorList.patreon" class="pt-2">
  514. <a :href="'https://' + sponsorList.patreon" rel="nofollow" class="font-weight-bold">{{sponsorList.patreon}}</a>
  515. </p>
  516. <p v-if="sponsorList.liberapay" class="pt-2">
  517. <a :href="'https://' + sponsorList.liberapay" rel="nofollow" class="font-weight-bold">{{sponsorList.liberapay}}</a>
  518. </p>
  519. <p v-if="sponsorList.opencollective" class="pt-2">
  520. <a :href="'https://' + sponsorList.opencollective" rel="nofollow" class="font-weight-bold">{{sponsorList.opencollective}}</a>
  521. </p>
  522. </div>
  523. </b-modal>
  524. <b-modal ref="embedModal"
  525. id="ctx-embed-modal"
  526. hide-header
  527. hide-footer
  528. centered
  529. rounded
  530. size="md"
  531. body-class="p-2 rounded">
  532. <div>
  533. <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>
  534. <hr>
  535. <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>
  536. <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>
  537. </div>
  538. </b-modal>
  539. </div>
  540. </template>
  541. <style type="text/css" scoped>
  542. .o-square {
  543. max-width: 320px;
  544. }
  545. .o-portrait {
  546. max-width: 320px;
  547. }
  548. .o-landscape {
  549. max-width: 320px;
  550. }
  551. .post-icon {
  552. color: #fff;
  553. position:relative;
  554. margin-top: 10px;
  555. z-index: 9;
  556. opacity: 0.6;
  557. text-shadow: 3px 3px 16px #272634;
  558. }
  559. .font-size-16px {
  560. font-size: 16px;
  561. }
  562. .profile-website {
  563. color: #003569;
  564. text-decoration: none;
  565. font-weight: 600;
  566. }
  567. .nav-topbar .nav-link {
  568. color: #999;
  569. }
  570. .nav-topbar .nav-link .small {
  571. font-weight: 600;
  572. }
  573. .has-story {
  574. width: 84px;
  575. height: 84px;
  576. border-radius: 50%;
  577. padding: 4px;
  578. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  579. }
  580. .has-story img {
  581. width: 76px;
  582. height: 76px;
  583. border-radius: 50%;
  584. padding: 6px;
  585. background: #fff;
  586. }
  587. .has-story-lg {
  588. width: 159px;
  589. height: 159px;
  590. border-radius: 50%;
  591. padding: 4px;
  592. background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
  593. }
  594. .has-story-lg img {
  595. width: 150px;
  596. height: 150px;
  597. border-radius: 50%;
  598. padding: 6px;
  599. background:#fff;
  600. }
  601. .no-focus {
  602. border-color: none;
  603. outline: 0;
  604. box-shadow: none;
  605. }
  606. .modal-tab-active {
  607. border-bottom: 1px solid #08d;
  608. }
  609. </style>
  610. <script type="text/javascript">
  611. import VueMasonry from 'vue-masonry-css'
  612. export default {
  613. props: [
  614. 'profile-id',
  615. 'profile-layout',
  616. 'profile-settings',
  617. 'profile-username'
  618. ],
  619. data() {
  620. return {
  621. ids: [],
  622. profile: {},
  623. user: false,
  624. timeline: [],
  625. timelinePage: 2,
  626. min_id: 0,
  627. max_id: 0,
  628. loading: true,
  629. owner: false,
  630. layout: this.profileLayout,
  631. mode: 'grid',
  632. modes: ['grid', 'collections', 'bookmarks'],
  633. modalStatus: false,
  634. relationship: {},
  635. followers: [],
  636. followerCursor: 1,
  637. followerMore: true,
  638. following: [],
  639. followingCursor: 1,
  640. followingMore: true,
  641. warning: false,
  642. sponsorList: [],
  643. bookmarks: [],
  644. bookmarksPage: 2,
  645. collections: [],
  646. collectionsPage: 2,
  647. isMobile: false,
  648. ctxEmbedPayload: null,
  649. copiedEmbed: false,
  650. hasStory: null,
  651. followingModalSearch: null,
  652. followingModalSearchCache: null,
  653. followingModalTab: 'following',
  654. bookmarksLoading: true,
  655. }
  656. },
  657. beforeMount() {
  658. this.fetchRelationships();
  659. this.fetchProfile();
  660. let u = new URLSearchParams(window.location.search);
  661. let forceMetro = localStorage.getItem('pf_metro_ui.exp.forceMetro') == 'true';
  662. if(forceMetro == true || u.has('ui') && u.get('ui') == 'metro' && this.layout != 'metro') {
  663. this.layout = 'metro';
  664. }
  665. if(u.has('ui') && u.get('ui') == 'moment' && this.layout != 'moment') {
  666. Vue.use(VueMasonry);
  667. this.layout = 'moment';
  668. }
  669. if(this.layout == 'metro' && u.has('t')) {
  670. if(this.modes.indexOf(u.get('t')) != -1) {
  671. if(u.get('t') == 'bookmarks') {
  672. return;
  673. }
  674. this.mode = u.get('t');
  675. }
  676. }
  677. },
  678. mounted() {
  679. let u = new URLSearchParams(window.location.search);
  680. if(u.has('md') && u.get('md') == 'followers') {
  681. this.followersModal();
  682. }
  683. if(u.has('md') && u.get('md') == 'following') {
  684. this.followingModal();
  685. }
  686. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
  687. axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
  688. this.user = res.data;
  689. if(res.data.id == this.profileId || this.relationship.following == true) {
  690. axios.get('/api/stories/v0/exists/' + this.profileId)
  691. .then(res => {
  692. this.hasStory = res.data == true;
  693. })
  694. }
  695. });
  696. }
  697. if(window.outerWidth < 576) {
  698. $('nav.navbar').hide();
  699. this.isMobile = true;
  700. }
  701. },
  702. updated() {
  703. $('[data-toggle="tooltip"]').tooltip();
  704. },
  705. methods: {
  706. fetchProfile() {
  707. axios.get('/api/pixelfed/v1/accounts/' + this.profileId).then(res => {
  708. this.profile = res.data;
  709. }).then(res => {
  710. this.fetchPosts();
  711. });
  712. },
  713. fetchPosts() {
  714. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  715. axios.get(apiUrl, {
  716. params: {
  717. only_media: true,
  718. min_id: 1,
  719. }
  720. })
  721. .then(res => {
  722. let data = res.data.filter(status => status.media_attachments.length > 0);
  723. let ids = data.map(status => status.id);
  724. this.ids = ids;
  725. this.min_id = Math.max(...ids);
  726. this.max_id = Math.min(...ids);
  727. this.modalStatus = _.first(res.data);
  728. this.timeline = data;
  729. this.ownerCheck();
  730. this.loading = false;
  731. //this.loadSponsor();
  732. }).catch(err => {
  733. swal('Oops, something went wrong',
  734. 'Please release the page.',
  735. 'error');
  736. });
  737. },
  738. ownerCheck() {
  739. if($('body').hasClass('loggedIn') == false) {
  740. this.owner = false;
  741. return;
  742. }
  743. this.owner = this.profile.id === this.user.id;
  744. },
  745. infiniteTimeline($state) {
  746. if(this.loading || this.timeline.length < 9) {
  747. $state.complete();
  748. return;
  749. }
  750. let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses';
  751. axios.get(apiUrl, {
  752. params: {
  753. only_media: true,
  754. max_id: this.max_id
  755. },
  756. }).then(res => {
  757. if (res.data.length && this.loading == false) {
  758. let data = res.data;
  759. let self = this;
  760. data.forEach(d => {
  761. if(self.ids.indexOf(d.id) == -1) {
  762. self.timeline.push(d);
  763. self.ids.push(d.id);
  764. }
  765. });
  766. let max = Math.min(...this.ids);
  767. if(max == this.max_id) {
  768. $state.complete();
  769. return;
  770. }
  771. this.min_id = Math.max(...this.ids);
  772. this.max_id = max;
  773. $state.loaded();
  774. this.loading = false;
  775. } else {
  776. $state.complete();
  777. }
  778. });
  779. },
  780. previewUrl(status) {
  781. return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url;
  782. },
  783. previewBackground(status) {
  784. let preview = this.previewUrl(status);
  785. return 'background-image: url(' + preview + ');';
  786. },
  787. switchMode(mode) {
  788. this.mode = _.indexOf(this.modes, mode) ? mode : 'grid';
  789. if(this.mode == 'bookmarks' && this.bookmarks.length == 0) {
  790. axios.get('/api/local/bookmarks')
  791. .then(res => {
  792. this.bookmarks = res.data;
  793. this.bookmarksLoading = false;
  794. });
  795. }
  796. if(this.mode == 'collections' && this.collections.length == 0) {
  797. axios.get('/api/local/profile/collections/' + this.profileId)
  798. .then(res => {
  799. this.collections = res.data
  800. });
  801. }
  802. },
  803. reportProfile() {
  804. let id = this.profile.id;
  805. window.location.href = '/i/report?type=user&id=' + id;
  806. },
  807. reportUrl(status) {
  808. let type = status.in_reply_to ? 'comment' : 'post';
  809. let id = status.id;
  810. return '/i/report?type=' + type + '&id=' + id;
  811. },
  812. commentFocus(status, $event) {
  813. let el = event.target;
  814. let card = el.parentElement.parentElement.parentElement;
  815. let comments = card.getElementsByClassName('comments')[0];
  816. if(comments.children.length == 0) {
  817. comments.classList.add('mb-2');
  818. this.fetchStatusComments(status, card);
  819. }
  820. let footer = card.querySelectorAll('.card-footer')[0];
  821. let input = card.querySelectorAll('.status-reply-input')[0];
  822. if(footer.classList.contains('d-none') == true) {
  823. footer.classList.remove('d-none');
  824. input.focus();
  825. } else {
  826. footer.classList.add('d-none');
  827. input.blur();
  828. }
  829. },
  830. likeStatus(status, $event) {
  831. if($('body').hasClass('loggedIn') == false) {
  832. return;
  833. }
  834. axios.post('/i/like', {
  835. item: status.id
  836. }).then(res => {
  837. status.favourites_count = res.data.count;
  838. if(status.favourited == true) {
  839. status.favourited = false;
  840. } else {
  841. status.favourited = true;
  842. }
  843. }).catch(err => {
  844. swal('Error', 'Something went wrong, please try again later.', 'error');
  845. });
  846. },
  847. shareStatus(status, $event) {
  848. if($('body').hasClass('loggedIn') == false) {
  849. return;
  850. }
  851. axios.post('/i/share', {
  852. item: status.id
  853. }).then(res => {
  854. status.reblogs_count = res.data.count;
  855. if(status.reblogged == true) {
  856. status.reblogged = false;
  857. } else {
  858. status.reblogged = true;
  859. }
  860. }).catch(err => {
  861. swal('Error', 'Something went wrong, please try again later.', 'error');
  862. });
  863. },
  864. timestampFormat(timestamp) {
  865. let ts = new Date(timestamp);
  866. return ts.toDateString() + ' ' + ts.toLocaleTimeString();
  867. },
  868. editUrl(status) {
  869. return status.url + '/edit';
  870. },
  871. redirect(url) {
  872. window.location.href = url;
  873. return;
  874. },
  875. replyUrl(status) {
  876. let username = this.profile.username;
  877. let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
  878. return '/p/' + username + '/' + id;
  879. },
  880. mentionUrl(status) {
  881. let username = status.account.username;
  882. let id = status.id;
  883. return '/p/' + username + '/' + id;
  884. },
  885. statusOwner(status) {
  886. let sid = status.account.id;
  887. let uid = this.profile.id;
  888. if(sid == uid) {
  889. return true;
  890. } else {
  891. return false;
  892. }
  893. },
  894. fetchRelationships() {
  895. if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) {
  896. return;
  897. }
  898. axios.get('/api/pixelfed/v1/accounts/relationships', {
  899. params: {
  900. 'id[]': this.profileId
  901. }
  902. }).then(res => {
  903. if(res.data.length) {
  904. this.relationship = res.data[0];
  905. if(res.data[0].blocking == true) {
  906. this.warning = true;
  907. }
  908. }
  909. });
  910. },
  911. muteProfile(status = null) {
  912. if($('body').hasClass('loggedIn') == false) {
  913. return;
  914. }
  915. let id = this.profileId;
  916. axios.post('/i/mute', {
  917. type: 'user',
  918. item: id
  919. }).then(res => {
  920. this.fetchRelationships();
  921. this.$refs.visitorContextMenu.hide();
  922. swal('Success', 'You have successfully muted ' + this.profile.acct, 'success');
  923. }).catch(err => {
  924. swal('Error', 'Something went wrong. Please try again later.', 'error');
  925. });
  926. },
  927. unmuteProfile(status = null) {
  928. if($('body').hasClass('loggedIn') == false) {
  929. return;
  930. }
  931. let id = this.profileId;
  932. axios.post('/i/unmute', {
  933. type: 'user',
  934. item: id
  935. }).then(res => {
  936. this.fetchRelationships();
  937. this.$refs.visitorContextMenu.hide();
  938. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  939. }).catch(err => {
  940. swal('Error', 'Something went wrong. Please try again later.', 'error');
  941. });
  942. },
  943. blockProfile(status = null) {
  944. if($('body').hasClass('loggedIn') == false) {
  945. return;
  946. }
  947. let id = this.profileId;
  948. axios.post('/i/block', {
  949. type: 'user',
  950. item: id
  951. }).then(res => {
  952. this.warning = true;
  953. this.fetchRelationships();
  954. this.$refs.visitorContextMenu.hide();
  955. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  956. }).catch(err => {
  957. swal('Error', 'Something went wrong. Please try again later.', 'error');
  958. });
  959. },
  960. unblockProfile(status = null) {
  961. if($('body').hasClass('loggedIn') == false) {
  962. return;
  963. }
  964. let id = this.profileId;
  965. axios.post('/i/unblock', {
  966. type: 'user',
  967. item: id
  968. }).then(res => {
  969. this.fetchRelationships();
  970. this.$refs.visitorContextMenu.hide();
  971. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  972. }).catch(err => {
  973. swal('Error', 'Something went wrong. Please try again later.', 'error');
  974. });
  975. },
  976. deletePost(status, index) {
  977. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  978. return;
  979. }
  980. axios.post('/i/delete', {
  981. type: 'status',
  982. item: status.id
  983. }).then(res => {
  984. this.timeline.splice(index,1);
  985. swal('Success', 'You have successfully deleted this post', 'success');
  986. }).catch(err => {
  987. swal('Error', 'Something went wrong. Please try again later.', 'error');
  988. });
  989. },
  990. followProfile() {
  991. if($('body').hasClass('loggedIn') == false) {
  992. return;
  993. }
  994. axios.post('/i/follow', {
  995. item: this.profileId
  996. }).then(res => {
  997. this.$refs.visitorContextMenu.hide();
  998. if(this.relationship.following) {
  999. this.profile.followers_count--;
  1000. if(this.profile.locked == true) {
  1001. window.location.href = '/';
  1002. }
  1003. } else {
  1004. this.profile.followers_count++;
  1005. }
  1006. this.relationship.following = !this.relationship.following;
  1007. }).catch(err => {
  1008. if(err.response.data.message) {
  1009. swal('Error', err.response.data.message, 'error');
  1010. }
  1011. });
  1012. },
  1013. followingModal() {
  1014. if($('body').hasClass('loggedIn') == false) {
  1015. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1016. return;
  1017. }
  1018. if(this.profileSettings.following.list == false) {
  1019. return;
  1020. }
  1021. if(this.followingCursor > 1) {
  1022. this.$refs.followingModal.show();
  1023. return;
  1024. } else {
  1025. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/following', {
  1026. params: {
  1027. page: this.followingCursor
  1028. }
  1029. })
  1030. .then(res => {
  1031. this.following = res.data;
  1032. this.followingModalSearchCache = res.data;
  1033. this.followingCursor++;
  1034. if(res.data.length < 10) {
  1035. this.followingMore = false;
  1036. }
  1037. });
  1038. this.$refs.followingModal.show();
  1039. return;
  1040. }
  1041. },
  1042. followersModal() {
  1043. if($('body').hasClass('loggedIn') == false) {
  1044. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1045. return;
  1046. }
  1047. if(this.profileSettings.followers.list == false) {
  1048. return;
  1049. }
  1050. if(this.followerCursor > 1) {
  1051. this.$refs.followerModal.show();
  1052. return;
  1053. } else {
  1054. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/followers', {
  1055. params: {
  1056. page: this.followerCursor
  1057. }
  1058. })
  1059. .then(res => {
  1060. this.followers.push(...res.data);
  1061. this.followerCursor++;
  1062. if(res.data.length < 10) {
  1063. this.followerMore = false;
  1064. }
  1065. })
  1066. this.$refs.followerModal.show();
  1067. return;
  1068. }
  1069. },
  1070. followingLoadMore() {
  1071. if($('body').hasClass('loggedIn') == false) {
  1072. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  1073. return;
  1074. }
  1075. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  1076. params: {
  1077. page: this.followingCursor,
  1078. fbu: this.followingModalSearch
  1079. }
  1080. })
  1081. .then(res => {
  1082. if(res.data.length > 0) {
  1083. this.following.push(...res.data);
  1084. this.followingCursor++;
  1085. this.followingModalSearchCache = this.following;
  1086. }
  1087. if(res.data.length < 10) {
  1088. this.followingModalSearchCache = this.following;
  1089. this.followingMore = false;
  1090. }
  1091. });
  1092. },
  1093. followersLoadMore() {
  1094. if($('body').hasClass('loggedIn') == false) {
  1095. return;
  1096. }
  1097. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  1098. params: {
  1099. page: this.followerCursor
  1100. }
  1101. })
  1102. .then(res => {
  1103. if(res.data.length > 0) {
  1104. this.followers.push(...res.data);
  1105. this.followerCursor++;
  1106. }
  1107. if(res.data.length < 10) {
  1108. this.followerMore = false;
  1109. }
  1110. });
  1111. },
  1112. visitorMenu() {
  1113. this.$refs.visitorContextMenu.show();
  1114. },
  1115. followModalAction(id, index, type = 'following') {
  1116. axios.post('/i/follow', {
  1117. item: id
  1118. }).then(res => {
  1119. if(type == 'following') {
  1120. this.following.splice(index, 1);
  1121. this.profile.following_count--;
  1122. }
  1123. }).catch(err => {
  1124. if(err.response.data.message) {
  1125. swal('Error', err.response.data.message, 'error');
  1126. }
  1127. });
  1128. },
  1129. momentBackground() {
  1130. let c = 'w-100 h-100 mt-n3 ';
  1131. if(this.profile.header_bg) {
  1132. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1133. } else {
  1134. c += 'bg-pixelfed';
  1135. }
  1136. return c;
  1137. },
  1138. loadSponsor() {
  1139. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1140. .then(res => {
  1141. this.sponsorList = res.data;
  1142. });
  1143. },
  1144. showSponsorModal() {
  1145. this.$refs.sponsorModal.show();
  1146. },
  1147. goBack() {
  1148. if(window.history.length > 2) {
  1149. window.history.back();
  1150. return;
  1151. } else {
  1152. window.location.href = '/';
  1153. return;
  1154. }
  1155. },
  1156. copyProfileLink() {
  1157. navigator.clipboard.writeText(window.location.href);
  1158. this.$refs.visitorContextMenu.hide();
  1159. },
  1160. formatCount(count) {
  1161. return App.util.format.count(count);
  1162. },
  1163. statusUrl(status) {
  1164. return status.url;
  1165. if(status.local == true) {
  1166. return status.url;
  1167. }
  1168. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1169. },
  1170. profileUrl(status) {
  1171. return status.url;
  1172. if(status.local == true) {
  1173. return status.account.url;
  1174. }
  1175. return '/i/web/profile/_/' + status.account.id;
  1176. },
  1177. showEmbedProfileModal() {
  1178. this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url);
  1179. this.$refs.visitorContextMenu.hide();
  1180. this.$refs.embedModal.show();
  1181. },
  1182. ctxCopyEmbed() {
  1183. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1184. this.$refs.embedModal.hide();
  1185. this.$refs.visitorContextMenu.hide();
  1186. },
  1187. storyRedirect() {
  1188. window.location.href = '/stories/' + this.profileUsername;
  1189. },
  1190. followingModalSearchHandler() {
  1191. let self = this;
  1192. let q = this.followingModalSearch;
  1193. if(q.length == 0) {
  1194. this.following = this.followingModalSearchCache;
  1195. this.followingModalSearch = null;
  1196. }
  1197. if(q.length > 0) {
  1198. let url = '/api/pixelfed/v1/accounts/' +
  1199. self.profileId + '/following?page=1&fbu=' +
  1200. q;
  1201. axios.get(url).then(res => {
  1202. this.following = res.data;
  1203. }).catch(err => {
  1204. self.following = self.followingModalSearchCache;
  1205. self.followingModalSearch = null;
  1206. });
  1207. }
  1208. },
  1209. truncate(str, len) {
  1210. return _.truncate(str, {
  1211. length: len
  1212. });
  1213. }
  1214. }
  1215. }
  1216. </script>