@@ -4,7 +4,11 @@ import disconnectWallet from './disconnect'
4
4
import setChain from './chain'
5
5
import { state } from './store'
6
6
import { reset$ } from './streams'
7
- import { validateInitOptions , validateNotify , validateNotifyOptions } from './validation'
7
+ import {
8
+ validateInitOptions ,
9
+ validateNotify ,
10
+ validateNotifyOptions
11
+ } from './validation'
8
12
import initI18N from './i18n'
9
13
import App from './views/Index.svelte'
10
14
import type { InitOptions , OnboardAPI , Notify } from './types'
@@ -106,11 +110,11 @@ function init(options: InitOptions): OnboardAPI {
106
110
if ( typeof notify !== 'undefined' ) {
107
111
if ( 'desktop' in notify || 'mobile' in notify ) {
108
112
const error = validateNotifyOptions ( notify )
109
-
113
+
110
114
if ( error ) {
111
115
throw error
112
116
}
113
-
117
+
114
118
if (
115
119
( ! notify . desktop || ( notify . desktop && ! notify . desktop . position ) ) &&
116
120
accountCenter &&
@@ -128,6 +132,7 @@ function init(options: InitOptions): OnboardAPI {
128
132
notify . mobile . position = accountCenter . mobile . position
129
133
}
130
134
let notifyUpdate : Partial < Notify >
135
+
131
136
if ( device . type === 'mobile' && notify . mobile ) {
132
137
notifyUpdate = {
133
138
...APP_INITIAL_STATE . notify ,
@@ -139,15 +144,34 @@ function init(options: InitOptions): OnboardAPI {
139
144
...notify . desktop
140
145
}
141
146
}
147
+ if ( ! apiKey || ! notifyUpdate . enabled ) {
148
+ notifyUpdate . enabled = false
149
+ }
142
150
updateNotify ( notifyUpdate )
143
151
} else {
144
152
const error = validateNotify ( notify as Notify )
145
-
153
+
146
154
if ( error ) {
147
155
throw error
148
156
}
149
- updateNotify ( notify as Notify )
157
+ const notifyUpdate : Partial < Notify > = {
158
+ ...APP_INITIAL_STATE . notify ,
159
+ ...notify
160
+ }
161
+
162
+ if ( ! apiKey || ! notifyUpdate . enabled ) {
163
+ notifyUpdate . enabled = false
164
+ }
165
+ console . log ( notifyUpdate )
166
+ updateNotify ( notifyUpdate )
167
+ }
168
+ } else {
169
+ const notifyUpdate : Partial < Notify > = APP_INITIAL_STATE . notify
170
+
171
+ if ( ! apiKey ) {
172
+ notifyUpdate . enabled = false
150
173
}
174
+ updateNotify ( notifyUpdate )
151
175
}
152
176
153
177
if ( svelteInstance ) {
0 commit comments