Profile.vue 45 KB

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