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) {
226226 }
227227}
228228
229+ let scanTimeout : any
230+
229231// eslint-disable-next-line camelcase
230- export function _legacy_getAndRegisterApps ( ctx : BackendContext ) {
232+ export function _legacy_getAndRegisterApps ( ctx : BackendContext , clear = false ) {
231233 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+ }
238242
239243 const apps = scan ( )
240244
245+ clearTimeout ( scanTimeout )
241246 if ( ! apps . length ) {
242- setTimeout ( ( ) => _legacy_getAndRegisterApps ( ctx ) , 1000 )
247+ scanTimeout = setTimeout ( ( ) => _legacy_getAndRegisterApps ( ctx ) , 1000 )
243248 }
244249
245250 apps . forEach ( app => {
Original file line number Diff line number Diff line change @@ -59,12 +59,15 @@ export async function initBackend (bridge: Bridge) {
5959 hook,
6060 } )
6161
62+ SharedData . legacyApps = false
6263 if ( hook . Vue ) {
6364 connect ( )
64- _legacy_getAndRegisterApps ( ctx )
65+ _legacy_getAndRegisterApps ( ctx , true )
66+ SharedData . legacyApps = true
6567 }
6668 hook . on ( HookEvents . INIT , ( ) => {
67- _legacy_getAndRegisterApps ( ctx )
69+ _legacy_getAndRegisterApps ( ctx , true )
70+ SharedData . legacyApps = true
6871 } )
6972
7073 hook . on ( HookEvents . APP_ADD , async app => {
@@ -356,6 +359,12 @@ function connectBridge () {
356359 }
357360 } )
358361
362+ ctx . bridge . on ( BridgeEvents . TO_BACK_SCAN_LEGACY_APPS , ( ) => {
363+ if ( hook . Vue ) {
364+ _legacy_getAndRegisterApps ( ctx )
365+ }
366+ } )
367+
359368 // Components
360369
361370 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> {
8585 }
8686}
8787
88+ export function scanLegacyApps ( ) {
89+ getBridge ( ) . send ( BridgeEvents . TO_BACK_SCAN_LEGACY_APPS , { } )
90+ }
91+
8892export function setupAppsBridgeEvents ( bridge : Bridge ) {
8993 bridge . on ( BridgeEvents . TO_FRONT_APP_ADD , ( { appRecord } ) => {
9094 addApp ( appRecord )
Original file line number Diff line number Diff line change @@ -197,6 +197,8 @@ export default defineComponent({
197197 @mouseleave =" queueClose()"
198198 @wheel =" onMouseWheel"
199199 >
200+ <slot name =" before" />
201+
200202 <VueDropdownButton
201203 v-for =" (item, index) of items"
202204 :key =" index"
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import AppSelectItem from './AppSelectItem.vue'
44
55import { watch , defineComponent , computed } from ' @vue/composition-api'
66import { BridgeEvents , SharedData } from ' @vue-devtools/shared-utils'
7- import { useApps , pendingSelectAppId } from ' @front/features/apps'
7+ import { useApps , pendingSelectAppId , scanLegacyApps } from ' @front/features/apps'
88import { useOrientation } from ' @front/features/layout/orientation'
99import { useRouter } from ' @front/util/router'
1010import { useBridge } from ' ../bridge'
@@ -72,6 +72,7 @@ export default defineComponent({
7272 selectApp ,
7373 orientation ,
7474 hasNewVueVersion ,
75+ scanLegacyApps ,
7576 }
7677 },
7778})
@@ -119,6 +120,17 @@ export default defineComponent({
119120 :app =" item"
120121 />
121122 </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 >
122134 </AppHeaderSelect >
123135</template >
124136
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export enum BridgeEvents {
2828 TO_FRONT_APP_REMOVE = 'f:app:remove' ,
2929 TO_BACK_APP_SELECT = 'b:app:select' ,
3030 TO_FRONT_APP_SELECTED = 'f:app:selected' ,
31+ TO_BACK_SCAN_LEGACY_APPS = 'b:app:scan-legacy' ,
3132
3233 // Components
3334 TO_BACK_COMPONENT_TREE = 'b:component:tree' ,
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ const internalSharedData = {
2727 pluginPermissions : { } as any ,
2828 pluginSettings : { } as any ,
2929 pageConfig : { } as any ,
30+ legacyApps : false ,
3031 debugInfo : false ,
3132}
3233
You can’t perform that action at this time.
0 commit comments