mirror of
https://github.com/block-core/blockcore-notes.git
synced 2024-09-28 22:10:42 +00:00
Add display of a limited set of public chats
This commit is contained in:
parent
6ba07dd615
commit
a29dc1100c
@ -87,14 +87,15 @@
|
|||||||
<mat-icon [matBadgeHidden]="(ui.unreadNotifications$ | async) == 0" [matBadge]="ui.unreadNotifications$ | async">notifications</mat-icon>
|
<mat-icon [matBadgeHidden]="(ui.unreadNotifications$ | async) == 0" [matBadge]="ui.unreadNotifications$ | async">notifications</mat-icon>
|
||||||
<span *ngIf="displayLabels">{{ 'App.Notifications' | translate }}</span>
|
<span *ngIf="displayLabels">{{ 'App.Notifications' | translate }}</span>
|
||||||
</a>
|
</a>
|
||||||
<!-- <a [routerLink]="['/chat']" mat-menu-item (click)="toggleMenu()" [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active">
|
<a [routerLink]="['/chat']" mat-menu-item (click)="toggleMenu()" [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active">
|
||||||
<mat-icon>chat</mat-icon>
|
<mat-icon>chat</mat-icon>
|
||||||
<span *ngIf="displayLabels">Channels</span>
|
<span *ngIf="displayLabels">Chats</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a [routerLink]="['/m']" mat-menu-item (click)="toggleMenu()" [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active">
|
<a [routerLink]="['/m']" mat-menu-item (click)="toggleMenu()" [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active">
|
||||||
<mat-icon matBadge="2">mail</mat-icon>
|
<mat-icon matBadge="2">mail</mat-icon>
|
||||||
<span *ngIf="displayLabels">Messages</span>
|
<span *ngIf="displayLabels">Messages</span>
|
||||||
</a> -->
|
</a>
|
||||||
<a [routerLink]="['/people']" mat-menu-item (click)="toggleMenu()" [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active">
|
<a [routerLink]="['/people']" mat-menu-item (click)="toggleMenu()" [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="active">
|
||||||
<mat-icon>people</mat-icon>
|
<mat-icon>people</mat-icon>
|
||||||
<span *ngIf="displayLabels">{{ 'App.People' | translate }}</span>
|
<span *ngIf="displayLabels">{{ 'App.People' | translate }}</span>
|
||||||
|
@ -154,6 +154,7 @@ import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
|
|||||||
import { DragScrollModule } from 'ngx-drag-scroll';
|
import { DragScrollModule } from 'ngx-drag-scroll';
|
||||||
import { ZappersListDialogComponent } from './shared/zappers-list-dialog/zappers-list-dialog.component';
|
import { ZappersListDialogComponent } from './shared/zappers-list-dialog/zappers-list-dialog.component';
|
||||||
import { ExampleComponent } from './example/example';
|
import { ExampleComponent } from './example/example';
|
||||||
|
import { MessageListComponent } from './shared/message-list/message-list.component';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
@ -245,7 +246,8 @@ import { ExampleComponent } from './example/example';
|
|||||||
TagsComponent,
|
TagsComponent,
|
||||||
BadgeComponent,
|
BadgeComponent,
|
||||||
ZappersListDialogComponent,
|
ZappersListDialogComponent,
|
||||||
ExampleComponent
|
ExampleComponent,
|
||||||
|
MessageListComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
|
@ -1,4 +1,47 @@
|
|||||||
<mat-sidenav-container class="drawer-container" autosize>
|
<mat-nav-list>
|
||||||
|
<div class="search">
|
||||||
|
<mat-form-field appearance="fill" class="input-full-width">
|
||||||
|
<input matInput type="text" placeholder="Search..." />
|
||||||
|
<mat-icon matSuffix>search</mat-icon>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ng-container *ngFor="let chat of ui.chats$ | async; let lastItem = last">
|
||||||
|
<mat-list-item>
|
||||||
|
<img alt="" matListItemAvatar [src]="chat.picture" />
|
||||||
|
<h4 mat-line>{{ chat.name }}</h4>
|
||||||
|
<p mat-line class="last-message">{{ chat.about }}</p>
|
||||||
|
<!-- <span *ngIf="chat.lastMessageLength" [matBadge]="chat.lastMessageLength" matBadgeOverlap="false" matBadgePosition="above before" matBadgeColor="warn"></span> -->
|
||||||
|
</mat-list-item>
|
||||||
|
<!-- <app-chat-item [routerLink]="['/m', chat.id]" [chat]="chat"></app-chat-item> -->
|
||||||
|
<mat-divider *ngIf="!lastItem"></mat-divider>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- <ng-container *ngFor="let event of chatService.chats2$ | async; let lastItem = last">
|
||||||
|
<app-chat-item [routerLink]="['/m', '5f432a9f39b58ff132fc0a4c8af10d42efd917d8076f68bb7f2f91ed7d4f6a41']" [event]="event"></app-chat-item>
|
||||||
|
<mat-divider *ngIf="!lastItem"></mat-divider>
|
||||||
|
</ng-container> -->
|
||||||
|
</mat-nav-list>
|
||||||
|
|
||||||
|
<!-- <div *ngFor="let chat of chatService.chats3">{{ chat.pubkey }} : {{ chat.content }}</div> -->
|
||||||
|
|
||||||
|
<!-- <div *ngIf="chatService.uniqueChats$ | async as chats">
|
||||||
|
<div *ngFor="let chat of chats">{{ chat.pubkey }} : {{ chat.content }}</div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<!-- <div *ngIf="chats$ | async as chats">
|
||||||
|
<div *ngFor="let chat of chats">{{ chat.id }} : {{ chat.name }}</div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<!-- <button (click)="add()">Add</button>
|
||||||
|
|
||||||
|
<button (click)="reset()">Reset</button>
|
||||||
|
|
||||||
|
<button (click)="chatService.download()">Download</button> -->
|
||||||
|
|
||||||
|
<!-- <app-chat-list (openChatSidebar)="open.chatSideBar($event)"></app-chat-list> -->
|
||||||
|
|
||||||
|
<!-- <mat-sidenav-container class="drawer-container" autosize>
|
||||||
<mat-tab-group mat-align-tabs="center">
|
<mat-tab-group mat-align-tabs="center">
|
||||||
<mat-tab label="Messages">
|
<mat-tab label="Messages">
|
||||||
<app-chat-list (openChatSidebar)="open.chatSideBar($event)"></app-chat-list>
|
<app-chat-list (openChatSidebar)="open.chatSideBar($event)"></app-chat-list>
|
||||||
@ -25,4 +68,4 @@
|
|||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
<app-user-profile (openChatWindow)="open.chatSideBar($event)"></app-user-profile>
|
<app-user-profile (openChatWindow)="open.chatSideBar($event)"></app-user-profile>
|
||||||
</mat-sidenav>
|
</mat-sidenav>
|
||||||
</mat-sidenav-container>
|
</mat-sidenav-container> -->
|
||||||
|
@ -29,3 +29,20 @@
|
|||||||
.spacer {
|
.spacer {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.form {
|
||||||
|
padding: 16px 16px 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-full-width {
|
||||||
|
position: relative;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
padding: 10px;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
import { Component, ChangeDetectorRef, ViewChild, ViewEncapsulation } from '@angular/core';
|
import { Component, ChangeDetectorRef, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||||
import { MatSidenav } from '@angular/material/sidenav';
|
import { MatSidenav } from '@angular/material/sidenav';
|
||||||
import { ApplicationState } from '../services/applicationstate';
|
import { ApplicationState } from '../services/applicationstate';
|
||||||
|
import { ChatService } from '../services/chat.service';
|
||||||
|
import { RelayService } from '../services/relay';
|
||||||
|
import { Kind } from 'nostr-tools';
|
||||||
|
import { UIService } from '../services/ui';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-chat',
|
selector: 'app-chat',
|
||||||
templateUrl: './chat.html',
|
templateUrl: './chat.html',
|
||||||
@ -10,7 +14,10 @@ import { ApplicationState } from '../services/applicationstate';
|
|||||||
export class ChatComponent {
|
export class ChatComponent {
|
||||||
@ViewChild('chatSidebar', { static: false }) chatSidebar!: MatSidenav;
|
@ViewChild('chatSidebar', { static: false }) chatSidebar!: MatSidenav;
|
||||||
@ViewChild('userSidebar', { static: false }) userSidebar!: MatSidenav;
|
@ViewChild('userSidebar', { static: false }) userSidebar!: MatSidenav;
|
||||||
constructor(private appState: ApplicationState) {}
|
|
||||||
|
subscription: any;
|
||||||
|
|
||||||
|
constructor(private appState: ApplicationState, private chatService: ChatService, private relayService: RelayService, public ui: UIService) {}
|
||||||
sidebarTitles = {
|
sidebarTitles = {
|
||||||
user: '',
|
user: '',
|
||||||
chat: '',
|
chat: '',
|
||||||
@ -29,8 +36,13 @@ export class ChatComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
this.ui.clearChats();
|
||||||
|
|
||||||
this.appState.updateTitle('Chat');
|
this.appState.updateTitle('Chat');
|
||||||
this.appState.goBack = true;
|
this.appState.goBack = true;
|
||||||
this.appState.actions = [];
|
this.appState.actions = [];
|
||||||
|
|
||||||
|
this.subscription = this.relayService.subscribe([{ kinds: [Kind.ChannelCreation, Kind.ChannelMetadata], limit: 10 }]).id;
|
||||||
|
// this.chatService.downloadChatRooms();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,42 @@ export class ChatService {
|
|||||||
|
|
||||||
subscriptions: Subscription[] = [];
|
subscriptions: Subscription[] = [];
|
||||||
|
|
||||||
|
downloadChatRooms() {
|
||||||
|
debugger;
|
||||||
|
// this.chats2 = [];
|
||||||
|
this.#chats = [];
|
||||||
|
|
||||||
|
this.dataService
|
||||||
|
.downloadEventsByQuery([{ kinds: [40, 41] }], 3000)
|
||||||
|
.pipe(
|
||||||
|
finalize(async () => {
|
||||||
|
debugger;
|
||||||
|
for (let index = 0; index < this.#chats.length; index++) {
|
||||||
|
const event = this.#chats[index];
|
||||||
|
const content = await this.nostr.decrypt(event.pubkey, event.content);
|
||||||
|
event.content = content;
|
||||||
|
console.log('DECRYPTED EVENT:', event);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe(async (event) => {
|
||||||
|
if (this.#chats.findIndex((e) => e.id === event.id) > -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// const gt = globalThis as any;
|
||||||
|
// const content = await gt.nostr.nip04.decrypt(event.pubkey, event.content);
|
||||||
|
// event.content = content;
|
||||||
|
|
||||||
|
this.#chats.unshift(event);
|
||||||
|
|
||||||
|
// this.chats2.push(event);
|
||||||
|
// this.#chatsChanged2.next(this.chats2);
|
||||||
|
});
|
||||||
|
|
||||||
|
// this.subscriptions.push(this.dataService.downloadEventsByQuery([{}]));
|
||||||
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
// this.chats2 = [];
|
// this.chats2 = [];
|
||||||
this.#chats = [];
|
this.#chats = [];
|
||||||
|
@ -582,7 +582,6 @@ export class DataService {
|
|||||||
downloadFromRelay(filters: Filter[], relay: NostrRelay, requestTimeout = 10000): Observable<NostrEventDocument> {
|
downloadFromRelay(filters: Filter[], relay: NostrRelay, requestTimeout = 10000): Observable<NostrEventDocument> {
|
||||||
return new Observable<NostrEventDocument>((observer: Observer<NostrEventDocument>) => {
|
return new Observable<NostrEventDocument>((observer: Observer<NostrEventDocument>) => {
|
||||||
const sub = relay.sub([...filters], {}) as NostrSubscription;
|
const sub = relay.sub([...filters], {}) as NostrSubscription;
|
||||||
// relay.subscriptions.push(sub);
|
|
||||||
|
|
||||||
sub.on('event', (originalEvent: any) => {
|
sub.on('event', (originalEvent: any) => {
|
||||||
const event = this.eventService.processEvent(originalEvent);
|
const event = this.eventService.processEvent(originalEvent);
|
||||||
@ -599,8 +598,6 @@ export class DataService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
// console.log('downloadFromRelay:finished:unsub');
|
|
||||||
// When the observable is finished, this return function is called.
|
|
||||||
sub.unsub();
|
sub.unsub();
|
||||||
};
|
};
|
||||||
}).pipe(
|
}).pipe(
|
||||||
@ -608,7 +605,7 @@ export class DataService {
|
|||||||
catchError((error) => {
|
catchError((error) => {
|
||||||
console.warn('The observable was timed out.');
|
console.warn('The observable was timed out.');
|
||||||
return of();
|
return of();
|
||||||
}) // Simply return undefined when the timeout is reached.
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +331,12 @@ export interface CustomObjectModel {
|
|||||||
formatted?: string;
|
formatted?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface NostrEventChat extends NostrEvent {
|
||||||
|
about: string;
|
||||||
|
name: string;
|
||||||
|
picture: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class ChatModel {
|
export class ChatModel {
|
||||||
'id': number;
|
'id': number;
|
||||||
'targetUserId': number;
|
'targetUserId': number;
|
||||||
|
@ -427,6 +427,14 @@ export class RelayService {
|
|||||||
this.zapUi.addZap(event);
|
this.zapUi.addZap(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.kind == Kind.ChannelCreation) {
|
||||||
|
this.ui.putChat(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.kind == Kind.ChannelMetadata) {
|
||||||
|
this.ui.putChatMetadata(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (response.subscription) {
|
if (response.subscription) {
|
||||||
const sub = this.subs.get(response.subscription);
|
const sub = this.subs.get(response.subscription);
|
||||||
if (sub) {
|
if (sub) {
|
||||||
|
@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
import { Kind } from 'nostr-tools';
|
import { Kind } from 'nostr-tools';
|
||||||
import { BehaviorSubject, map, Observable, filter, flatMap, mergeMap, concatMap, tap, take, single, takeWhile, from, of } from 'rxjs';
|
import { BehaviorSubject, map, Observable, filter, flatMap, mergeMap, concatMap, tap, take, single, takeWhile, from, of } from 'rxjs';
|
||||||
import { EventService } from './event';
|
import { EventService } from './event';
|
||||||
import { EmojiEnum, LoadMoreOptions, NostrEvent, NostrEventDocument, NostrProfileDocument, NotificationModel, ThreadEntry } from './interfaces';
|
import { EmojiEnum, LoadMoreOptions, NostrEvent, NostrEventChat, NostrEventDocument, NostrProfileDocument, NotificationModel, ThreadEntry } from './interfaces';
|
||||||
import { OptionsService } from './options';
|
import { OptionsService } from './options';
|
||||||
import { ProfileService } from './profile';
|
import { ProfileService } from './profile';
|
||||||
import { ZapService } from './zap.service';
|
import { ZapService } from './zap.service';
|
||||||
@ -26,6 +26,7 @@ export class UIService {
|
|||||||
rootEventsView: [] as NostrEventDocument[],
|
rootEventsView: [] as NostrEventDocument[],
|
||||||
replyEventsView: [] as NostrEventDocument[],
|
replyEventsView: [] as NostrEventDocument[],
|
||||||
reactions: new Map<string, ThreadEntry>(),
|
reactions: new Map<string, ThreadEntry>(),
|
||||||
|
chats: [] as NostrEventChat[],
|
||||||
};
|
};
|
||||||
|
|
||||||
viewCounts = {
|
viewCounts = {
|
||||||
@ -156,6 +157,14 @@ export class UIService {
|
|||||||
// return this.#eventsChanged.asObservable().pipe(map((data) => data.sort((a, b) => (a.created_at > b.created_at ? -1 : 1))));
|
// return this.#eventsChanged.asObservable().pipe(map((data) => data.sort((a, b) => (a.created_at > b.created_at ? -1 : 1))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chats: NostrEventChat[] = [];
|
||||||
|
|
||||||
|
#chatsChanged: BehaviorSubject<NostrEventChat[]> = new BehaviorSubject<NostrEventChat[]>(this.chats);
|
||||||
|
|
||||||
|
get chats$(): Observable<NostrEventChat[]> {
|
||||||
|
return this.#chatsChanged.asObservable();
|
||||||
|
}
|
||||||
|
|
||||||
#loadMore: BehaviorSubject<LoadMoreOptions | undefined> = new BehaviorSubject<LoadMoreOptions | undefined>(undefined);
|
#loadMore: BehaviorSubject<LoadMoreOptions | undefined> = new BehaviorSubject<LoadMoreOptions | undefined>(undefined);
|
||||||
|
|
||||||
get loadMore$(): Observable<LoadMoreOptions | undefined> {
|
get loadMore$(): Observable<LoadMoreOptions | undefined> {
|
||||||
@ -285,6 +294,69 @@ export class UIService {
|
|||||||
this.triggerUnreadNotifications();
|
this.triggerUnreadNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
putChat(event: NostrEvent) {
|
||||||
|
const index = this.chats.findIndex((n) => n.id == event.id);
|
||||||
|
|
||||||
|
if (index == -1) {
|
||||||
|
const chat = event as NostrEventChat;
|
||||||
|
const parsed = JSON.parse(chat.content);
|
||||||
|
|
||||||
|
chat.picture = parsed.picture;
|
||||||
|
chat.name = parsed.name;
|
||||||
|
chat.about = parsed.about;
|
||||||
|
|
||||||
|
this.chats.push(chat);
|
||||||
|
this.#chatsChanged.next(this.chats);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (index == -1) {
|
||||||
|
// this.#notifications.unshift(notification);
|
||||||
|
|
||||||
|
// this.#notifications = this.#notifications.sort((a, b) => {
|
||||||
|
// return a.created < b.created ? 1 : -1;
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// this.#notifications[index] = notification;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.#activityFeed = this.#notifications.slice(0, 5);
|
||||||
|
// this.triggerUnreadNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
putChatMetadata(event: NostrEvent) {
|
||||||
|
const channelId = this.eventService.lastETag(event);
|
||||||
|
|
||||||
|
if (!channelId) {
|
||||||
|
console.debug('This channel metadata does not have eTag:', event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the existing chat creation, but verify both channel ID and the public key.
|
||||||
|
const index = this.chats.findIndex((n) => n.id == channelId && n.pubkey == event.pubkey);
|
||||||
|
|
||||||
|
// TODO: We are subscribing to both 40 and 41 at the same time and we are receiving 41 (metadata updates)
|
||||||
|
// before some of the 40 (create) events, meaning we'll never show the latest metadata for certain chats.
|
||||||
|
if (index == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.chats[index].content = event.content;
|
||||||
|
this.#chatsChanged.next(this.chats);
|
||||||
|
|
||||||
|
// if (index == -1) {
|
||||||
|
// this.#notifications.unshift(notification);
|
||||||
|
|
||||||
|
// this.#notifications = this.#notifications.sort((a, b) => {
|
||||||
|
// return a.created < b.created ? 1 : -1;
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// this.#notifications[index] = notification;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// this.#activityFeed = this.#notifications.slice(0, 5);
|
||||||
|
// this.triggerUnreadNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
viewEventsStart = 0;
|
viewEventsStart = 0;
|
||||||
viewEventsCount = 5;
|
viewEventsCount = 5;
|
||||||
|
|
||||||
@ -709,6 +781,7 @@ export class UIService {
|
|||||||
this.#lists.followingEventsView = [];
|
this.#lists.followingEventsView = [];
|
||||||
|
|
||||||
this.#lists.reactions = new Map<string, ThreadEntry>();
|
this.#lists.reactions = new Map<string, ThreadEntry>();
|
||||||
|
this.#lists.chats = [];
|
||||||
|
|
||||||
this.#notifications = [];
|
this.#notifications = [];
|
||||||
this.#activityFeed = [];
|
this.#activityFeed = [];
|
||||||
@ -766,6 +839,10 @@ export class UIService {
|
|||||||
this.previousFeedSinceValue = 0;
|
this.previousFeedSinceValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearChats() {
|
||||||
|
this.#lists.chats = [];
|
||||||
|
}
|
||||||
|
|
||||||
// #parentEventId: string | undefined = undefined;
|
// #parentEventId: string | undefined = undefined;
|
||||||
|
|
||||||
// get parentEventId() {
|
// get parentEventId() {
|
||||||
|
@ -9,7 +9,7 @@ import { ChatModel, NostrEventDocument } from 'src/app/services/interfaces';
|
|||||||
})
|
})
|
||||||
export class ChatItemComponent {
|
export class ChatItemComponent {
|
||||||
@Output() openChatSidebar: EventEmitter<string> = new EventEmitter();
|
@Output() openChatSidebar: EventEmitter<string> = new EventEmitter();
|
||||||
@Input() chat!: ChatModel;
|
@Input() chat!: ChatModel | any;
|
||||||
@Input() event!: NostrEventDocument;
|
@Input() event!: NostrEventDocument;
|
||||||
|
|
||||||
constructor(private service: ChatService) {}
|
constructor(private service: ChatService) {}
|
||||||
|
@ -18,8 +18,7 @@ export class ChatListComponent implements OnInit {
|
|||||||
constructor(public chatService: ChatService) {}
|
constructor(public chatService: ChatService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.chatService.download();
|
// this.chatService.download();
|
||||||
|
|
||||||
// this.chatService.uniqueChats$.subscribe((data) => {
|
// this.chatService.uniqueChats$.subscribe((data) => {
|
||||||
// console.log('YEEH!', data);
|
// console.log('YEEH!', data);
|
||||||
// });
|
// });
|
||||||
|
35
src/app/shared/message-list/message-list.component.html
Normal file
35
src/app/shared/message-list/message-list.component.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<mat-nav-list>
|
||||||
|
|
||||||
|
<div class="search">
|
||||||
|
<mat-form-field appearance="fill" class="input-full-width">
|
||||||
|
<input matInput type="text" placeholder="Search...">
|
||||||
|
<mat-icon matSuffix>search</mat-icon>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ng-container *ngFor="let chat of chatService.chats$ | async; let lastItem = last">
|
||||||
|
<app-chat-item [routerLink]="['/m', chat.id]" [chat]="chat"></app-chat-item>
|
||||||
|
<mat-divider *ngIf="!lastItem"></mat-divider>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- <ng-container *ngFor="let event of chatService.chats2$ | async; let lastItem = last">
|
||||||
|
<app-chat-item [routerLink]="['/m', '5f432a9f39b58ff132fc0a4c8af10d42efd917d8076f68bb7f2f91ed7d4f6a41']" [event]="event"></app-chat-item>
|
||||||
|
<mat-divider *ngIf="!lastItem"></mat-divider>
|
||||||
|
</ng-container> -->
|
||||||
|
</mat-nav-list>
|
||||||
|
|
||||||
|
<div *ngFor="let chat of chatService.chats3">{{ chat.pubkey }} : {{ chat.content }}</div>
|
||||||
|
|
||||||
|
<!-- <div *ngIf="chatService.uniqueChats$ | async as chats">
|
||||||
|
<div *ngFor="let chat of chats">{{ chat.pubkey }} : {{ chat.content }}</div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<!-- <div *ngIf="chats$ | async as chats">
|
||||||
|
<div *ngFor="let chat of chats">{{ chat.id }} : {{ chat.name }}</div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<button (click)="add()">Add</button>
|
||||||
|
|
||||||
|
<button (click)="reset()">Reset</button>
|
||||||
|
|
||||||
|
<button (click)="chatService.download()">Download</button>
|
15
src/app/shared/message-list/message-list.component.scss
Normal file
15
src/app/shared/message-list/message-list.component.scss
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
.form {
|
||||||
|
padding: 16px 16px 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-full-width {
|
||||||
|
position: relative;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
padding: 10px;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
25
src/app/shared/message-list/message-list.component.spec.ts
Normal file
25
src/app/shared/message-list/message-list.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
|
// import {ChatListComponent} from './chat-list.component';
|
||||||
|
|
||||||
|
// describe('ChatListComponent', () => {
|
||||||
|
// let component: ChatListComponent;
|
||||||
|
// let fixture: ComponentFixture<ChatListComponent>;
|
||||||
|
|
||||||
|
// beforeEach(async(() => {
|
||||||
|
// TestBed.configureTestingModule({
|
||||||
|
// declarations: [ChatListComponent]
|
||||||
|
// })
|
||||||
|
// .compileComponents();
|
||||||
|
// }));
|
||||||
|
|
||||||
|
// beforeEach(() => {
|
||||||
|
// fixture = TestBed.createComponent(ChatListComponent);
|
||||||
|
// component = fixture.componentInstance;
|
||||||
|
// fixture.detectChanges();
|
||||||
|
// });
|
||||||
|
|
||||||
|
// it('should create', () => {
|
||||||
|
// expect(component).toBeTruthy();
|
||||||
|
// });
|
||||||
|
// });
|
35
src/app/shared/message-list/message-list.component.ts
Normal file
35
src/app/shared/message-list/message-list.component.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import { Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
|
||||||
|
import { from, Observable, of } from 'rxjs';
|
||||||
|
import { ChatService } from 'src/app/services/chat.service';
|
||||||
|
|
||||||
|
interface ChatModel {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-message-list',
|
||||||
|
templateUrl: './message-list.component.html',
|
||||||
|
styleUrls: ['./message-list.component.scss'],
|
||||||
|
})
|
||||||
|
export class MessageListComponent implements OnInit {
|
||||||
|
@Output() openChatSidebar: EventEmitter<string> = new EventEmitter();
|
||||||
|
|
||||||
|
constructor(public chatService: ChatService) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.chatService.download();
|
||||||
|
|
||||||
|
// this.chatService.uniqueChats$.subscribe((data) => {
|
||||||
|
// console.log('YEEH!', data);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
add() {
|
||||||
|
// this.#chats.unshift({ id: '123', name: 'Yes!' });
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
// this.#chats = [];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user