File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ async function getHookedCollectionsFromStore({ store }) {
4949 return store . get ( { key : 'meilisearch_hooked' } )
5050}
5151
52+ async function createHookedCollection ( { store } ) {
53+ return store . set ( { key : 'meilisearch_hooked' , value : [ ] } )
54+ }
55+
5256function addLifecycles ( { client, collections } ) {
5357 // Add lifecyles
5458 collections . map ( collection => {
@@ -69,10 +73,11 @@ function addLifecycles({ client, collections }) {
6973async function initHooks ( store ) {
7074 try {
7175 const credentials = await getCredentials ( )
72- const getHookedCollections = await getHookedCollectionsFromStore ( { store } )
73- // If hooked collection is not found it means that no MeiliSearch
74- // Indexes are to be hooked. Meaning we do not have to add any lifecycle.
75- if ( credentials . host && getHookedCollections ) {
76+ const hookedCollections =
77+ ( await getHookedCollectionsFromStore ( { store } ) ) ||
78+ ( await createHookedCollection ( { store } ) )
79+
80+ if ( credentials . host && hookedCollections ) {
7681 const client = await getClient ( credentials )
7782 // get list of indexes in MeiliSearch Instance
7883 const indexes = ( await getIndexes ( client ) ) . map ( index => index . uid )
You can’t perform that action at this time.
0 commit comments