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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 69x 69x 69x 29x 29x 29x 29x 29x 29x 3x 3x 2x | import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { autorun } from 'mobx';
import { catchError, map, Observable } from 'rxjs';
import { Oembed } from '../../model/oembed';
import { Store } from '../../store/store';
import { params } from '../../util/http';
import { ConfigService } from '../config.service';
import { LoginService } from '../login.service';
@Injectable({
providedIn: 'root'
})
export class OEmbedService {
constructor(
private http: HttpClient,
private config: ConfigService,
private login: LoginService,
private store: Store,
) {
autorun(() => {
Iif (store.eventBus.event === '+plugin/oembed:defaults' || this.store.eventBus.event === '*:defaults') {
this.defaults().subscribe();
}
});
}
private get base() {
return this.config.api + '/api/v1/oembed';
}
get(url: string, theme?: string, maxwidth?: number, maxheight?: number): Observable<Oembed> {
return this.http.get(this.base, {
params: params({
url,
theme,
maxwidth,
maxheight,
}),
}).pipe(
map(t => t as Oembed),
catchError(err => this.login.handleHttpError(err)),
);
}
defaults(): Observable<void> {
return this.http.post<void>(this.base + '/defaults', null).pipe(
catchError(err => this.login.handleHttpError(err)),
);
}
}
|