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) =>{
4949Object . assign ( appOptions , message . _args [ 0 ] , { port : port } ) ;
5050if ( message . _method == "appReady" ) {
5151appOptions . ready = true ;
52+ if ( appOptions . initData )
53+ setTimeout ( ( ) => {
54+ weh . rpc . call ( app , "wehInitData" , appOptions . initData ) ;
55+ } , 0 ) ;
5256var wait = waiting [ app ] ;
5357if ( wait && wait . timer ) {
5458clearTimeout ( 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 ) {
7983if ( ! apps [ app ] )
8084apps [ 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){
3838url : url ,
3939} )
4040. then ( function ( tab ) {
41- weh . __declareAppTab ( name , tab . id ) ;
41+ weh . __declareAppTab ( name , { tab : tab . id , initData : options . initData } ) ;
4242panels [ name ] = {
4343type : "tab" ,
4444tabId : tab . id
4545}
4646tabs [ 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){
154142return tab ;
155143} )
156144. then ( ( tab ) => {
157- weh . __declareAppTab ( name , tab . id ) ;
145+ weh . __declareAppTab ( name , { tab : tab . id , initData : options . initData } ) ;
158146tabs [ 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