Skip to content

Commit

Permalink
Update user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
miladsoft committed Nov 2, 2024
1 parent b811577 commit beb7209
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
10 changes: 7 additions & 3 deletions src/app/components/profile/profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@
[src]="token.safeWord"
alt="Embedded Image"
style="width: 100%"
class="max-h-140 object-cover"
/>
</div>
</ng-container>
Expand Down Expand Up @@ -920,9 +921,12 @@
<!-- Plain Text -->
<ng-container *ngIf="!token.token">
<div class="mx-6 mb-6 mt-2 sm:mx-8">
<span class="inline-block break-words break-all">{{
token
}}</span>
<span
class="inline-block break-words break-all"
[ngClass]="{'large-font': isSingleEmojiOrWord(token)}"
>
{{ token.trim() }}
</span>
</div>
</ng-container>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/profile/profile.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@
max-width: 100%;
border-radius: 10px;
}
.large-font {
font-size: 3rem;
}
17 changes: 13 additions & 4 deletions src/app/components/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,10 @@ export class ProfileComponent implements OnInit, OnDestroy {

});

this._storageService.posts$.subscribe((posts) => {
this.posts = posts.sort((a, b) => b.createdAt - a.createdAt);
this._changeDetectorRef.detectChanges();
this._storageService.posts$.subscribe((data) => {
this.posts = data;
this._changeDetectorRef.detectChanges();
});

}

toggleAbout(): void {
Expand Down Expand Up @@ -450,4 +449,14 @@ export class ProfileComponent implements OnInit, OnDestroy {
this.openSnackBar('npub public key copied', 'dismiss');
}

isSingleEmojiOrWord(token: string): boolean {
const trimmedToken = token.trim();
const isSingleWord = /^\w+$/.test(trimmedToken);

const isSingleEmoji = /^[\p{Emoji}]+$/u.test(trimmedToken);

return isSingleWord || isSingleEmoji;
}


}
2 changes: 1 addition & 1 deletion src/app/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class StateService {
const postFilter: Filter = {
kinds: [1],
authors: [pubkey],
limit: 100
limit: 20
};

if (postsLastUpdate) {
Expand Down
10 changes: 8 additions & 2 deletions src/app/services/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,21 @@ export class StorageService {
async savePostForPubKey(event: any): Promise<void> {
try {
await this.postsStore.setItem(event.id, event);

await this.setUpdateHistory('posts');

this.postsSubject.next(event);
const currentPosts = this.postsSubject.getValue();

const updatedPosts = [event, ...currentPosts];

this.postsSubject.next(updatedPosts);


} catch (error) {
console.error('Error saving event type 1 and sending it to clients:', error);
}
}


async getPostsByPubKey(pubKey: string): Promise<any[]> {
try {
const events: any[] = [];
Expand Down

0 comments on commit beb7209

Please sign in to comment.