diff --git a/app/Http/Controllers/FollowerController.php b/app/Http/Controllers/FollowerController.php index fae861b88..808effa10 100644 --- a/app/Http/Controllers/FollowerController.php +++ b/app/Http/Controllers/FollowerController.php @@ -26,6 +26,11 @@ class FollowerController extends Controller ]); $item = $request->input('item'); $this->handleFollowRequest($item); + if($request->wantsJson()) { + return response()->json([ + 200 + ], 200); + } return redirect()->back(); } diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 708543647..c07c3a5dd 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -136,34 +136,31 @@ class InternalApiController extends Controller }); $following = array_merge($following, $filters); - $people = Cache::remember('feature:discover:people:'.$pid, 15, function() use ($following) { - return Profile::select('id', 'name', 'username') + $people = Profile::select('id', 'name', 'username') ->with('avatar') - ->inRandomOrder() + ->orderByRaw('rand()') ->whereHas('statuses') ->whereNull('domain') ->whereNotIn('id', $following) ->whereIsPrivate(false) ->take(3) ->get(); - }); - $posts = Cache::remember('feature:discover:posts:'.$pid, 60, function() use ($following) { - return Status::select('id', 'caption', 'profile_id') + $posts = Status::select('id', 'caption', 'profile_id') ->whereNull('in_reply_to_id') ->whereNull('reblog_of_id') ->whereIsNsfw(false) ->whereVisibility('public') ->whereNotIn('profile_id', $following) - ->withCount(['comments', 'likes']) + ->with('media') ->orderBy('created_at', 'desc') ->take(21) ->get(); - }); $res = [ 'people' => $people->map(function($profile) { return [ + 'id' => $profile->id, 'avatar' => $profile->avatarUrl(), 'name' => $profile->name, 'username' => $profile->username, @@ -174,8 +171,6 @@ class InternalApiController extends Controller return [ 'url' => $post->url(), 'thumb' => $post->thumb(), - 'comments_count' => $post->comments_count, - 'likes_count' => $post->likes_count, ]; }) ]; diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index ff9a92eee..233316540 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -37,7 +37,7 @@ class ProfileController extends Controller $settings->show_profile_follower_count = true; $settings->show_profile_following_count = true; } else { - $settings = User::whereUsername($username)->firstOrFail()->settings; + $settings = $user->user->settings; } if ($request->wantsJson() && config('pixelfed.activitypub_enabled')) { @@ -101,7 +101,6 @@ class ProfileController extends Controller } return false; - } protected function blockedProfileCheck(Profile $profile) @@ -145,6 +144,7 @@ class ProfileController extends Controller public function followers(Request $request, $username) { $profile = $user = Profile::whereUsername($username)->firstOrFail(); + // TODO: fix $profile/$user mismatch in profile & follower templates $owner = Auth::check() && Auth::id() === $user->user_id; $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; @@ -161,7 +161,10 @@ class ProfileController extends Controller $settings = new \StdClass; $settings->crawlable = false; } else { - $settings = User::whereUsername($username)->firstOrFail()->settings; + $settings = $profile->user->settings; + if(!$settings->show_profile_follower_count && !$owner) { + abort(403); + } } return view('profile.followers', compact('user', 'profile', 'followers', 'owner', 'is_following', 'is_admin', 'settings')); } @@ -185,7 +188,10 @@ class ProfileController extends Controller $settings = new \StdClass; $settings->crawlable = false; } else { - $settings = User::whereUsername($username)->firstOrFail()->settings; + $settings = $profile->user->settings; + if(!$settings->show_profile_follower_count && !$owner) { + abort(403); + } } return view('profile.following', compact('user', 'profile', 'following', 'owner', 'is_following', 'is_admin', 'settings')); } diff --git a/app/Jobs/FollowPipeline/FollowPipeline.php b/app/Jobs/FollowPipeline/FollowPipeline.php index 54489cc29..8e3bc2ed9 100644 --- a/app/Jobs/FollowPipeline/FollowPipeline.php +++ b/app/Jobs/FollowPipeline/FollowPipeline.php @@ -51,7 +51,7 @@ class FollowPipeline implements ShouldQueue $notification->save(); Cache::forever('notification.'.$notification->id, $notification); - + Cache::forget('feature:discover:people:'.$actor->id); $redis = Redis::connection(); $nkey = config('cache.prefix').':user.'.$target->id.'.notifications'; diff --git a/app/Listeners/AuthLogin.php b/app/Listeners/AuthLogin.php index f587c66a7..79e9c5eab 100644 --- a/app/Listeners/AuthLogin.php +++ b/app/Listeners/AuthLogin.php @@ -2,24 +2,18 @@ namespace App\Listeners; -use DB; -use App\User; -use App\UserSetting; +use DB, Cache; +use App\{ + Follower, + User, + UserFilter, + UserSetting +}; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; class AuthLogin { - /** - * Create the event listener. - * - * @return void - */ - public function __construct() - { - // - } - /** * Handle the event. * @@ -36,5 +30,22 @@ class AuthLogin ]); }); } + $this->warmCache($user); + } + + public function warmCache($user) + { + $pid = $user->profile->id; + + Cache::remember('feature:discover:following:'.$pid, 10080, function() use ($pid) { + return Follower::whereProfileId($pid)->pluck('following_id')->toArray(); + }); + + Cache::remember("user:filter:list:$pid", 10080, function() use($pid) { + return UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id')->toArray(); + }); } } diff --git a/public/js/components.js b/public/js/components.js index 457af0ff0..83390dd02 100644 --- a/public/js/components.js +++ b/public/js/components.js @@ -1 +1 @@ -!function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/",n(n.s=2)}({"/7en":function(t,e,n){var i,r;"undefined"!=typeof window&&window,void 0===(r="function"==typeof(i=function(){"use strict";function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var n=this._events=this._events||{},i=n[t]=n[t]||[];return-1==i.indexOf(e)&&i.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var n=this._onceEvents=this._onceEvents||{};return(n[t]=n[t]||{})[e]=!0,this}},e.off=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){var i=n.indexOf(e);return-1!=i&&n.splice(i,1),this}},e.emitEvent=function(t,e){var n=this._events&&this._events[t];if(n&&n.length){n=n.slice(0),e=e||[];for(var i=this._onceEvents&&this._onceEvents[t],r=0;r1&&($(".section-people .lds-ring").hide(),$(".section-people .row.d-none").removeClass("d-none")),t.posts.length>1&&($(".section-explore .lds-ring").hide(),$(".section-explore .row.d-none").removeClass("d-none"))})}}}},"1/oy":function(t,e,n){var i=n("eAYY");"string"==typeof i&&(i=[[t.i,i,""]]);var r={transform:void 0};n("MTIv")(i,r);i.locals&&(t.exports=i.locals)},"162o":function(t,e,n){(function(t){var i=void 0!==t&&t||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(r.call(setTimeout,i,arguments),clearTimeout)},e.setInterval=function(){return new o(r.call(setInterval,i,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(i,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n("mypn"),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(e,n("DuR2"))},"1MO9":function(t,e,n){(t.exports=n("FZ+f")(!1)).push([t.i,"input.form-control[type=color],input.form-control[type=range]{height:2.25rem}input.form-control.form-control-sm[type=color],input.form-control.form-control-sm[type=range]{height:1.9375rem}input.form-control.form-control-lg[type=color],input.form-control.form-control-lg[type=range]{height:3rem}input.form-control[type=color]{padding:.25rem}input.form-control.form-control-sm[type=color]{padding:.125rem}",""])},"1zu+":function(t,e,n){(t.exports=n("FZ+f")(!1)).push([t.i,"",""])},2:function(t,e,n){t.exports=n("Tkmu")},"20cu":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={data:function(){return{tokens:[]}},ready:function(){this.prepareComponent()},mounted:function(){this.prepareComponent()},methods:{prepareComponent:function(){this.getTokens()},getTokens:function(){var t=this;axios.get("/oauth/tokens").then(function(e){t.tokens=e.data})},revoke:function(t){var e=this;axios.delete("/oauth/tokens/"+t.id).then(function(t){e.getTokens()})}}}},"3G5u":function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",[n("div",[n("div",{staticClass:"card card-default mb-4"},[n("div",{staticClass:"card-header font-weight-bold bg-white"},[n("div",{staticStyle:{display:"flex","justify-content":"space-between","align-items":"center"}},[n("span",[t._v("\n Personal Access Tokens\n ")]),t._v(" "),n("a",{staticClass:"action-link",attrs:{tabindex:"-1"},on:{click:t.showCreateTokenForm}},[t._v("\n Create New Token\n ")])])]),t._v(" "),n("div",{staticClass:"card-body"},[0===t.tokens.length?n("p",{staticClass:"mb-0"},[t._v("\n You have not created any personal access tokens.\n ")]):t._e(),t._v(" "),t.tokens.length>0?n("table",{staticClass:"table table-borderless mb-0"},[t._m(0),t._v(" "),n("tbody",t._l(t.tokens,function(e){return n("tr",[n("td",{staticStyle:{"vertical-align":"middle"}},[t._v("\n "+t._s(e.name)+"\n ")]),t._v(" "),n("td",{staticStyle:{"vertical-align":"middle"}},[n("a",{staticClass:"action-link text-danger",on:{click:function(n){t.revoke(e)}}},[t._v("\n Delete\n ")])])])}))]):t._e()])])]),t._v(" "),n("div",{staticClass:"modal fade",attrs:{id:"modal-create-token",tabindex:"-1",role:"dialog"}},[n("div",{staticClass:"modal-dialog"},[n("div",{staticClass:"modal-content"},[t._m(1),t._v(" "),n("div",{staticClass:"modal-body"},[t.form.errors.length>0?n("div",{staticClass:"alert alert-danger"},[t._m(2),t._v(" "),n("br"),t._v(" "),n("ul",t._l(t.form.errors,function(e){return n("li",[t._v("\n "+t._s(e)+"\n ")])}))]):t._e(),t._v(" "),n("form",{attrs:{role:"form"},on:{submit:function(e){return e.preventDefault(),t.store(e)}}},[n("div",{staticClass:"form-group row"},[n("label",{staticClass:"col-md-4 col-form-label"},[t._v("Name")]),t._v(" "),n("div",{staticClass:"col-md-6"},[n("input",{directives:[{name:"model",rawName:"v-model",value:t.form.name,expression:"form.name"}],staticClass:"form-control",attrs:{id:"create-token-name",type:"text",name:"name",autocomplete:"off"},domProps:{value:t.form.name},on:{input:function(e){e.target.composing||t.$set(t.form,"name",e.target.value)}}})])]),t._v(" "),t.scopes.length>0?n("div",{staticClass:"form-group row"},[n("label",{staticClass:"col-md-4 col-form-label"},[t._v("Scopes")]),t._v(" "),n("div",{staticClass:"col-md-6"},t._l(t.scopes,function(e){return n("div",[n("div",{staticClass:"checkbox"},[n("label",[n("input",{attrs:{type:"checkbox"},domProps:{checked:t.scopeIsAssigned(e.id)},on:{click:function(n){t.toggleScope(e.id)}}}),t._v("\n\n "+t._s(e.id)+"\n ")])])])}))]):t._e()])]),t._v(" "),n("div",{staticClass:"modal-footer"},[n("button",{staticClass:"btn btn-secondary font-weight-bold",attrs:{type:"button","data-dismiss":"modal"}},[t._v("Close")]),t._v(" "),n("button",{staticClass:"btn btn-primary font-weight-bold",attrs:{type:"button"},on:{click:t.store}},[t._v("\n Create\n ")])])])])]),t._v(" "),n("div",{staticClass:"modal fade",attrs:{id:"modal-access-token",tabindex:"-1",role:"dialog"}},[n("div",{staticClass:"modal-dialog"},[n("div",{staticClass:"modal-content"},[t._m(3),t._v(" "),n("div",{staticClass:"modal-body"},[n("p",[t._v("\n Here is your new personal access token. This is the only time it will be shown so don't lose it!\n You may now use this token to make API requests.\n ")]),t._v(" "),n("textarea",{staticClass:"form-control",attrs:{rows:"10"}},[t._v(t._s(t.accessToken))])]),t._v(" "),t._m(4)])])])])},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("thead",[e("tr",[e("th",[this._v("Name")]),this._v(" "),e("th")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"modal-header"},[e("h4",{staticClass:"modal-title"},[this._v("\n Create Token\n ")]),this._v(" "),e("button",{staticClass:"close",attrs:{type:"button","data-dismiss":"modal","aria-hidden":"true"}},[this._v("×")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("p",{staticClass:"mb-0"},[e("strong",[this._v("Whoops!")]),this._v(" Something went wrong!")])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"modal-header"},[e("h4",{staticClass:"modal-title"},[this._v("\n Personal Access Token\n ")]),this._v(" "),e("button",{staticClass:"close",attrs:{type:"button","data-dismiss":"modal","aria-hidden":"true"}},[this._v("×")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"modal-footer"},[e("button",{staticClass:"btn btn-secondary",attrs:{type:"button","data-dismiss":"modal"}},[this._v("Close")])])}]}},"3H+/":function(t,e,n){var i,r;!function(o,a){i=[n("/7en"),n("h803")],void 0===(r=function(t,e){return a(o,t,e)}.apply(e,i))||(t.exports=r)}(window,function(t,e,n){var i=t.jQuery,r={};function o(t,e){var a=n.getQueryElement(t);if(a){if((t=a).infiniteScrollGUID){var s=r[t.infiniteScrollGUID];return s.option(e),s}this.element=t,this.options=n.extend({},o.defaults),this.option(e),i&&(this.$element=i(this.element)),this.create()}else console.error("Bad element for InfiniteScroll: "+(a||t))}o.defaults={},o.create={},o.destroy={};var a=o.prototype;n.extend(a,e.prototype);var s=0;a.create=function(){var t=this.guid=++s;if(this.element.infiniteScrollGUID=t,r[t]=this,this.pageIndex=1,this.loadCount=0,this.updateGetPath(),this.getPath&&this.getPath())for(var e in this.updateGetAbsolutePath(),this.log("initialized",[this.element.className]),this.callOnInit(),o.create)o.create[e].call(this);else console.error("Disabling InfiniteScroll")},a.option=function(t){n.extend(this.options,t)},a.callOnInit=function(){var t=this.options.onInit;t&&t.call(this,this)},a.dispatchEvent=function(t,e,n){this.log(t,n);var r=e?[e].concat(n):n;if(this.emitEvent(t,r),i&&this.$element){var o=t+=".infiniteScroll";if(e){var a=i.Event(e);a.type=t,o=a}this.$element.trigger(o,n)}};var l={initialized:function(t){return"on "+t},request:function(t){return"URL: "+t},load:function(t,e){return(t.title||"")+". URL: "+e},error:function(t,e){return t+". URL: "+e},append:function(t,e,n){return n.length+" items. URL: "+e},last:function(t,e){return"URL: "+e},history:function(t,e){return"URL: "+e},pageIndex:function(t,e){return"current page determined to be: "+t+" from "+e}};a.log=function(t,e){if(this.options.debug){var n="[InfiniteScroll] "+t,i=l[t];i&&(n+=". "+i.apply(this,e)),console.log(n)}},a.updateMeasurements=function(){this.windowHeight=t.innerHeight;var e=this.element.getBoundingClientRect();this.top=e.top+t.pageYOffset},a.updateScroller=function(){var e=this.options.elementScroll;if(e){if(this.scroller=!0===e?this.element:n.getQueryElement(e),!this.scroller)throw"Unable to find elementScroll: "+e}else this.scroller=t},a.updateGetPath=function(){var t=this.options.path;if(t){var e=typeof t;if("function"!=e)"string"==e&&t.match("{{#}}")?this.updateGetPathTemplate(t):this.updateGetPathSelector(t);else this.getPath=t}else console.error("InfiniteScroll path option required. Set as: "+t)},a.updateGetPathTemplate=function(t){this.getPath=function(){var e=this.pageIndex+1;return t.replace("{{#}}",e)}.bind(this);var e=t.replace("{{#}}","(\\d\\d?\\d?)"),n=new RegExp(e),i=location.href.match(n);i&&(this.pageIndex=parseInt(i[1],10),this.log("pageIndex",[this.pageIndex,"template string"]))};var c=[/^(.*?\/?page\/?)(\d\d?\d?)(.*?$)/,/^(.*?\/?\?page=)(\d\d?\d?)(.*?$)/,/(.*?)(\d\d?\d?)(?!.*\d)(.*?$)/];return a.updateGetPathSelector=function(t){var e=document.querySelector(t);if(e){for(var n,i,r=e.getAttribute("href"),o=0;r&&o=0,this.isPrefilling?(this.log("prefill"),this.loadNextPage()):this.stopPrefill()},n.getPrefillDistance=function(){return this.options.elementScroll?this.scroller.clientHeight-this.scroller.scrollHeight:this.windowHeight-this.element.clientHeight},n.stopPrefill=function(){this.log("stopPrefill"),this.off("append",this.prefill)},e})},"99Qu":function(t,e,n){var i,r;!function(o,a){i=[n("3H+/"),n("h803")],void 0===(r=function(t,e){return a(o,t,e)}.apply(e,i))||(t.exports=r)}(window,function(t,e,n){var i=e.prototype;return e.defaults.scrollThreshold=400,e.create.scrollWatch=function(){this.pageScrollHandler=this.onPageScroll.bind(this),this.resizeHandler=this.onResize.bind(this);var t=this.options.scrollThreshold;(t||0===t)&&this.enableScrollWatch()},e.destroy.scrollWatch=function(){this.disableScrollWatch()},i.enableScrollWatch=function(){this.isScrollWatching||(this.isScrollWatching=!0,this.updateMeasurements(),this.updateScroller(),this.on("last",this.disableScrollWatch),this.bindScrollWatchEvents(!0))},i.disableScrollWatch=function(){this.isScrollWatching&&(this.bindScrollWatchEvents(!1),delete this.isScrollWatching)},i.bindScrollWatchEvents=function(e){var n=e?"addEventListener":"removeEventListener";this.scroller[n]("scroll",this.pageScrollHandler),t[n]("resize",this.resizeHandler)},i.onPageScroll=e.throttle(function(){this.getBottomDistance()<=this.options.scrollThreshold&&this.dispatchEvent("scrollThreshold")}),i.getBottomDistance=function(){return this.options.elementScroll?this.getElementBottomDistance():this.getWindowBottomDistance()},i.getWindowBottomDistance=function(){return this.top+this.element.clientHeight-(t.pageYOffset+this.windowHeight)},i.getElementBottomDistance=function(){return this.scroller.scrollHeight-(this.scroller.scrollTop+this.scroller.clientHeight)},i.onResize=function(){this.updateMeasurements()},n.debounceMethod(e,"onResize",150),e})},"A/e+":function(t,e,n){var i=n("VU/8")(n("5m3O"),n("ITff"),!1,function(t){n("SZtu")},"data-v-6c5fc404",null);t.exports=i.exports},AHQe:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"postComponent"},[n("div",{staticClass:"container px-0 mt-md-4"},[n("div",{staticClass:"card card-md-rounded-0 status-container orientation-unknown"},[n("div",{staticClass:"row mx-0"},[n("div",{staticClass:"d-flex d-md-none align-items-center justify-content-between card-header bg-white w-100"},[n("a",{staticClass:"d-flex align-items-center status-username text-truncate",attrs:{href:t.statusProfileUrl,"data-toggle":"tooltip","data-placement":"bottom",title:t.statusUsername}},[n("div",{staticClass:"status-avatar mr-2"},[n("img",{staticStyle:{"border-radius":"12px"},attrs:{src:t.statusAvatar,width:"24px",height:"24px"}})]),t._v(" "),n("div",{staticClass:"username"},[n("span",{staticClass:"username-link font-weight-bold text-dark"},[t._v(t._s(t.statusUsername))])])]),t._v(" "),n("div",{staticClass:"float-right"},[n("div",{staticClass:"post-actions d-none"},[n("div",{staticClass:"dropdown"},[t._m(0),t._v(" "),n("div",{staticClass:"dropdown-menu dropdown-menu-right",attrs:{"aria-labelledby":"dropdownMenuButton"}},[n("a",{staticClass:"dropdown-item font-weight-bold",attrs:{href:t.reportUrl()}},[t._v("Report")]),t._v(" "),n("div",{staticClass:"dropdown-divider"}),t._v(" "),t._m(1),t._v(" "),t._m(2)])])])])]),t._v(" "),t._m(3),t._v(" "),n("div",{staticClass:"col-12 col-md-4 px-0 d-flex flex-column border-left border-md-left-0"},[n("div",{staticClass:"d-md-flex d-none align-items-center justify-content-between card-header py-3 bg-white"},[n("a",{staticClass:"d-flex align-items-center status-username text-truncate",attrs:{href:t.statusProfileUrl,"data-toggle":"tooltip","data-placement":"bottom",title:t.statusUsername}},[n("div",{staticClass:"status-avatar mr-2"},[n("img",{staticStyle:{"border-radius":"12px"},attrs:{src:t.statusAvatar,width:"24px",height:"24px"}})]),t._v(" "),n("div",{staticClass:"username"},[n("span",{staticClass:"username-link font-weight-bold text-dark"},[t._v(t._s(t.statusUsername))])])]),t._v(" "),n("div",{staticClass:"float-right"},[n("div",{staticClass:"post-actions d-none"},[n("div",{staticClass:"dropdown"},[t._m(4),t._v(" "),n("div",{staticClass:"dropdown-menu dropdown-menu-right",attrs:{"aria-labelledby":"dropdownMenuButton"}},[n("a",{staticClass:"dropdown-item font-weight-bold",attrs:{href:t.reportUrl()}},[t._v("Report")]),t._v(" "),n("div",{staticClass:"dropdown-divider"}),t._v(" "),t._m(5),t._v(" "),t._m(6)])])])])]),t._v(" "),n("div",{staticClass:"d-flex flex-md-column flex-column-reverse h-100"},[n("div",{staticClass:"card-body status-comments"},[n("div",{staticClass:"status-comment"},[n("p",{staticClass:"mb-1 read-more",staticStyle:{overflow:"hidden"}},[n("span",{staticClass:"font-weight-bold pr-1"},[t._v(t._s(t.statusUsername))]),t._v(" "),n("span",{staticClass:"comment-text"})]),t._v(" "),n("post-comments",{attrs:{user:this.user,"post-id":t.statusId,"post-username":t.statusUsername}})],1)]),t._v(" "),n("div",{staticClass:"card-body flex-grow-0 py-1"},[n("div",{staticClass:"reactions my-1"},[n("form",{staticClass:"d-inline-flex pr-3 like-form",staticStyle:{display:"inline"},attrs:{method:"post",action:"/i/like","data-id":t.statusId,"data-action":"like"}},[n("input",{attrs:{type:"hidden",name:"_token",value:""}}),t._v(" "),n("input",{attrs:{type:"hidden",name:"item"},domProps:{value:t.statusId}}),t._v(" "),t._m(7)]),t._v(" "),n("h3",{staticClass:"far fa-comment pr-3 m-0",attrs:{title:"Comment"},on:{click:t.commentFocus}}),t._v(" "),n("form",{staticClass:"d-inline-flex share-form pr-3",staticStyle:{display:"inline"},attrs:{method:"post",action:"/i/share","data-id":"11todo","data-action":"share","data-count":"status.favourite_count"}},[n("input",{attrs:{type:"hidden",name:"_token",value:""}}),t._v(" "),n("input",{attrs:{type:"hidden",name:"item"},domProps:{value:t.statusId}}),t._v(" "),t._m(8)]),t._v(" "),n("span",{staticClass:"float-right"},[n("form",{staticClass:"d-inline-flex",staticStyle:{display:"inline"},attrs:{method:"post",action:"/i/bookmark","data-id":"#","data-action":"bookmark",onclick:"this.preventDefault()"}},[n("input",{attrs:{type:"hidden",name:"_token",value:""}}),t._v(" "),n("input",{attrs:{type:"hidden",name:"item"},domProps:{value:t.statusId}}),t._v(" "),t._m(9)])])]),t._v(" "),n("div",{staticClass:"likes font-weight-bold mb-0"},[n("span",{staticClass:"like-count"},[t._v(t._s(t.status.favourites_count||0))]),t._v(" likes\n ")]),t._v(" "),n("div",{staticClass:"timestamp"},[n("a",{staticClass:"small text-muted",attrs:{href:t.statusUrl}},[t._v("\n "+t._s(t.timestampFormat())+"\n ")])])])]),t._v(" "),n("div",{staticClass:"card-footer bg-white sticky-md-bottom"},[t._m(10),t._v(" "),n("form",{staticClass:"comment-form d-none",attrs:{method:"post",action:"/i/comment","data-id":t.statusId,"data-truncate":"false"}},[n("input",{attrs:{type:"hidden",name:"_token",value:""}}),t._v(" "),n("input",{attrs:{type:"hidden",name:"item"},domProps:{value:t.statusId}}),t._v(" "),n("input",{staticClass:"form-control",attrs:{name:"comment",placeholder:"Add a comment...",autocomplete:"off"}})])])])])])])])},staticRenderFns:[function(){var t=this.$createElement,e=this._self._c||t;return e("button",{staticClass:"btn btn-link text-dark no-caret dropdown-toggle",attrs:{type:"button","data-toggle":"dropdown","aria-haspopup":"true","aria-expanded":"false",title:"Post options"}},[e("span",{staticClass:"fas fa-ellipsis-v text-muted"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("form",{attrs:{method:"post",action:"/i/mute"}},[e("input",{attrs:{type:"hidden",name:"_token",value:""}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"type",value:"user"}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"item",value:""}}),this._v(" "),e("button",{staticClass:"dropdown-item btn btn-link font-weight-bold",attrs:{type:"submit"}},[this._v("Mute this user")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("form",{attrs:{method:"post",action:"/i/block"}},[e("input",{attrs:{type:"hidden",name:"_token",value:""}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"type",value:"user"}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"item",value:""}}),this._v(" "),e("button",{staticClass:"dropdown-item btn btn-link font-weight-bold",attrs:{type:"submit"}},[this._v("Block this user")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"col-12 col-md-8 status-photo px-0"},[e("div",{staticClass:"postPresenterLoader text-center"},[e("div",{staticClass:"lds-ring"},[e("div"),e("div"),e("div"),e("div")])]),this._v(" "),e("div",{staticClass:"postPresenterContainer d-none"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("button",{staticClass:"btn btn-link text-dark no-caret dropdown-toggle",attrs:{type:"button","data-toggle":"dropdown","aria-haspopup":"true","aria-expanded":"false",title:"Post options"}},[e("span",{staticClass:"fas fa-ellipsis-v text-muted"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("form",{attrs:{method:"post",action:"/i/mute"}},[e("input",{attrs:{type:"hidden",name:"_token",value:""}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"type",value:"user"}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"item",value:""}}),this._v(" "),e("button",{staticClass:"dropdown-item btn btn-link font-weight-bold",attrs:{type:"submit"}},[this._v("Mute this user")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("form",{attrs:{method:"post",action:"/i/block"}},[e("input",{attrs:{type:"hidden",name:"_token",value:""}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"type",value:"user"}}),this._v(" "),e("input",{attrs:{type:"hidden",name:"item",value:""}}),this._v(" "),e("button",{staticClass:"dropdown-item btn btn-link font-weight-bold",attrs:{type:"submit"}},[this._v("Block this user")])])},function(){var t=this.$createElement,e=this._self._c||t;return e("button",{staticClass:"btn btn-link text-dark p-0 border-0",attrs:{type:"submit",title:"Like!"}},[e("h3",{staticClass:"status-heart m-0 far fa-heart text-dark"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("button",{staticClass:"btn btn-link text-dark p-0",attrs:{type:"submit",title:"Share"}},[e("h3",{staticClass:"m-0 far fa-share-square"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("button",{staticClass:"btn btn-link text-dark p-0 border-0",attrs:{type:"submit",title:"Save"}},[e("h3",{staticClass:"m-0 far fa-bookmark"})])},function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"comment-form-guest"},[e("a",{attrs:{href:"/login"}},[this._v("Login")]),this._v(" to like or comment.\n ")])}]}},BXHd:function(t,e){$(document).ready(function(){$(document).on("submit",".bookmark-form",function(t){t.preventDefault();var e=$(this).data("id");axios.post("/i/bookmark",{item:e})})})},"Bx+d":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),pixelfed.postComponent={},pixelfed.presenter={show:{image:function(t,e){$(".status-container").removeClass("orientation-unknown").addClass("orientation-"+e[0].orientation);var n=$("
");n.addClass(e[0].filter_class);var i=$("");i.attr("src",e[0].url),i.attr("title",e[0].description),n.append(i),t.append(n)},video:function(t,e){var n=$("
");n.addClass("embed-responsive embed-responsive-4by3");var i=$("
@@ -36,16 +33,6 @@
-
-
- - {{post.likes_count}} - - - {{post.comments_count}} - -
-
@@ -53,7 +40,7 @@
-

To view more posts, check the home, local or federated timelines.

+

To view more posts, check the home or local timelines.

@@ -68,10 +55,26 @@ export default { } }, mounted() { - this.fetchData(); + this.slowTimeout(); + this.fetchData(); }, methods: { + followUser(id, event) { + axios.post('/i/follow', { + item: id + }).then(res => { + let el = $(event.target); + el.addClass('btn-outline-secondary').removeClass('btn-primary'); + el.text('Unfollow'); + }).catch(err => { + swal( + 'Whoops! Something went wrong...', + 'An error occured, please try again later.', + 'error' + ); + }); + }, fetchData() { axios.get('/api/v2/discover') .then((res) => { @@ -80,16 +83,23 @@ export default { this.posts = data.posts; if(this.people.length > 1) { - $('.section-people .lds-ring').hide(); + $('.section-people .loader').hide(); $('.section-people .row.d-none').removeClass('d-none'); } if(this.posts.length > 1) { - $('.section-explore .lds-ring').hide(); + $('.section-explore .loader').hide(); $('.section-explore .row.d-none').removeClass('d-none'); } }); - } + }, + slowTimeout() { + setTimeout(function() { + let el = $('

').addClass('font-weight-bold').text('This is taking longer than expected to load. Please try reloading the page if this does not load after 30 seconds.'); + $('.section-people .loader').append(el); + $('.section-explore .loader').append(el); + }, 5000); + } } } \ No newline at end of file diff --git a/resources/assets/js/components/PostComments.vue b/resources/assets/js/components/PostComments.vue index d93396c8f..4dbb3f776 100644 --- a/resources/assets/js/components/PostComments.vue +++ b/resources/assets/js/components/PostComments.vue @@ -18,7 +18,7 @@