Profile.vue 48 KB

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