@@ -16,6 +16,7 @@ import {
16
16
} from './types'
17
17
import { DEFAULT_PLUGIN_LIST_FILTERS } from './constants'
18
18
import './pluginListContainer.scss'
19
+ import { getUpdatedPluginStore } from './utils'
19
20
20
21
const PluginListContainer = ( {
21
22
availableTags,
@@ -98,25 +99,12 @@ const PluginListContainer = ({
98
99
pluginResponse ,
99
100
appendResponse = false ,
100
101
) => {
101
- const clonedPluginDataStore = structuredClone ( pluginDataStore )
102
102
const {
103
103
pluginStore : { parentPluginStore, pluginVersionStore } ,
104
104
totalCount : responseTotalCount ,
105
105
} = pluginResponse
106
106
107
- Object . keys ( parentPluginStore ) . forEach ( ( key ) => {
108
- if ( ! clonedPluginDataStore . parentPluginStore [ key ] ) {
109
- clonedPluginDataStore . parentPluginStore [ key ] = parentPluginStore [ key ]
110
- }
111
- } )
112
-
113
- Object . keys ( pluginVersionStore ) . forEach ( ( key ) => {
114
- if ( ! clonedPluginDataStore . pluginVersionStore [ key ] ) {
115
- clonedPluginDataStore . pluginVersionStore [ key ] = pluginVersionStore [ key ]
116
- }
117
- } )
118
-
119
- handlePluginDataStoreUpdate ( clonedPluginDataStore )
107
+ handlePluginDataStoreUpdate ( getUpdatedPluginStore ( pluginDataStore , parentPluginStore , pluginVersionStore ) )
120
108
handleUpdateTotalCount ( responseTotalCount )
121
109
122
110
const newPluginList : typeof pluginList = appendResponse ? structuredClone ( pluginList ) : [ ]
@@ -142,7 +130,6 @@ const PluginListContainer = ({
142
130
143
131
useEffect ( ( ) => {
144
132
const isLoading = isLoadingPluginData || getIsRequestAborted ( pluginDataError )
145
- // This will be reusable for load more so convert it to a function
146
133
if ( ! isLoading && ! pluginDataError && pluginData ) {
147
134
handleDataUpdateForPluginResponse ( pluginData )
148
135
}
0 commit comments