Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/app/backend-api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class BackendRoutes {
static RoutePathGetMessagesStateless = "/get-messages-stateless";
static RoutePathGetFollowsStateless = "/get-follows-stateless";
static RoutePathCreateFollowTxnStateless = "/create-follow-txn-stateless";
static RoutePathCreateBlockPublicKeyTxnStateless = "/create-block-public-key-txn-stateless";
static RoutePathCreateLikeStateless = "/create-like-stateless";
static RoutePathBuyOrSellCreatorCoin = "/buy-or-sell-creator-coin-WVAzTWpGOFFnMlBvWXZhTFA4NjNSZGNW";
static RoutePathBuyOrSellCreatorCoinPreview = "/buy-or-sell-creator-coin-preview-WVAzTWpGOFFnMlBvWXZhTFA4NjNSZGNW";
Expand All @@ -38,7 +39,6 @@ export class BackendRoutes {
static RoutePathGetSinglePost = "/get-single-post";
static RoutePathSendPhoneNumberVerificationText = "/send-phone-number-verification-text";
static RoutePathSubmitPhoneNumberVerificationCode = "/submit-phone-number-verification-code";
static RoutePathBlockPublicKey = "/block-public-key";
static RoutePathGetBlockTemplate = "/get-block-template";
static RoutePathGetTxn = "/get-txn";
static RoutePathGetIdentities = "/get-identities";
Expand Down Expand Up @@ -99,6 +99,7 @@ export class ProfileEntryResponse {
Posts?: PostEntryResponse[];
IsReserved?: boolean;
IsVerified?: boolean;
IsBlockedByReader?: boolean;
}

export class User {
Expand Down Expand Up @@ -716,8 +717,14 @@ export class BackendApiService {
AddGlobalFeedBool,
});
}
GetSingleProfile(endpoint: string, PublicKeyBase58Check: string, Username: string): Observable<any> {
GetSingleProfile(
endpoint: string,
UserPublicKeyBase58Check: string,
PublicKeyBase58Check: string,
Username: string
): Observable<any> {
return this.post(endpoint, BackendRoutes.RoutePathGetSingleProfile, {
UserPublicKeyBase58Check,
PublicKeyBase58Check,
Username,
});
Expand Down Expand Up @@ -1001,17 +1008,20 @@ export class BackendApiService {
return request;
}

BlockPublicKey(
CreateBlockPublicKeyTxn(
endpoint: string,
PublicKeyBase58Check: string,
BlockPublicKeyBase58Check: string,
Unblock: boolean = false
Unblock: boolean = false,
MinFeeRateNanosPerKB: number
): Observable<any> {
return this.jwtPost(endpoint, BackendRoutes.RoutePathBlockPublicKey, PublicKeyBase58Check, {
const request = this.post(endpoint, BackendRoutes.RoutePathCreateBlockPublicKeyTxnStateless, {
PublicKeyBase58Check,
BlockPublicKeyBase58Check,
Unblock,
MinFeeRateNanosPerKB,
});
return this.signAndSubmitTransaction(endpoint, request, PublicKeyBase58Check);
}

// Note that FetchStartIndex < 0 means "fetch me the latest notifications."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,20 @@

<!-- Posts -->
<div *ngIf="profile && activeTab == 'Posts' && !loading">
<creator-profile-posts
[profile]="profile"
[showProfileAsReserved]="showProfileAsReserved()"
(blockUser)="userBlocked()"
></creator-profile-posts>
<div *ngIf="globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check)" class="w-100 d-flex p-15px">
<div *ngIf="profile.IsBlockedByReader; else showPosts" class="w-100 d-flex p-15px">
<span>
You have blocked {{ profile.Username }}.
<a (click)="unblock()">Unblock</a>
to see their posts.
</span>
</div>
<ng-template #showPosts>
<creator-profile-posts
[profile]="profile"
[showProfileAsReserved]="showProfileAsReserved()"
(blockUser)="userBlocked()"
></creator-profile-posts>
</ng-template>
</div>

<!-- Creator Coin Info -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ export class CreatorProfileDetailsComponent {
}).then((response: any) => {
this.userUnblocked.emit(this.profile.PublicKeyBase58Check);
if (response.isConfirmed) {
delete this.globalVars.loggedInUser.BlockedPubKeys[this.profile.PublicKeyBase58Check];
this.backendApi
.BlockPublicKey(
.CreateBlockPublicKeyTxn(
this.globalVars.localNode,
this.globalVars.loggedInUser.PublicKeyBase58Check,
this.profile.PublicKeyBase58Check,
true /* unblock */
true /* unblock */,
this.globalVars.feeRateBitCloutPerKB * 1e9
)
.subscribe(
() => {
this.globalVars.logEvent("user : unblock");
this.profile.IsBlockedByReader = false;
},
(err) => {
console.log(err);
Expand Down Expand Up @@ -119,17 +120,19 @@ export class CreatorProfileDetailsComponent {
reverseButtons: true,
}).then((response: any) => {
if (response.isConfirmed) {
this.globalVars.loggedInUser.BlockedPubKeys[this.profile.PublicKeyBase58Check] = {};
Promise.all([
this.backendApi
.BlockPublicKey(
.CreateBlockPublicKeyTxn(
this.globalVars.localNode,
this.globalVars.loggedInUser.PublicKeyBase58Check,
this.profile.PublicKeyBase58Check
this.profile.PublicKeyBase58Check,
false,
this.globalVars.feeRateBitCloutPerKB * 1e9
)
.subscribe(
() => {
this.globalVars.logEvent("user : block");
this.profile.IsBlockedByReader = true;
},
(err) => {
console.error(err);
Expand All @@ -156,7 +159,7 @@ export class CreatorProfileDetailsComponent {
}

this.loading = true;
this.backendApi.GetSingleProfile(this.globalVars.localNode, "", this.userName).subscribe(
this.backendApi.GetSingleProfile(this.globalVars.localNode, readerPubKey, "", this.userName).subscribe(
(res) => {
if (!res) {
console.log("This profile was not found. It either does not exist or it was deleted.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,32 @@
</div>
</div>
<ng-container *ngIf="!showProfileAsReserved">
<div *ngIf="!globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check)">
<div #uiScroll *uiScroll="let post of datasource" class="border-bottom border-color-grey">
<feed-post
*ngIf="post.ProfileEntryResponse"
[contentShouldLinkToThread]="true"
[includePaddingOnPost]="true"
[post]="post"
[afterCommentCreatedCallback]="_prependComment.bind(this, post)"
[blocked]="globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check)"
(userBlocked)="userBlocked()"
></feed-post>
<div *ngFor="let comment of post.Comments">
<div class="px-15px pb-15px post-thread__subcomment-container">
<feed-post
[includePaddingOnPost]="false"
[post]="comment"
[parentPost]="post"
[contentShouldLinkToThread]="true"
[showIconRow]="false"
[showDropdown]="false"
[showReplyToContent]="false"
[isSubcomment]="true"
[afterCommentCallback]="_prependComment.bind(this.post)"
></feed-post>
</div>
<div #uiScroll *uiScroll="let post of datasource" class="border-bottom border-color-grey">
<feed-post
*ngIf="post.ProfileEntryResponse"
[contentShouldLinkToThread]="true"
[includePaddingOnPost]="true"
[post]="post"
[afterCommentCreatedCallback]="_prependComment.bind(this, post)"
[blocked]="profile.IsBlockedByReader"
[enableChangeDetection]="true"
(userBlocked)="userBlocked()"
></feed-post>
<div *ngFor="let comment of post.Comments">
<div class="px-15px pb-15px post-thread__subcomment-container">
<feed-post
[includePaddingOnPost]="false"
[post]="comment"
[parentPost]="post"
[contentShouldLinkToThread]="true"
[showIconRow]="false"
[showDropdown]="false"
[showReplyToContent]="false"
[isSubcomment]="true"
[afterCommentCallback]="_prependComment.bind(this.post)"
></feed-post>
</div>
</div>
<simple-center-loader [height]="200" *ngIf="loadingNextPage && !loadingFirstPage"></simple-center-loader>
</div>
<simple-center-loader [height]="200" *ngIf="loadingNextPage && !loadingFirstPage"></simple-center-loader>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ export class CreatorProfilePostsComponent {
datasource: IDatasource<IAdapter<PostEntryResponse>> = this.getDatasource();
loadingFirstPage = true;
loadingNextPage = false;
pagedKeys = {
0: "",
initialPagedKeys = {
0: '',
};
pagedKeys = this.initialPagedKeys;

pagedRequests = {
"-1": new Promise((resolve) => {
initialPagedRequests = {
'-1': new Promise(resolve => {
resolve([]);
}),
})
};

pagedRequests = this.initialPagedRequests;

lastPage = null;

@Output() blockUser = new EventEmitter();
Expand All @@ -41,9 +44,7 @@ export class CreatorProfilePostsComponent {
private cdr: ChangeDetectorRef,
private router: Router,
private location: Location
) {
// this.datasource = this.getDatasource();
}
) {}

// TODO: Cleanup - Create InfiniteScroller class to de-duplicate this logic
getDatasource() {
Expand Down Expand Up @@ -139,6 +140,9 @@ export class CreatorProfilePostsComponent {
}

userBlocked() {
this.profile.IsBlockedByReader = true;
this.pagedRequests = this.initialPagedRequests;
this.pagedKeys = this.initialPagedKeys;
this.blockUser.emit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<div class="dropdown-menu dropdown-menu-right text-danger p-0" *dropdownMenu>
<a
class="dropdown-menu-item d-block link--unstyled p-10px feed-post__dropdown-menu-item"
(click)="globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check) ? unblock() : block()"
(click)="profile.IsBlockedByReader ? unblock() : block()"
>
<i class="fas fa-ban"></i>
{{ globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check) ? "Unblock" : "Block" }} User
{{ profile.IsBlockedByReader ? "Unblock" : "Block" }} User
</a>
</div>
</div>
Expand All @@ -37,7 +37,7 @@
<ng-template #elseBlock>
<!-- Show follow button-->
<follow-button
*ngIf="!globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check)"
*ngIf="!profile.IsBlockedByReader"
[displayAsLink]="true"
[followedPubKeyBase58Check]="profile.PublicKeyBase58Check"
></follow-button>
Expand All @@ -54,7 +54,7 @@
</a>
<a
class="btn btn-danger font-weight-bold ml-15px fs-14px creator-profile-top-card__block-btn"
*ngIf="globalVars.hasUserBlockedCreator(profile.PublicKeyBase58Check)"
*ngIf="profile.IsBlockedByReader"
(click)="unblock()"
>
<span>Unblock</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class FeedPostDropdownComponent {
// User shouldn't be able to block themselves
return (
this.globalVars.loggedInUser?.PublicKeyBase58Check !== this.post.PosterPublicKeyBase58Check &&
!this.globalVars.hasUserBlockedCreator(this.post.PosterPublicKeyBase58Check)
!this.post.ProfileEntryResponse.IsBlockedByReader
);
}

Expand Down
7 changes: 4 additions & 3 deletions src/app/feed/feed-post/feed-post.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>

<div
*ngIf="globalVars.hasUserBlockedCreator(post.PosterPublicKeyBase58Check)"
*ngIf="post.ProfileEntryResponse.IsBlockedByReader"
class="p-15px background-color-grey d-flex align-items-center justify-content-center fs-15px"
>
<a
Expand All @@ -43,7 +43,7 @@
</div>

<div
*ngIf="!post.IsHidden && !hidingPost && !globalVars.hasUserBlockedCreator(postContent.PosterPublicKeyBase58Check)"
*ngIf="!post.IsHidden && !hidingPost && !post.ProfileEntryResponse.IsBlockedByReader"
class="d-flex flex-column js-feed-post"
[ngClass]="{ 'js-feed-post-hover': hoverable }"
>
Expand Down Expand Up @@ -80,7 +80,8 @@
[postContent]="postContent"
(postHidden)="hidePost()"
(userBlocked)="blockUser()"
(toggleGlobalFeed)="_addPostToGlobalFeed()"
(toggleGlobalFeed)="_addPostToGlobalFeed($event)"
(togglePostPin)="_pinPostToGlobalFeed($event)"
></feed-post-dropdown>
</div>

Expand Down
9 changes: 6 additions & 3 deletions src/app/feed/feed-post/feed-post.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,19 @@ export class FeedPostComponent implements OnInit {
}).then((response: any) => {
if (response.isConfirmed) {
this.backendApi
.BlockPublicKey(
.CreateBlockPublicKeyTxn(
this.globalVars.localNode,
this.globalVars.loggedInUser.PublicKeyBase58Check,
this.post.PosterPublicKeyBase58Check
this.post.PosterPublicKeyBase58Check,
false,
this.globalVars.feeRateBitCloutPerKB * 1e9
)
.subscribe(
() => {
this.globalVars.logEvent("user : block");
this.globalVars.loggedInUser.BlockedPubKeys[this.post.PosterPublicKeyBase58Check] = {};
this.post.ProfileEntryResponse.IsBlockedByReader = true;
this.userBlocked.emit(this.post.PosterPublicKeyBase58Check);
this.ref.detectChanges();
},
(err) => {
console.error(err);
Expand Down
2 changes: 1 addition & 1 deletion src/app/feed/feed.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
[contentShouldLinkToThread]="true"
[hideFollowLink]="hideFollowLink()"
[showLeftSelectedBorder]="post.IsPinned"
[blocked]="globalVars.hasUserBlockedCreator(post.PosterPublicKeyBase58Check)"
[blocked]="post.ProfileEntryResponse.IsBlockedByReader"
(postDeleted)="onPostHidden($event)"
(userBlocked)="userBlocked()"
></feed-post>
Expand Down
4 changes: 3 additions & 1 deletion src/app/follow-button/follow-button.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class FollowButtonComponent implements OnInit, OnDestroy {
changeRef: ChangeDetectorRef;

unfollow(event) {
event.stopPropagation();
if (event) {
event.stopPropagation();
}
this._toggleFollow(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
[showThreadConnectionLine]="true"
[blocked]="isPostBlocked(parentPost)"
(postDeleted)="onPostHidden(currentPost, null, null)"
(userBlocked)="afterUserBlocked($event)"
(userBlocked)="userBlocked($event)"
></feed-post>
</div>

Expand All @@ -41,7 +41,7 @@
[showLeftSelectedBorder]="true"
[blocked]="isPostBlocked(currentPost)"
(postDeleted)="onPostHidden(currentPost, null, null)"
(userBlocked)="afterUserBlocked($event)"
(userBlocked)="userBlocked($event)"
></feed-post>
</div>

Expand All @@ -60,8 +60,9 @@
[showReplyingToContent]="true"
[afterCommentCreatedCallback]="prependToSubcommentList.bind(this, item, currentPost)"
[blocked]="isPostBlocked(item)"
[enableChangeDetection]="true"
(postDeleted)="onPostHidden(item, currentPost, null)"
(userBlocked)="afterUserBlocked($event)"
(userBlocked)="userBlocked($event)"
></feed-post>

<div *ngFor="let subcommentPost of item.Comments">
Expand All @@ -81,7 +82,7 @@
[afterCommentCreatedCallback]="appendToSubcommentList.bind(this, item, currentPost)"
[blocked]="isPostBlocked(subcommentPost)"
(postDeleted)="onPostHidden(subcommentPost, item, currentPost)"
(userBlocked)="afterUserBlocked($event)"
(userBlocked)="userBlocked($event)"
></feed-post>
</div>
</div>
Expand Down
Loading