Profile.vue 44 KB

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