diff --git a/src/app/chat/data-access/chat-state.service.ts b/src/app/chat/data-access/chat-state.service.ts index 645215b8..91d4ced4 100644 --- a/src/app/chat/data-access/chat-state.service.ts +++ b/src/app/chat/data-access/chat-state.service.ts @@ -10,6 +10,7 @@ import { chatStateAdapter } from './chat-state.adapter'; import { TimerService } from '@shared/util/time/timer.service'; import { startWith } from 'rxjs/operators'; import { ActivatedRoute } from '@angular/router'; +import { AuthStorageService } from '@shared/data-access/auth/auth-storage.service'; export type SingleChatState = { id: string; @@ -27,13 +28,15 @@ export type ChatAdaptState = { newMessageSent: boolean; }; -@Injectable({ - providedIn: 'root', -}) +@Injectable() export class ChatStateService { private readonly storePath = 'chat'; private activatedRoute = inject(ActivatedRoute); + private authStorageService = inject(AuthStorageService); + private userLoggedOut$ = this.authStorageService.hasLoggedOut$.pipe( + toSource('[Chat] userLoggedOut') + ); // either we have a chat open with that DancerId or we create a new one // TODO: logic can possibly be simplified when we do this only after the initial fetch openChatWith$ = this.activatedRoute.queryParams.pipe( @@ -71,7 +74,7 @@ export class ChatStateService { const fetchChatsSources = getRequestSources( '[Chat] fetchChats', merge( - timerService.interval('chatFetchTrigger', 5000), + timerService.interval('chatFetchTrigger', 20000), store.chatCreated$.pipe(filter((hasCreated) => !!hasCreated)) ).pipe( startWith(-1), @@ -158,6 +161,7 @@ export class ChatStateService { chatCreatedError: createChatSource.error$, messageSent: sendMessageSource.success$, messageSentError: sendMessageSource.error$, + reset: this.userLoggedOut$, }; } ); diff --git a/src/app/chat/feature/chat-page/chat-page.component.ts b/src/app/chat/feature/chat-page/chat-page.component.ts index 1d5c17df..bcae4847 100644 --- a/src/app/chat/feature/chat-page/chat-page.component.ts +++ b/src/app/chat/feature/chat-page/chat-page.component.ts @@ -8,11 +8,12 @@ import { ChatConversationListComponent } from '../../ui/conversation-list/chat-c import { AsyncPipe, NgFor, NgIf } from '@angular/common'; import { ChatStateService } from '../../data-access/chat-state.service'; import { ChatConversationHeaderComponent } from '../../ui/chat-conversation-header.component'; +import { interval, take } from 'rxjs'; @Component({ selector: 'app-chat-page', template: ` -
+

Deine Chats

@@ -21,7 +22,7 @@ import { ChatConversationHeaderComponent } from '../../ui/chat-conversation-head >
- +
@@ -84,7 +90,7 @@ import { ChatConversationHeaderComponent } from '../../ui/chat-conversation-head
`, styleUrls: ['./chat-page.component.scss'], - providers: [], + providers: [ChatStateService], changeDetection: ChangeDetectionStrategy.Default, standalone: true, imports: [ @@ -101,4 +107,5 @@ import { ChatConversationHeaderComponent } from '../../ui/chat-conversation-head }) export class ChatPageComponent { chatState = inject(ChatStateService); + delayLoading$ = interval(100).pipe(take(1)); } diff --git a/src/app/chat/ui/chat-messages/chat-messages.component.ts b/src/app/chat/ui/chat-messages/chat-messages.component.ts index 6f8673c4..aa4190d2 100644 --- a/src/app/chat/ui/chat-messages/chat-messages.component.ts +++ b/src/app/chat/ui/chat-messages/chat-messages.component.ts @@ -19,7 +19,7 @@ import { map } from 'rxjs'; template: `
@@ -33,6 +33,13 @@ import { map } from 'rxjs'; 'self-end': message.authorId === ownUserId() }" > +
+

Noch gibt es hier nichts zu sehen

+

Schreibe jetzt deine erste Nachricht

+
`, diff --git a/src/app/chat/ui/chat-messages/chat-single-message.component.ts b/src/app/chat/ui/chat-messages/chat-single-message.component.ts index 13fa2ccc..dab48622 100644 --- a/src/app/chat/ui/chat-messages/chat-single-message.component.ts +++ b/src/app/chat/ui/chat-messages/chat-single-message.component.ts @@ -10,7 +10,7 @@ import { NgClass, NgIf } from '@angular/common'; class="rounded-3xl px-6 py-3 drop-shadow" [ngClass]="{ 'rounded-br-none bg-green-100': isOwnMessage, - 'rounded-tl-none bg-white': !isOwnMessage + 'rounded-bl-none bg-white': !isOwnMessage }" > {{ message.text }} diff --git a/src/app/chat/ui/conversation-list/chat-conversation-list-entry.component.ts b/src/app/chat/ui/conversation-list/chat-conversation-list-entry.component.ts index 4a6a07b5..d07a9626 100644 --- a/src/app/chat/ui/conversation-list/chat-conversation-list-entry.component.ts +++ b/src/app/chat/ui/conversation-list/chat-conversation-list-entry.component.ts @@ -25,19 +25,22 @@ import { Profile } from '../../../profile/data-access/types/profile.types';
-
+
}>; @Component({ selector: 'app-chat-message-composer', template: ` -
+ authData.isLoggedIn), + filter((authData) => !authData.isLoggedIn) + ); + constructor() {} private static initFromLocalStorage(): AuthData {