File tree Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ browser.runtime.onConnect.addListener((port) => {
49
49
Object . assign ( appOptions , message . _args [ 0 ] , { port : port } ) ;
50
50
if ( message . _method == "appReady" ) {
51
51
appOptions . ready = true ;
52
+ if ( appOptions . initData )
53
+ setTimeout ( ( ) => {
54
+ weh . rpc . call ( app , "wehInitData" , appOptions . initData ) ;
55
+ } , 0 ) ;
52
56
var wait = waiting [ app ] ;
53
57
if ( wait && wait . timer ) {
54
58
clearTimeout ( wait . timer ) ;
@@ -75,12 +79,10 @@ browser.runtime.onConnect.addListener((port) => {
75
79
} ) ;
76
80
} ) ;
77
81
78
- weh . __declareAppTab = function ( app , tabId ) {
82
+ weh . __declareAppTab = function ( app , data ) {
79
83
if ( ! apps [ app ] )
80
84
apps [ app ] = { } ;
81
- Object . assign ( apps [ app ] , {
82
- tab : tabId
83
- } ) ;
85
+ Object . assign ( apps [ app ] , data ) ;
84
86
}
85
87
86
88
weh . __closeByTab = function ( tabId ) {
Original file line number Diff line number Diff line change @@ -38,24 +38,12 @@ function OpenTab(name,options) {
38
38
url : url ,
39
39
} )
40
40
. then ( function ( tab ) {
41
- weh . __declareAppTab ( name , tab . id ) ;
41
+ weh . __declareAppTab ( name , { tab : tab . id , initData : options . initData } ) ;
42
42
panels [ name ] = {
43
43
type : "tab" ,
44
44
tabId : tab . id
45
45
}
46
46
tabs [ tab . id ] = name ;
47
- if ( options . initData ) {
48
- return new Promise ( ( resolve , reject ) => {
49
- const onUpdated = ( tabId , changeInfo ) => {
50
- if ( tabId == tab . id && changeInfo . status == "complete" ) {
51
- weh . rpc . call ( name , "wehInitData" , options . initData )
52
- . then ( resolve , reject ) ;
53
- browser . tabs . onUpdated . removeListener ( onUpdated ) ;
54
- }
55
- }
56
- browser . tabs . onUpdated . addListener ( onUpdated ) ;
57
- } )
58
- }
59
47
} ) ;
60
48
} )
61
49
. then ( resolve )
@@ -154,10 +142,8 @@ function CreatePanel(name,options) {
154
142
return tab ;
155
143
} )
156
144
. then ( ( tab ) => {
157
- weh . __declareAppTab ( name , tab . id ) ;
145
+ weh . __declareAppTab ( name , { tab : tab . id , initData : options . initData } ) ;
158
146
tabs [ tab . id ] = name ;
159
- if ( options . initData )
160
- return weh . rpc . call ( name , "wehInitData" , options . initData ) ;
161
147
} ) . then ( resolve )
162
148
. catch ( reject ) ;
163
149
You can’t perform that action at this time.
0 commit comments