Skip to content

Minor additions #2921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compat/performance/performance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApplicationRef, Injectable, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { first, tap } from 'rxjs/operators';

const IS_STABLE_START_MARK = '_isStableStart';
const IS_STABLE_START_MARK = 'Zone';
const IS_STABLE_END_MARK = '_isStableEnd';

function markStarts() {
Expand Down
12 changes: 9 additions & 3 deletions src/compat/storage/pipes/storageUrl.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { AsyncPipe } from '@angular/common';
import { ChangeDetectorRef, NgModule, OnDestroy, Pipe, PipeTransform } from '@angular/core';
import { Observable } from 'rxjs';
import { makeStateKey, TransferState } from '@angular/platform-browser';
import { Observable, of } from 'rxjs';
import { tap } from 'rxjs/operators';
import { AngularFireStorage } from '../storage';

/** to be used with in combination with | async */
Expand All @@ -14,14 +16,18 @@ export class GetDownloadURLPipe implements PipeTransform, OnDestroy {
private path: string;
private downloadUrl$: Observable<any>;

constructor(private storage: AngularFireStorage, cdr: ChangeDetectorRef) {
constructor(private storage: AngularFireStorage, cdr: ChangeDetectorRef, private state: TransferState) {
this.asyncPipe = new AsyncPipe(cdr);
}

transform(path: string) {
if (path !== this.path) {
this.path = path;
this.downloadUrl$ = this.storage.ref(path).getDownloadURL();
const key = makeStateKey<string>(`|getDownloadURL|${path}`);
const existing = this.state.get(key, undefined);
this.downloadUrl$ = existing ? of(existing) : this.storage.ref(path).getDownloadURL().pipe(
tap(it => this.state.set(key, it))
);
}
return this.asyncPipe.transform(this.downloadUrl$);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compat/storage/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface AngularFireStorageReference {
getDownloadURL(): Observable<any>;
getMetadata(): Observable<any>;
delete(): Observable<any>;
child(path: string): any;
child(path: string): AngularFireStorageReference;
updateMetadata(meta: SettableMetadata): Observable<any>;
put(data: any, metadata?: UploadMetadata | undefined): AngularFireUploadTask;
putString(data: string, format?: string | undefined, metadata?: UploadMetadata | undefined): AngularFireUploadTask;
Expand Down