Profile.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449
  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" @click.prevent="remoteRedirect(profile.website)">{{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)" v-once>
  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. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1033. });
  1034. },
  1035. unmuteProfile(status = null) {
  1036. if($('body').hasClass('loggedIn') == false) {
  1037. return;
  1038. }
  1039. let id = this.profileId;
  1040. axios.post('/i/unmute', {
  1041. type: 'user',
  1042. item: id
  1043. }).then(res => {
  1044. this.fetchRelationships();
  1045. this.$refs.visitorContextMenu.hide();
  1046. swal('Success', 'You have successfully unmuted ' + this.profile.acct, 'success');
  1047. }).catch(err => {
  1048. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1049. });
  1050. },
  1051. blockProfile(status = null) {
  1052. if($('body').hasClass('loggedIn') == false) {
  1053. return;
  1054. }
  1055. let id = this.profileId;
  1056. axios.post('/i/block', {
  1057. type: 'user',
  1058. item: id
  1059. }).then(res => {
  1060. this.warning = true;
  1061. this.fetchRelationships();
  1062. this.$refs.visitorContextMenu.hide();
  1063. swal('Success', 'You have successfully blocked ' + this.profile.acct, 'success');
  1064. }).catch(err => {
  1065. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1066. });
  1067. },
  1068. unblockProfile(status = null) {
  1069. if($('body').hasClass('loggedIn') == false) {
  1070. return;
  1071. }
  1072. let id = this.profileId;
  1073. axios.post('/i/unblock', {
  1074. type: 'user',
  1075. item: id
  1076. }).then(res => {
  1077. this.fetchRelationships();
  1078. this.$refs.visitorContextMenu.hide();
  1079. swal('Success', 'You have successfully unblocked ' + this.profile.acct, 'success');
  1080. }).catch(err => {
  1081. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1082. });
  1083. },
  1084. deletePost(status, index) {
  1085. if($('body').hasClass('loggedIn') == false || status.account.id !== this.profile.id) {
  1086. return;
  1087. }
  1088. axios.post('/i/delete', {
  1089. type: 'status',
  1090. item: status.id
  1091. }).then(res => {
  1092. this.timeline.splice(index,1);
  1093. swal('Success', 'You have successfully deleted this post', 'success');
  1094. }).catch(err => {
  1095. swal('Error', 'Something went wrong. Please try again later.', 'error');
  1096. });
  1097. },
  1098. followProfile() {
  1099. if($('body').hasClass('loggedIn') == false) {
  1100. return;
  1101. }
  1102. axios.post('/i/follow', {
  1103. item: this.profileId
  1104. }).then(res => {
  1105. this.$refs.visitorContextMenu.hide();
  1106. if(this.relationship.following) {
  1107. this.profile.followers_count--;
  1108. if(this.profile.locked == true) {
  1109. window.location.href = '/';
  1110. }
  1111. } else {
  1112. this.profile.followers_count++;
  1113. }
  1114. this.relationship.following = !this.relationship.following;
  1115. }).catch(err => {
  1116. if(err.response.data.message) {
  1117. swal('Error', err.response.data.message, 'error');
  1118. }
  1119. });
  1120. },
  1121. followingModal() {
  1122. if($('body').hasClass('loggedIn') == false) {
  1123. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1124. return;
  1125. }
  1126. if(this.profileSettings.following.list == false) {
  1127. return;
  1128. }
  1129. if(this.followingCursor > 1) {
  1130. this.$refs.followingModal.show();
  1131. return;
  1132. } else {
  1133. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/following', {
  1134. params: {
  1135. page: this.followingCursor
  1136. }
  1137. })
  1138. .then(res => {
  1139. this.following = res.data;
  1140. this.followingModalSearchCache = res.data;
  1141. this.followingCursor++;
  1142. if(res.data.length < 10) {
  1143. this.followingMore = false;
  1144. }
  1145. this.followingLoading = false;
  1146. });
  1147. this.$refs.followingModal.show();
  1148. return;
  1149. }
  1150. },
  1151. followersModal() {
  1152. if($('body').hasClass('loggedIn') == false) {
  1153. window.location.href = encodeURI('/login?next=/' + this.profileUsername + '/');
  1154. return;
  1155. }
  1156. if(this.profileSettings.followers.list == false) {
  1157. return;
  1158. }
  1159. if(this.followerCursor > 1) {
  1160. this.$refs.followerModal.show();
  1161. return;
  1162. } else {
  1163. axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/followers', {
  1164. params: {
  1165. page: this.followerCursor
  1166. }
  1167. })
  1168. .then(res => {
  1169. this.followers.push(...res.data);
  1170. this.followerCursor++;
  1171. if(res.data.length < 10) {
  1172. this.followerMore = false;
  1173. }
  1174. this.followerLoading = false;
  1175. })
  1176. this.$refs.followerModal.show();
  1177. return;
  1178. }
  1179. },
  1180. followingLoadMore() {
  1181. if($('body').hasClass('loggedIn') == false) {
  1182. window.location.href = encodeURI('/login?next=/' + this.profile.username + '/');
  1183. return;
  1184. }
  1185. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', {
  1186. params: {
  1187. page: this.followingCursor,
  1188. fbu: this.followingModalSearch
  1189. }
  1190. })
  1191. .then(res => {
  1192. if(res.data.length > 0) {
  1193. this.following.push(...res.data);
  1194. this.followingCursor++;
  1195. this.followingModalSearchCache = this.following;
  1196. }
  1197. if(res.data.length < 10) {
  1198. this.followingModalSearchCache = this.following;
  1199. this.followingMore = false;
  1200. }
  1201. });
  1202. },
  1203. followersLoadMore() {
  1204. if($('body').hasClass('loggedIn') == false) {
  1205. return;
  1206. }
  1207. axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', {
  1208. params: {
  1209. page: this.followerCursor
  1210. }
  1211. })
  1212. .then(res => {
  1213. if(res.data.length > 0) {
  1214. this.followers.push(...res.data);
  1215. this.followerCursor++;
  1216. }
  1217. if(res.data.length < 10) {
  1218. this.followerMore = false;
  1219. }
  1220. });
  1221. },
  1222. visitorMenu() {
  1223. this.$refs.visitorContextMenu.show();
  1224. },
  1225. followModalAction(id, index, type = 'following') {
  1226. axios.post('/i/follow', {
  1227. item: id
  1228. }).then(res => {
  1229. if(type == 'following') {
  1230. this.following.splice(index, 1);
  1231. this.profile.following_count--;
  1232. }
  1233. }).catch(err => {
  1234. if(err.response.data.message) {
  1235. swal('Error', err.response.data.message, 'error');
  1236. }
  1237. });
  1238. },
  1239. momentBackground() {
  1240. let c = 'w-100 h-100 mt-n3 ';
  1241. if(this.profile.header_bg) {
  1242. c += this.profile.header_bg == 'default' ? 'bg-pixelfed' : 'bg-moment-' + this.profile.header_bg;
  1243. } else {
  1244. c += 'bg-pixelfed';
  1245. }
  1246. return c;
  1247. },
  1248. loadSponsor() {
  1249. axios.get('/api/local/profile/sponsor/' + this.profileId)
  1250. .then(res => {
  1251. this.sponsorList = res.data;
  1252. });
  1253. },
  1254. showSponsorModal() {
  1255. this.$refs.sponsorModal.show();
  1256. },
  1257. goBack() {
  1258. if(window.history.length > 2) {
  1259. window.history.back();
  1260. return;
  1261. } else {
  1262. window.location.href = '/';
  1263. return;
  1264. }
  1265. },
  1266. copyProfileLink() {
  1267. navigator.clipboard.writeText(window.location.href);
  1268. this.$refs.visitorContextMenu.hide();
  1269. },
  1270. formatCount(count) {
  1271. return App.util.format.count(count);
  1272. },
  1273. statusUrl(status) {
  1274. return status.url;
  1275. if(status.local == true) {
  1276. return status.url;
  1277. }
  1278. return '/i/web/post/_/' + status.account.id + '/' + status.id;
  1279. },
  1280. profileUrl(status) {
  1281. return status.url;
  1282. if(status.local == true) {
  1283. return status.account.url;
  1284. }
  1285. return '/i/web/profile/_/' + status.account.id;
  1286. },
  1287. profileUrlRedirect(profile) {
  1288. if(profile.local == true) {
  1289. return profile.url;
  1290. }
  1291. return '/i/web/profile/_/' + profile.id;
  1292. },
  1293. showEmbedProfileModal() {
  1294. this.ctxEmbedPayload = window.App.util.embed.profile(this.profile.url);
  1295. this.$refs.visitorContextMenu.hide();
  1296. this.$refs.embedModal.show();
  1297. },
  1298. ctxCopyEmbed() {
  1299. navigator.clipboard.writeText(this.ctxEmbedPayload);
  1300. this.$refs.embedModal.hide();
  1301. this.$refs.visitorContextMenu.hide();
  1302. },
  1303. storyRedirect() {
  1304. window.location.href = '/stories/' + this.profileUsername + '?t=4';
  1305. },
  1306. followingModalSearchHandler() {
  1307. let self = this;
  1308. let q = this.followingModalSearch;
  1309. if(q.length == 0) {
  1310. this.following = this.followingModalSearchCache;
  1311. this.followingModalSearch = null;
  1312. }
  1313. if(q.length > 0) {
  1314. let url = '/api/pixelfed/v1/accounts/' +
  1315. self.profileId + '/following?page=1&fbu=' +
  1316. q;
  1317. axios.get(url).then(res => {
  1318. this.following = res.data;
  1319. }).catch(err => {
  1320. self.following = self.followingModalSearchCache;
  1321. self.followingModalSearch = null;
  1322. });
  1323. }
  1324. },
  1325. truncate(str, len) {
  1326. return _.truncate(str, {
  1327. length: len
  1328. });
  1329. },
  1330. formatWebsite(site) {
  1331. if(site.slice(0, 8) === 'https://') {
  1332. site = site.substr(8);
  1333. } else if(site.slice(0, 7) === 'http://') {
  1334. site = site.substr(7);
  1335. } else {
  1336. this.profile.website = null;
  1337. return;
  1338. }
  1339. return this.truncate(site, 60);
  1340. },
  1341. joinedAtFormat(created) {
  1342. let d = new Date(created);
  1343. return d.toDateString();
  1344. },
  1345. archivesInfiniteLoader($state) {
  1346. axios.get('/api/pixelfed/v2/statuses/archives', {
  1347. params: {
  1348. page: this.archivesPage
  1349. }
  1350. }).then(res => {
  1351. if(res.data.length) {
  1352. this.archives.push(...res.data);
  1353. this.archivesPage++;
  1354. $state.loaded();
  1355. } else {
  1356. $state.complete();
  1357. }
  1358. });
  1359. }
  1360. }
  1361. }
  1362. </script>