refactor(service-worker): removing some todos (#48707)

Removing some outdated/unnecessary todos.

PR Close #48707
This commit is contained in:
Matthieu Riegler 2023-01-11 23:40:04 +01:00 committed by Jessica Janiuk
parent 82c8b7ae9e
commit f2c8ac5335
5 changed files with 6 additions and 11 deletions

View file

@ -132,8 +132,7 @@ export class SwPush {
return this.sw.isEnabled;
}
// TODO(issue/24571): remove '!'.
private pushManager!: Observable<PushManager>;
private pushManager: Observable<PushManager>|null = null;
private subscriptionChanges = new Subject<PushSubscription|null>();
constructor(private sw: NgswCommChannel) {
@ -163,7 +162,7 @@ export class SwPush {
* @returns A Promise that resolves to the new subscription object.
*/
requestSubscription(options: {serverPublicKey: string}): Promise<PushSubscription> {
if (!this.sw.isEnabled) {
if (!this.sw.isEnabled || this.pushManager === null) {
return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));
}
const pushOptions: PushSubscriptionOptionsInit = {userVisibleOnly: true};

View file

@ -129,7 +129,6 @@ export class MockCache {
async match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response> {
let url = this.getRequestUrl(request);
// TODO: cleanup typings. Typescript doesn't know this can resolve to undefined.
let res = this.cache.get(url);
if (!res && options?.ignoreSearch) {
// check if cache has url by ignoring search

View file

@ -26,8 +26,7 @@ export class MockClient implements Client {
export class MockWindowClient extends MockClient implements WindowClient {
readonly focused: boolean = false;
// TODO(crisbeto): change the type here to DocumentVisibilityState when we drop support for TS 4.5
readonly visibilityState: 'visible'|'hidden' = 'visible';
readonly visibilityState: DocumentVisibilityState = 'visible';
constructor(id: string, url: string, frameType: FrameType = 'top-level') {
super(id, url, 'window', frameType);

View file

@ -127,8 +127,7 @@ export class MockServerState {
private requests: Request[] = [];
private gate: Promise<void> = Promise.resolve();
private resolve: Function|null = null;
// TODO(issue/24571): remove '!'.
private resolveNextRequest!: Function;
private resolveNextRequest?: Function;
online = true;
nextRequest: Promise<Request>;
@ -139,7 +138,7 @@ export class MockServerState {
}
async fetch(req: Request): Promise<Response> {
this.resolveNextRequest(req);
this.resolveNextRequest?.(req);
this.nextRequest = new Promise(resolve => {
this.resolveNextRequest = resolve;
});

View file

@ -51,8 +51,7 @@ export class SwTestHarnessImpl extends Adapter<MockCacheStorage> implements
private selfMessageQueue: any[] = [];
autoAdvanceTime = false;
// TODO(issue/24571): remove '!'.
unregistered!: boolean;
unregistered: boolean = false;
readonly notifications: {title: string, options: Object}[] = [];
readonly registration: ServiceWorkerRegistration = {
active: {