Profile.vue 45 KB

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