Skip to content

Commit 72da01f

Browse files
bors[bot]bidoubiwa
andauthored
Merge #170
170: Fix reload bug r=bidoubiwa a=bidoubiwa When trying to reload the server to activate hooks it was ignored unless you already had hooks before the latest version Now when a collection is added or removed from MeiliSearch, the red `Reload Server` button is working when you click on it. It will add or remove the hooks. Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents 404e381 + 683ab7d commit 72da01f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

config/functions/bootstrap.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff 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+
5256
function addLifecycles({ client, collections }) {
5357
// Add lifecyles
5458
collections.map(collection => {
@@ -69,10 +73,11 @@ function addLifecycles({ client, collections }) {
6973
async 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)

0 commit comments

Comments
 (0)