1
0

Profile.vue 46 KB

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