Skip to content

Commit db5d924

Browse files
committedJun 19, 2024
fix(applet): prevent state update when data is empty
1 parent f7a52a6 commit db5d924

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed
 

‎packages/applet/src/modules/components/index.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ function normalizeComponentState(data: { state?: any[] }) {
150150
151151
function getComponentState(id: string) {
152152
rpc.value.getInspectorState({ inspectorId, nodeId: id }).then((data) => {
153-
activeComponentState.value = normalizeComponentState(parse(data!))
153+
const parsedData = parse(data!)
154+
if (!parsedData)
155+
return
156+
activeComponentState.value = normalizeComponentState(parsedData)
154157
expandedStateNodes.value = Array.from({ length: Object.keys(activeComponentState.value).length }, (_, i) => `${i}`)
155158
})
156159
}

‎packages/applet/src/modules/custom-inspector/components/state/Index.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ function filterEmptyState(data: Record<string, CustomInspectorState[]>) {
9999
100100
function getInspectorState(nodeId: string) {
101101
rpc.value.getInspectorState({ inspectorId: inspectorId.value, nodeId }).then((data) => {
102-
state.value = filterEmptyState(parse(data!))
102+
const parsedData = parse(data!)
103+
if (!parsedData)
104+
return
105+
state.value = filterEmptyState(parsedData)
103106
expandedStateNodes.value = Array.from({ length: Object.keys(state.value).length }, (_, i) => `${i}`)
104107
})
105108
}

‎packages/applet/src/modules/pinia/components/store/Index.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ function filterEmptyState(data: Record<string, unknown[] | undefined>) {
7070
7171
function getPiniaState(nodeId: string) {
7272
rpc.value.getInspectorState({ inspectorId, nodeId }).then((data) => {
73+
const parsedData = parse(data!)
74+
if (!parsedData)
75+
return
7376
// @ts-expect-error skip type check
74-
state.value = filterEmptyState(parse(data!))
77+
state.value = filterEmptyState(parsedData)
7578
expandedStateNodes.value = Array.from({ length: Object.keys(state.value).length }, (_, i) => `${i}`)
7679
})
7780
}

‎packages/applet/src/modules/router/components/routes/Index.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ function filterEmptyState(data: Record<string, unknown[] | string | undefined>)
7070
7171
function getRoutesState(nodeId: string) {
7272
rpc.value.getInspectorState({ inspectorId: inspectorId.value, nodeId }).then((data) => {
73+
const parsedData = parse(data!)
74+
if (!parsedData)
75+
return
7376
// @ts-expect-error skip type check
74-
state.value = filterEmptyState(parse(data!))
77+
state.value = filterEmptyState(parsedData)
7578
expandedStateNodes.value = Array.from({ length: Object.keys(state.value).length }, (_, i) => `${i}`)
7679
})
7780
}

0 commit comments

Comments
 (0)