1
0

Profile.vue 44 KB

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