All files / src/app/extensions/copilot-embedded/facades copilot-embedded.facade.ts

83.33% Statements 10/12
100% Branches 0/0
33.33% Functions 1/3
81.81% Lines 9/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 287x 7x         7x 7x 7x     7x 4x   4x     4x                    
import { Injectable } from '@angular/core';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs';
 
import { CopilotEmbeddedChat } from '../models/copilot-embedded-chat/copilot-embedded-chat.model';
import { CopilotEmbeddedConfig } from '../models/copilot-embedded-config/copilot-embedded-config.model';
import { copilotEmbeddedChatActions } from '../store/copilot-embedded-chat/copilot-embedded-chat.actions';
import { getCopilotEmbeddedChat } from '../store/copilot-embedded-chat/copilot-embedded-chat.selectors';
import { getCopilotEmbeddedConfig } from '../store/copilot-embedded-config/copilot-embedded-config.selectors';
 
@Injectable({ providedIn: 'root' })
export class CopilotEmbeddedFacade {
  constructor(private store: Store) {}
 
  configuration$: Observable<CopilotEmbeddedConfig> = this.store.pipe(select(getCopilotEmbeddedConfig));
 
  /** The persisted conversation, restored from the browser storage according to `dataRetention.copilotEmbedded`. */
  chat$: Observable<CopilotEmbeddedChat> = this.store.pipe(select(getCopilotEmbeddedChat));
 
  setChat(chat: CopilotEmbeddedChat) {
    this.store.dispatch(copilotEmbeddedChatActions.setCopilotEmbeddedChat({ chat }));
  }
 
  resetChat() {
    this.store.dispatch(copilotEmbeddedChatActions.resetCopilotEmbeddedChat());
  }
}