Profile.vue 45 KB

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