Profile.vue 45 KB

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