Skip to content

Commit 9022113

Browse files
committed
fix(vue2): re-scan to find apps that are not mounted yet, closes #1718
1 parent 17f0e6d commit 9022113

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

packages/app-backend-core/src/app.ts

+25-18
Original file line numberDiff line numberDiff line change
@@ -227,24 +227,31 @@ export async function removeApp (app: App, ctx: BackendContext) {
227227
}
228228

229229
// eslint-disable-next-line camelcase
230-
export async function _legacy_getAndRegisterApps (ctx: BackendContext) {
231-
// Remove apps that are legacy
232-
ctx.appRecords.forEach(appRecord => {
233-
if (appRecord.meta.Vue) {
234-
removeAppRecord(appRecord, ctx)
230+
export function _legacy_getAndRegisterApps (ctx: BackendContext) {
231+
setTimeout(() => {
232+
// Remove apps that are legacy
233+
ctx.appRecords.forEach(appRecord => {
234+
if (appRecord.meta.Vue) {
235+
removeAppRecord(appRecord, ctx)
236+
}
237+
})
238+
239+
const apps = scan()
240+
241+
if (!apps.length) {
242+
setTimeout(() => _legacy_getAndRegisterApps(ctx), 1000)
235243
}
236-
})
237244

238-
const apps = scan()
239-
apps.forEach(app => {
240-
const Vue = hook.Vue
241-
registerApp({
242-
app,
243-
types: {},
244-
version: Vue?.version,
245-
meta: {
246-
Vue,
247-
},
248-
}, ctx)
249-
})
245+
apps.forEach(app => {
246+
const Vue = hook.Vue
247+
registerApp({
248+
app,
249+
types: {},
250+
version: Vue?.version,
251+
meta: {
252+
Vue,
253+
},
254+
}, ctx)
255+
})
256+
}, 0)
250257
}

packages/app-backend-core/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export async function initBackend (bridge: Bridge) {
6868
})
6969

7070
hook.on(HookEvents.APP_ADD, async app => {
71-
await _legacy_getAndRegisterApps(ctx)
7271
await registerApp(app, ctx)
7372

7473
// Will init connect

packages/app-backend-core/src/timeline-marker.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export async function addTimelineMarker (options: TimelineMarkerOptions, ctx: Ba
1818
}
1919

2020
export async function sendTimelineMarkers (ctx: BackendContext) {
21+
if (!ctx.currentAppRecord) return
2122
const markers = ctx.timelineMarkers.filter(marker => marker.all || marker.appRecord === ctx.currentAppRecord)
2223
const result = []
2324
for (const marker of markers) {

0 commit comments

Comments
 (0)