This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createInCache<ReadQueryResponseT>( | |
toCreate: EntityObject, | |
readQuery: DocumentNode, | |
cache: ApolloCache<any>, | |
entityName: keyof ReadQueryResponseT | |
) { | |
const existingEntities = cache.readQuery< | |
Record<keyof ReadQueryResponseT, EntityObject[]> | |
>({ | |
query: readQuery, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface EntityObject { | |
id: string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloCache } from '@apollo/client/core'; | |
import { DocumentNode } from 'graphql'; | |
export interface EntityObject { | |
id: string; | |
} | |
export function createInCache<ReadQueryResponseT>( | |
toCreate: EntityObject, | |
readQuery: DocumentNode, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
For avoiding clicks on mouse up after HammerJS long press. | |
This event is triggered right before (click) to ensure we will not trigger click on long press. | |
*/ | |
preventClickAfterLongPress(event: MouseEvent) { | |
const element = event.target as HTMLElement; | |
// needs to add class directly so it is applied before click event | |
element.classList.add('prevent-pointer-events'); | |
setTimeout(() => { | |
element.classList.remove('prevent-pointer-events'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private getTrustedVideoUrl(url: string): SafeResourceUrl { | |
// Url domains are whitelisted using CSP header | |
// Content-Security-Policy: frame-src <source> <source>; | |
const sanitizedUrl = this.sanitizer.sanitize( | |
SecurityContext.URL, | |
url | |
); | |
return this.sanitizer.bypassSecurityTrustResourceUrl(sanitizedUrl); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private getTrustedVideoUrl(url: string): SafeResourceUrl { | |
// Url domains are whitelisted using CSP header | |
// Content-Security-Policy: frame-src <source> <source>; | |
const sanitizedUrl = this.sanitizer.sanitize( | |
SecurityContext.RESOURCE_URL, | |
url | |
); | |
return this.sanitizer.bypassSecurityTrustResourceUrl(sanitizedUrl); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({ providedIn: 'root' }) | |
export class SchoolIdResolver implements Resolve<null> { | |
constructor(private courseFacadeService: CourseFacadeService) {} | |
resolve( | |
route: ActivatedRouteSnapshot | |
): Observable<null> | Promise<null> | null { | |
const schoolId = route.params.schoolId; | |
auth().tenantId = schoolId; | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setLessonCompleted: ( | |
parent, | |
{ uid, lessonId, isCompleted }, | |
context: RequestContext | |
) => { | |
if (!context.auth.admin && uid !== context.auth.uid) { | |
throw new AuthenticationError('User is not admin or user'); | |
} | |
return firestoreDB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const routes: Routes = [ | |
{ | |
path: ':schoolId', | |
resolve: [SchoolIdResolver], | |
children: [ | |
{ | |
path: '', | |
pathMatch: 'full', | |
redirectTo: 'courses' | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({ providedIn: 'root' }) | |
export class SetTokenInterceptor implements HttpInterceptor { | |
constructor(private userService: UserService) {} | |
intercept( | |
req: HttpRequest<any>, | |
next: HttpHandler | |
): Observable<HttpEvent<any>> { | |
if (!this.userService.currentUser$.value) { | |
return next.handle(req); |