From 9bc814c3429ec61f3f03248e92f90d1f20a410b0 Mon Sep 17 00:00:00 2001 From: bluepartyhat Date: Mon, 28 Jun 2021 14:49:20 -0700 Subject: [PATCH 1/6] Added buttons to dropdown. --- .../feed-post-dropdown.component.html | 18 +++++++++++++++++- .../feed-post-dropdown.component.ts | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.html b/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.html index 6ae68b8cd..b91943b25 100644 --- a/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.html +++ b/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.html @@ -5,7 +5,7 @@ - diff --git a/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts b/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts index 7ba60563e..aa9f2ef4e 100644 --- a/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts +++ b/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts @@ -77,6 +77,16 @@ export class FeedPostDropdownComponent { return this.globalFeedEligible() && this.post.IsPinned; } + showPinToProfileDropdownItem(): boolean { + return this.globalVars.loggedInUser.PublicKeyBase58Check == this.post.PosterPublicKeyBase58Check + && !this.post.IsPinned; + } + + showUnpinFromProfileDropdownItem(): boolean { + return this.globalVars.loggedInUser.PublicKeyBase58Check == this.post.PosterPublicKeyBase58Check + && this.post.IsPinned; + } + hidePost() { this.postHidden.emit(); } From 432d3cd3f1b101882bda306fcdc4aaa512c10901 Mon Sep 17 00:00:00 2001 From: bluepartyhat Date: Tue, 29 Jun 2021 18:43:29 -0700 Subject: [PATCH 2/6] Initial code for pinned posts on frontend. --- src/app/backend-api.service.ts | 7 +++- .../creator-profile-posts.component.html | 2 + .../creator-profile-posts.component.ts | 4 +- .../feed-create-post.component.ts | 1 + .../feed-post-dropdown.component.ts | 13 +++++-- .../feed-post-icon-row.component.ts | 2 + .../feed/feed-post/feed-post.component.html | 9 ++++- src/app/feed/feed-post/feed-post.component.ts | 38 ++++++++++++++++++- src/app/feed/feed.component.html | 2 +- .../post-thread/post-thread.component.html | 1 + 10 files changed, 69 insertions(+), 10 deletions(-) diff --git a/src/app/backend-api.service.ts b/src/app/backend-api.service.ts index 42df9cf5d..a9804d4d8 100644 --- a/src/app/backend-api.service.ts +++ b/src/app/backend-api.service.ts @@ -179,6 +179,7 @@ export class PostEntryResponse { InMempool: boolean; IsPinned: boolean; DiamondsFromSender?: number; + IsGlobalPinned: boolean; } export class DiamondsPost { @@ -650,6 +651,7 @@ export class BackendApiService { PostExtraData: any, Sub: string, IsHidden: boolean, + IsPinned: boolean, MinFeeRateNanosPerKB: number ): Observable { const request = this.post(endpoint, BackendRoutes.RoutePathSubmitPost, { @@ -662,6 +664,7 @@ export class BackendApiService { PostExtraData, Sub, IsHidden, + IsPinned, MinFeeRateNanosPerKB, }); @@ -777,7 +780,8 @@ export class BackendApiService { ReaderPublicKeyBase58Check: string, LastPostHashHex: string, NumToFetch: number, - MediaRequired: boolean + MediaRequired: boolean, + MaxPinnedPosts: number, ): Observable { return this.post(endpoint, BackendRoutes.RoutePathGetPostsForPublicKey, { PublicKeyBase58Check, @@ -786,6 +790,7 @@ export class BackendApiService { LastPostHashHex, NumToFetch, MediaRequired, + MaxPinnedPosts, }); } diff --git a/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.html b/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.html index b82282604..08ea26ca0 100644 --- a/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.html +++ b/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.html @@ -20,9 +20,11 @@ *ngIf="post.ProfileEntryResponse" [contentShouldLinkToThread]="true" [includePaddingOnPost]="true" + [includeVisualPin]="true" [post]="post" [afterCommentCreatedCallback]="_prependComment.bind(this, post, index)" [blocked]="globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check)" + [showLeftSelectedBorder]="post.IsPinned" (userBlocked)="userBlocked()" >
diff --git a/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.ts b/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.ts index 6ff48b0a2..5bb6defc1 100644 --- a/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.ts +++ b/src/app/creator-profile-page/creator-profile-posts/creator-profile-posts.component.ts @@ -13,6 +13,7 @@ import * as _ from "lodash"; }) export class CreatorProfilePostsComponent { static PAGE_SIZE = 10; + static MAX_PINNED_POSTS = 5; @Input() profile: ProfileEntryResponse; @Input() afterCommentCreatedCallback: any = null; @Input() showProfileAsReserved: boolean; @@ -104,7 +105,8 @@ export class CreatorProfilePostsComponent { this.globalVars.loggedInUser?.PublicKeyBase58Check, lastPostHashHex, CreatorProfilePostsComponent.PAGE_SIZE, - false /*MediaRequired*/ + false /*MediaRequired*/, + CreatorProfilePostsComponent.MAX_PINNED_POSTS, ) .toPromise() .then((res) => { diff --git a/src/app/feed/feed-create-post/feed-create-post.component.ts b/src/app/feed/feed-create-post/feed-create-post.component.ts index 282119e41..8b87bdf49 100644 --- a/src/app/feed/feed-create-post/feed-create-post.component.ts +++ b/src/app/feed/feed-create-post/feed-create-post.component.ts @@ -171,6 +171,7 @@ export class FeedCreatePostComponent implements OnInit { // TODO: Should we have different values for creator basis points and stake multiple? // TODO: Also, it may not be reasonable to allow stake multiple to be set in the FE. false /*IsHidden*/, + false, this.globalVars.defaultFeeRateNanosPerKB /*MinFeeRateNanosPerKB*/ ) .subscribe( diff --git a/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts b/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts index aa9f2ef4e..bd5fab6d2 100644 --- a/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts +++ b/src/app/feed/feed-post-dropdown/feed-post-dropdown.component.ts @@ -16,7 +16,8 @@ export class FeedPostDropdownComponent { @Output() postHidden = new EventEmitter(); @Output() userBlocked = new EventEmitter(); @Output() toggleGlobalFeed = new EventEmitter(); - @Output() togglePostPin = new EventEmitter(); + @Output() toggleFeedPostPin = new EventEmitter(); + @Output() toggleProfilePostPin = new EventEmitter(); constructor( public globalVars: GlobalVarsService, @@ -70,11 +71,11 @@ export class FeedPostDropdownComponent { } showPinPostToGlobalFeedDropdownItem(): boolean { - return this.globalFeedEligible() && !this.post.IsPinned; + return this.globalFeedEligible() && !this.post.IsGlobalPinned; } showUnpinPostFromGlobalFeedDropdownItem(): boolean { - return this.globalFeedEligible() && this.post.IsPinned; + return this.globalFeedEligible() && this.post.IsGlobalPinned; } showPinToProfileDropdownItem(): boolean { @@ -100,7 +101,11 @@ export class FeedPostDropdownComponent { } _pinPostToGlobalFeed(event: any) { - this.togglePostPin.emit(event); + this.toggleFeedPostPin.emit(event); + } + + _pinPostToProfile(event: any) { + this.toggleProfilePostPin.emit(event); } copyPostLinkToClipboard(event) { diff --git a/src/app/feed/feed-post-icon-row/feed-post-icon-row.component.ts b/src/app/feed/feed-post-icon-row/feed-post-icon-row.component.ts index 8ce4abf75..654656cf4 100644 --- a/src/app/feed/feed-post-icon-row/feed-post-icon-row.component.ts +++ b/src/app/feed/feed-post-icon-row/feed-post-icon-row.component.ts @@ -122,6 +122,7 @@ export class FeedPostIconRowComponent { {}, "" /*Sub*/, false /*IsHidden*/, + false, // What should the fee rate be for this? this.globalVars.feeRateBitCloutPerKB * 1e9 /*feeRateNanosPerKB*/ ) @@ -171,6 +172,7 @@ export class FeedPostIconRowComponent { {}, "" /*Sub*/, true /*IsHidden*/, + false, // What should the fee rate be for this? this.globalVars.feeRateBitCloutPerKB * 1e9 /*feeRateNanosPerKB*/ ) diff --git a/src/app/feed/feed-post/feed-post.component.html b/src/app/feed/feed-post/feed-post.component.html index 0e1367322..2282ff200 100644 --- a/src/app/feed/feed-post/feed-post.component.html +++ b/src/app/feed/feed-post/feed-post.component.html @@ -174,12 +174,16 @@ + + + +
diff --git a/src/app/feed/feed-post/feed-post.component.ts b/src/app/feed/feed-post/feed-post.component.ts index 2b68b4200..59faa430f 100644 --- a/src/app/feed/feed-post/feed-post.component.ts +++ b/src/app/feed/feed-post/feed-post.component.ts @@ -87,11 +87,14 @@ export class FeedPostComponent implements OnInit { @Input() showReplyingTo = false; + @Input() includeVisualPin = false; + // If the post is shown in a modal, this is used to hide the modal on post click. @Input() containerModalRef: any = null; // emits the PostEntryResponse @Output() postDeleted = new EventEmitter(); + @Output() postPinnedToProfile = new EventEmitter(); // emits the UserBlocked event @Output() userBlocked = new EventEmitter(); @@ -231,13 +234,14 @@ export class FeedPostComponent implements OnInit { this.globalVars.localNode, this.globalVars.loggedInUser.PublicKeyBase58Check, this._post.PostHashHex /*PostHashHexToModify*/, - "" /*ParentPostHashHex*/, + this._post.ParentStakeID /*ParentPostHashHex*/, "" /*Title*/, { Body: this._post.Body, ImageURLs: this._post.ImageURLs } /*BodyObj*/, this._post.RecloutedPostEntryResponse?.PostHashHex || "", {}, "" /*Sub*/, true /*IsHidden*/, + this._post.IsPinned, this.globalVars.feeRateBitCloutPerKB * 1e9 /*feeRateNanosPerKB*/ ) .subscribe( @@ -256,6 +260,38 @@ export class FeedPostComponent implements OnInit { }); } + pinPostToProfile() { + this.ref.detectChanges(); + this.backendApi + .SubmitPost( + this.globalVars.localNode, + this.globalVars.loggedInUser.PublicKeyBase58Check, + this._post.PostHashHex /*PostHashHexToModify*/, + this._post.ParentStakeID /*ParentPostHashHex*/, + "" /*Title*/, + { Body: this._post.Body, ImageURLs: this._post.ImageURLs } /*BodyObj*/, + this._post.RecloutedPostEntryResponse?.PostHashHex || "", + {}, + "" /*Sub*/, + this._post.IsHidden /*IsHidden*/, + !this._post.IsPinned, /* We toggle whatever is set already */ + this.globalVars.feeRateBitCloutPerKB * 1e9 /*feeRateNanosPerKB*/ + ) + .subscribe( + (response) => { + this._post.IsPinned = !this._post.IsPinned + this.globalVars.logEvent("post : profile pin"); + }, + (err) => { + console.error(err); + const parsedError = this.backendApi.parsePostError(err); + this.globalVars.logEvent("post : profile pin : error", { parsedError }); + this.globalVars._alertError(parsedError); + } + ); + } + + blockUser() { SwalHelper.fire({ target: this.globalVars.getTargetComponentSelector(), diff --git a/src/app/feed/feed.component.html b/src/app/feed/feed.component.html index 0d54be9db..f97879049 100644 --- a/src/app/feed/feed.component.html +++ b/src/app/feed/feed.component.html @@ -56,7 +56,7 @@ [showReplyingToContent]="!!post.parentPost" [parentPost]="post.parentPost" [contentShouldLinkToThread]="true" - [showLeftSelectedBorder]="post.IsPinned" + [showLeftSelectedBorder]="post.IsGlobalPinned" [blocked]="globalVars.hasUserBlockedCreator(post.PosterPublicKeyBase58Check)" (postDeleted)="onPostHidden($event)" (userBlocked)="userBlocked()" diff --git a/src/app/post-thread-page/post-thread/post-thread.component.html b/src/app/post-thread-page/post-thread/post-thread.component.html index d9f0fee24..676211f27 100644 --- a/src/app/post-thread-page/post-thread/post-thread.component.html +++ b/src/app/post-thread-page/post-thread/post-thread.component.html @@ -35,6 +35,7 @@ Date: Tue, 29 Jun 2021 19:22:30 -0700 Subject: [PATCH 3/6] Clean up visuals surrounding pin on profile. --- src/app/feed/feed-post/feed-post.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/feed/feed-post/feed-post.component.html b/src/app/feed/feed-post/feed-post.component.html index 2282ff200..d35fb5dd8 100644 --- a/src/app/feed/feed-post/feed-post.component.html +++ b/src/app/feed/feed-post/feed-post.component.html @@ -174,7 +174,7 @@ Date: Fri, 2 Jul 2021 18:31:38 -0700 Subject: [PATCH 4/6] Remove detect changes. Co-authored-by: Lazy Nina <81658138+lazynina@users.noreply.github.com> --- src/app/feed/feed-post/feed-post.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/feed/feed-post/feed-post.component.ts b/src/app/feed/feed-post/feed-post.component.ts index 59faa430f..110764452 100644 --- a/src/app/feed/feed-post/feed-post.component.ts +++ b/src/app/feed/feed-post/feed-post.component.ts @@ -261,7 +261,6 @@ export class FeedPostComponent implements OnInit { } pinPostToProfile() { - this.ref.detectChanges(); this.backendApi .SubmitPost( this.globalVars.localNode, From d97680827ac6e949bc4f40c022bdcb7e811957d8 Mon Sep 17 00:00:00 2001 From: bluepartyhat <81657864+bluepartyhat@users.noreply.github.com> Date: Fri, 2 Jul 2021 18:32:07 -0700 Subject: [PATCH 5/6] Fix logEvent text. Co-authored-by: Lazy Nina <81658138+lazynina@users.noreply.github.com> --- src/app/feed/feed-post/feed-post.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/feed/feed-post/feed-post.component.ts b/src/app/feed/feed-post/feed-post.component.ts index 110764452..b4bfa3d6c 100644 --- a/src/app/feed/feed-post/feed-post.component.ts +++ b/src/app/feed/feed-post/feed-post.component.ts @@ -284,7 +284,7 @@ export class FeedPostComponent implements OnInit { (err) => { console.error(err); const parsedError = this.backendApi.parsePostError(err); - this.globalVars.logEvent("post : profile pin : error", { parsedError }); + this.globalVars.logEvent("post : profile-pin : error", { parsedError }); this.globalVars._alertError(parsedError); } ); From 29c456092d6866dfceada03126638e51a1bc52bb Mon Sep 17 00:00:00 2001 From: bluepartyhat <81657864+bluepartyhat@users.noreply.github.com> Date: Fri, 2 Jul 2021 18:32:44 -0700 Subject: [PATCH 6/6] Fix logEvent profile-pin typo Co-authored-by: Lazy Nina <81658138+lazynina@users.noreply.github.com> --- src/app/feed/feed-post/feed-post.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/feed/feed-post/feed-post.component.ts b/src/app/feed/feed-post/feed-post.component.ts index b4bfa3d6c..fb0c1b421 100644 --- a/src/app/feed/feed-post/feed-post.component.ts +++ b/src/app/feed/feed-post/feed-post.component.ts @@ -279,7 +279,7 @@ export class FeedPostComponent implements OnInit { .subscribe( (response) => { this._post.IsPinned = !this._post.IsPinned - this.globalVars.logEvent("post : profile pin"); + this.globalVars.logEvent("post : profile-pin"); }, (err) => { console.error(err);