@mattisvensson/strapi-plugin-webatlas 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,7 @@ function transformToUrl(input) {
19
19
  input = input.replace(/-+/g, "-");
20
20
  return input;
21
21
  }
22
- const version = "0.2.3";
22
+ const version = "0.2.4";
23
23
  const keywords = [];
24
24
  const type = "commonjs";
25
25
  const exports = {
@@ -205,6 +205,7 @@ const bootstrap = async ({ strapi: strapi2 }) => {
205
205
  if (!config2?.selectedContentTypes) return;
206
206
  strapi2.db?.lifecycles.subscribe({
207
207
  models: [waNavItem],
208
+ // TODO: is beforeDelete needed?
208
209
  async beforeDelete(event) {
209
210
  const id = event.params.where["id"];
210
211
  if (!id) return;
@@ -215,6 +216,7 @@ const bootstrap = async ({ strapi: strapi2 }) => {
215
216
  },
216
217
  populate: ["route"]
217
218
  });
219
+ if (!navItem || !navItem.route) return;
218
220
  event.state = navItem.route.id && !navItem.route.internal ? { id: navItem.route.id } : null;
219
221
  } catch (err) {
220
222
  console.log(err);
@@ -247,6 +249,12 @@ const bootstrap = async ({ strapi: strapi2 }) => {
247
249
  webatlas_override
248
250
  } = event.params.data;
249
251
  if (!webatlas_path) return;
252
+ const relatedRoute = await strapi2.db?.query(waRoute).findOne({
253
+ where: {
254
+ relatedDocumentId: event.result.documentId
255
+ }
256
+ });
257
+ if (relatedRoute) return;
250
258
  const title = ctSettings?.default ? event.params.data[ctSettings.default] : "";
251
259
  const path = await duplicateCheck(transformToUrl(webatlas_path));
252
260
  await strapi2.documents(waRoute).create({
@@ -296,8 +304,6 @@ const bootstrap = async ({ strapi: strapi2 }) => {
296
304
  }
297
305
  });
298
306
  } else {
299
- console.log("updating route", relatedRoute.documentId);
300
- console.log("with data", routeData);
301
307
  await strapi2.documents(waRoute).update({
302
308
  documentId: relatedRoute.documentId,
303
309
  data: {
@@ -5836,3 +5842,4 @@ const index = {
5836
5842
  export {
5837
5843
  index as default
5838
5844
  };
5845
+ //# sourceMappingURL=index.mjs.map