* Helper function to create a callable function that automatically refreshes the blocked users list. * @param callableName The name of the callable function to create. * @returns A function that can be called to invoke the callable function.
(
callableName: string,
skipRefresh = false,
)
| 79 | * @returns A function that can be called to invoke the callable function. |
| 80 | */ |
| 81 | private asCallable<T, R>( |
| 82 | callableName: string, |
| 83 | skipRefresh = false, |
| 84 | ): (callableArg: T) => Promise<R> { |
| 85 | return async (callableArg: T) => { |
| 86 | try { |
| 87 | const result = await httpsCallable<T, R>(this.functions, callableName)(callableArg); |
| 88 | if (!skipRefresh) { |
| 89 | this.refreshBlockedUsers$.next(); |
| 90 | } |
| 91 | return result.data; |
| 92 | } catch (error) { |
| 93 | const message = error instanceof Error ? error.message : 'Unknown error'; |
| 94 | this.snackBar.open(`Failed to execute ${callableName}: ${message}`, 'Dismiss', { |
| 95 | duration: 5000, |
| 96 | }); |
| 97 | throw error; |
| 98 | } |
| 99 | }; |
| 100 | } |
| 101 | } |
no test coverage detected