Profile.vue 46 KB

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