File tree Expand file tree Collapse file tree 7 files changed +45
-11
lines changed
app-frontend/src/features Expand file tree Collapse file tree 7 files changed +45
-11
lines changed Original file line number Diff line number Diff line change @@ -226,20 +226,25 @@ export async function removeApp (app: App, ctx: BackendContext) {
226
226
}
227
227
}
228
228
229
+ let scanTimeout : any
230
+
229
231
// eslint-disable-next-line camelcase
230
- export function _legacy_getAndRegisterApps ( ctx : BackendContext ) {
232
+ export function _legacy_getAndRegisterApps ( ctx : BackendContext , clear = false ) {
231
233
setTimeout ( ( ) => {
232
- // Remove apps that are legacy
233
- ctx . appRecords . forEach ( appRecord => {
234
- if ( appRecord . meta . Vue ) {
235
- removeAppRecord ( appRecord , ctx )
236
- }
237
- } )
234
+ if ( clear ) {
235
+ // Remove apps that are legacy
236
+ ctx . appRecords . forEach ( appRecord => {
237
+ if ( appRecord . meta . Vue ) {
238
+ removeAppRecord ( appRecord , ctx )
239
+ }
240
+ } )
241
+ }
238
242
239
243
const apps = scan ( )
240
244
245
+ clearTimeout ( scanTimeout )
241
246
if ( ! apps . length ) {
242
- setTimeout ( ( ) => _legacy_getAndRegisterApps ( ctx ) , 1000 )
247
+ scanTimeout = setTimeout ( ( ) => _legacy_getAndRegisterApps ( ctx ) , 1000 )
243
248
}
244
249
245
250
apps . forEach ( app => {
Original file line number Diff line number Diff line change @@ -59,12 +59,15 @@ export async function initBackend (bridge: Bridge) {
59
59
hook,
60
60
} )
61
61
62
+ SharedData . legacyApps = false
62
63
if ( hook . Vue ) {
63
64
connect ( )
64
- _legacy_getAndRegisterApps ( ctx )
65
+ _legacy_getAndRegisterApps ( ctx , true )
66
+ SharedData . legacyApps = true
65
67
}
66
68
hook . on ( HookEvents . INIT , ( ) => {
67
- _legacy_getAndRegisterApps ( ctx )
69
+ _legacy_getAndRegisterApps ( ctx , true )
70
+ SharedData . legacyApps = true
68
71
} )
69
72
70
73
hook . on ( HookEvents . APP_ADD , async app => {
@@ -356,6 +359,12 @@ function connectBridge () {
356
359
}
357
360
} )
358
361
362
+ ctx . bridge . on ( BridgeEvents . TO_BACK_SCAN_LEGACY_APPS , ( ) => {
363
+ if ( hook . Vue ) {
364
+ _legacy_getAndRegisterApps ( ctx )
365
+ }
366
+ } )
367
+
359
368
// Components
360
369
361
370
ctx . bridge . on ( BridgeEvents . TO_BACK_COMPONENT_TREE , ( { instanceId, filter } ) => {
Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ export function waitForAppSelect (): Promise<void> {
85
85
}
86
86
}
87
87
88
+ export function scanLegacyApps ( ) {
89
+ getBridge ( ) . send ( BridgeEvents . TO_BACK_SCAN_LEGACY_APPS , { } )
90
+ }
91
+
88
92
export function setupAppsBridgeEvents ( bridge : Bridge ) {
89
93
bridge . on ( BridgeEvents . TO_FRONT_APP_ADD , ( { appRecord } ) => {
90
94
addApp ( appRecord )
Original file line number Diff line number Diff line change @@ -197,6 +197,8 @@ export default defineComponent({
197
197
@mouseleave =" queueClose()"
198
198
@wheel =" onMouseWheel"
199
199
>
200
+ <slot name =" before" />
201
+
200
202
<VueDropdownButton
201
203
v-for =" (item, index) of items"
202
204
:key =" index"
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import AppSelectItem from './AppSelectItem.vue'
4
4
5
5
import { watch , defineComponent , computed } from ' @vue/composition-api'
6
6
import { BridgeEvents , SharedData } from ' @vue-devtools/shared-utils'
7
- import { useApps , pendingSelectAppId } from ' @front/features/apps'
7
+ import { useApps , pendingSelectAppId , scanLegacyApps } from ' @front/features/apps'
8
8
import { useOrientation } from ' @front/features/layout/orientation'
9
9
import { useRouter } from ' @front/util/router'
10
10
import { useBridge } from ' ../bridge'
@@ -72,6 +72,7 @@ export default defineComponent({
72
72
selectApp ,
73
73
orientation ,
74
74
hasNewVueVersion ,
75
+ scanLegacyApps ,
75
76
}
76
77
},
77
78
})
@@ -119,6 +120,17 @@ export default defineComponent({
119
120
:app =" item"
120
121
/>
121
122
</template >
123
+
124
+ <template #before >
125
+ <VueButton
126
+ v-if =" $shared.legacyApps"
127
+ class =" flat m-1"
128
+ icon-left =" cached"
129
+ @click =" scanLegacyApps()"
130
+ >
131
+ Scan apps
132
+ </VueButton >
133
+ </template >
122
134
</AppHeaderSelect >
123
135
</template >
124
136
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export enum BridgeEvents {
28
28
TO_FRONT_APP_REMOVE = 'f:app:remove' ,
29
29
TO_BACK_APP_SELECT = 'b:app:select' ,
30
30
TO_FRONT_APP_SELECTED = 'f:app:selected' ,
31
+ TO_BACK_SCAN_LEGACY_APPS = 'b:app:scan-legacy' ,
31
32
32
33
// Components
33
34
TO_BACK_COMPONENT_TREE = 'b:component:tree' ,
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const internalSharedData = {
27
27
pluginPermissions : { } as any ,
28
28
pluginSettings : { } as any ,
29
29
pageConfig : { } as any ,
30
+ legacyApps : false ,
30
31
debugInfo : false ,
31
32
}
32
33
You can’t perform that action at this time.
0 commit comments