Profile.vue 44 KB

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