Profile.vue 42 KB

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