Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type contactPredicate = (contact: Contact) => boolean;
- type contactLike = Contact | string | SelectedContact;
- @Injectable()
- export class ContactService {
- private selectedContactId: string = '';
- public selectedContactSubject: BehaviorSubject<contactLike>;
- public get SelectedContact(): contactLike {
- const contact: Contact = this.contactList.find((v) => v.Id === this.selectedContactId);
- return contact ? contact : null;
- }
- public set SelectedContact(value: contactLike) {
- this.selectedContactId = typeof value === 'string' ? value as string : value.Id;
- this.selectedContactSubject.next(this.findContact(this.selectedContactId));
- }
- constructor() {
- this.selectedContactSubject = new BehaviorSubject<Contact>(this.findContact(this.selectedContactId));
- }
- }
- import { ContactService } from './contact.service';
- @Injectable()
- export class FileService {
- constructor(
- private httpServiceProvider: HttpServiceProvider,
- private userService: UserService,
- private contactService: ContactService) {
- }
- getFiles(fileType: string, contactType: ContactType, skip: number, pageSize: number, organisationId: string): Observable<any> {
- let myUserId = this.userService.userId;
- let selectedContact: SelectedContact;
- this.contactService.selectedContactSubject.subscribe(v => {
- selectedContact = (v as SelectedContact);
- });
- let selectedContactId = selectedContact.Id;
- let params: HttpParams = new HttpParams();
- params = params.set('category', fileType)
- .append('senderId', myUserId)
- .append('receiverId', selectedContactId)
- .append('Skip', skip.toString())
- .append('PageSize', pageSize.toString())
- .append('contactType', String(contactType))
- .append('organisationId', organisationId);
- return this.httpServiceProvider.httpGet(CONFIGURATION.GetFiles.url, params);
- }
- }
Add Comment
Please, Sign In to add comment