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) => {
4949 Object . assign ( appOptions , message . _args [ 0 ] , { port : port } ) ;
5050 if ( message . _method == "appReady" ) {
5151 appOptions . ready = true ;
52+ if ( appOptions . initData )
53+ setTimeout ( ( ) => {
54+ weh . rpc . call ( app , "wehInitData" , appOptions . initData ) ;
55+ } , 0 ) ;
5256 var wait = waiting [ app ] ;
5357 if ( wait && wait . timer ) {
5458 clearTimeout ( wait . timer ) ;
@@ -75,12 +79,10 @@ browser.runtime.onConnect.addListener((port) => {
7579 } ) ;
7680} ) ;
7781
78- weh . __declareAppTab = function ( app , tabId ) {
82+ weh . __declareAppTab = function ( app , data ) {
7983 if ( ! apps [ app ] )
8084 apps [ app ] = { } ;
81- Object . assign ( apps [ app ] , {
82- tab : tabId
83- } ) ;
85+ Object . assign ( apps [ app ] , data ) ;
8486}
8587
8688weh . __closeByTab = function ( tabId ) {
Original file line number Diff line number Diff line change @@ -38,24 +38,12 @@ function OpenTab(name,options) {
3838 url : url ,
3939 } )
4040 . then ( function ( tab ) {
41- weh . __declareAppTab ( name , tab . id ) ;
41+ weh . __declareAppTab ( name , { tab : tab . id , initData : options . initData } ) ;
4242 panels [ name ] = {
4343 type : "tab" ,
4444 tabId : tab . id
4545 }
4646 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- }
5947 } ) ;
6048 } )
6149 . then ( resolve )
@@ -154,10 +142,8 @@ function CreatePanel(name,options) {
154142 return tab ;
155143 } )
156144 . then ( ( tab ) => {
157- weh . __declareAppTab ( name , tab . id ) ;
145+ weh . __declareAppTab ( name , { tab : tab . id , initData : options . initData } ) ;
158146 tabs [ tab . id ] = name ;
159- if ( options . initData )
160- return weh . rpc . call ( name , "wehInitData" , options . initData ) ;
161147 } ) . then ( resolve )
162148 . catch ( reject ) ;
163149
You can’t perform that action at this time.
0 commit comments