Profile.vue 45 KB

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