File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -51,14 +51,12 @@ export function getMessagingInWindow(app: FirebaseApp = getApp()): Messaging {
51
51
// special handling.
52
52
isWindowSupported ( )
53
53
. then ( isSupported => {
54
+ // If `isWindowSupported()` resolved, but returned false.
54
55
if ( ! isSupported ) {
55
56
throw ERROR_FACTORY . create ( ErrorCode . UNSUPPORTED_BROWSER ) ;
56
57
}
57
- } )
58
- . catch ( ( e : Error ) => {
59
- if ( e . message . includes ( ErrorCode . UNSUPPORTED_BROWSER ) ) {
60
- throw e ;
61
- }
58
+ } , _ => {
59
+ // If `isWindowSupported()` rejected.
62
60
throw ERROR_FACTORY . create ( ErrorCode . INDEXED_DB_UNSUPPORTED ) ;
63
61
} ) ;
64
62
return _getProvider ( getModularInstance ( app ) , 'messaging' ) . getImmediate ( ) ;
@@ -77,17 +75,15 @@ export function getMessagingInSw(app: FirebaseApp = getApp()): Messaging {
77
75
// developer's information. Developers can then choose to import and call `isSupported` for
78
76
// special handling.
79
77
isSwSupported ( )
80
- . then ( isSupported => {
81
- if ( ! isSupported ) {
82
- throw ERROR_FACTORY . create ( ErrorCode . UNSUPPORTED_BROWSER ) ;
83
- }
84
- } )
85
- . catch ( ( e : Error ) => {
86
- if ( e . message . includes ( ErrorCode . UNSUPPORTED_BROWSER ) ) {
87
- throw e ;
88
- }
89
- throw ERROR_FACTORY . create ( ErrorCode . INDEXED_DB_UNSUPPORTED ) ;
90
- } ) ;
78
+ . then ( isSupported => {
79
+ // If `isSwSupported()` resolved, but returned false.
80
+ if ( ! isSupported ) {
81
+ throw ERROR_FACTORY . create ( ErrorCode . UNSUPPORTED_BROWSER ) ;
82
+ }
83
+ } , _ => {
84
+ // If `isSwSupported()` rejected.
85
+ throw ERROR_FACTORY . create ( ErrorCode . INDEXED_DB_UNSUPPORTED ) ;
86
+ } ) ;
91
87
return _getProvider ( getModularInstance ( app ) , 'messaging-sw' ) . getImmediate ( ) ;
92
88
}
93
89
You can’t perform that action at this time.
0 commit comments