File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -19,31 +19,29 @@ async function fallbackDefaultSettings() {
1919 }
2020}
2121
22+ let rimeLoaded = false ;
2223self . controller = new InputController ( ) ;
2324chrome . storage . sync . get ( [ "settings" ] ) . then ( async ( obj ) => {
2425 // Only load engine if settings exists
2526 if ( obj . settings ) {
2627 const ok = await self . controller . loadRime ( false ) ;
27- if ( ! ok ) {
28- await fallbackDefaultSettings ( ) ;
29- }
30- await globalPrepare ( ) ;
28+ rimeLoaded = ok ;
3129 }
32- } )
30+ } ) . catch ( ( e ) => {
31+ console . error ( 'load settings error' , e ) ;
32+ } ) . finally ( async ( ) => {
33+ if ( ! rimeLoaded ) {
34+ await fallbackDefaultSettings ( ) ;
35+ }
36+ await postLoad ( ) ;
37+ } ) ;
3338
3439chrome . input . ime . onActivate . addListener ( async ( engineId , screen ) => {
3540 self . controller . engineId = engineId ;
3641 serviceWorkerKeepalive ( ) ;
3742} ) ;
3843
39- chrome . runtime . onInstalled . addListener ( async ( d ) => {
40- if ( d . reason == chrome . runtime . OnInstalledReason . INSTALL ) {
41- await fallbackDefaultSettings ( ) ;
42- await globalPrepare ( ) ;
43- }
44- } )
45-
46- const globalPrepare = async ( ) => {
44+ const postLoad = async ( ) => {
4745 chrome . input . ime . onFocus . addListener ( async ( context ) => {
4846 // Todo: in incoginto tab, context.shouldDoLearning = false,
4947 // we should disable rime learning in such context
You can’t perform that action at this time.
0 commit comments