Skip to content

Commit

Permalink
fix: do not open minimized chat window when sending message
Browse files Browse the repository at this point in the history
  • Loading branch information
trampi committed Jan 10, 2019
1 parent 337d934 commit fdee840
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
import { Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';
import { Direction } from '../../core';
import { ChatListStateService, ChatWindowState } from '../../services/chat-list-state.service';

@Component({
Expand All @@ -12,19 +14,25 @@ export class ChatWindowComponent implements OnInit, OnDestroy {
@Input()
public chatWindowState: ChatWindowState;

private subscriptions: Subscription[] = [];
private ngDestroy = new Subject<void>();

constructor(private chatListService: ChatListStateService) {
}

ngOnInit() {
this.subscriptions.push(this.chatWindowState.contact.messages$.subscribe(() => {
this.chatWindowState.isCollapsed = false;
}));
this.chatWindowState.contact.messages$
.pipe(
filter(message => message.direction === Direction.in),
takeUntil(this.ngDestroy)
)
.subscribe(() => {
this.chatWindowState.isCollapsed = false;
});
}

ngOnDestroy() {
this.subscriptions.forEach(subscription => subscription.unsubscribe());
this.ngDestroy.next();
this.ngDestroy.complete();
}

public onClickHeader() {
Expand Down

0 comments on commit fdee840

Please sign in to comment.