@lv-x-software-house/x_view 1.2.8-dev.2 → 1.2.8-dev.3

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.
Files changed (3) hide show
  1. package/dist/index.js +129 -197
  2. package/dist/index.mjs +129 -197
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1545,17 +1545,11 @@ var userActionHandlers = {
1545
1545
  links: sceneDataRef.current.links,
1546
1546
  quest_counter: sceneDataRef.current.quest_counter || 1
1547
1547
  };
1548
- const questFilePayload = {
1549
- nodes: specificParentData.nodes,
1550
- links: specificParentData.links,
1551
- milestones: sceneDataRef.current.milestones || []
1552
- };
1553
1548
  await context.actions.save_view_data(
1554
1549
  context.sceneSaveUrl,
1555
1550
  viewFilePayload
1556
1551
  );
1557
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
1558
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
1552
+ await context.actions.save_quest_link(context.ownerId, context.sceneConfigId, newLink);
1559
1553
  } else {
1560
1554
  const specificParentData = JSON.parse(
1561
1555
  JSON.stringify(graphDataRef.current[parentFileIdToSave])
@@ -1842,20 +1836,14 @@ var userActionHandlers = {
1842
1836
  links: sceneDataRef.current.links,
1843
1837
  quest_counter: sceneDataRef.current.quest_counter || 1
1844
1838
  };
1845
- questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
1846
- questFilePayload = {
1847
- nodes: specificParentData.nodes,
1848
- links: specificParentData.links,
1849
- milestones: sceneDataRef.current.milestones || []
1850
- };
1851
1839
  } else {
1852
1840
  filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
1853
1841
  payloadToSave = specificParentData;
1854
1842
  }
1855
1843
  try {
1856
1844
  await context.actions.save_view_data(filenameToSave, payloadToSave);
1857
- if (questSaveUrl && questFilePayload) {
1858
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
1845
+ if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link) {
1846
+ await context.actions.delete_quest_link(ownerId, context.sceneConfigId, linkIdToDelete);
1859
1847
  }
1860
1848
  graphDataRef.current[parentFileId] = specificParentData;
1861
1849
  setters.setDetailsLink(
@@ -2087,13 +2075,15 @@ var userActionHandlers = {
2087
2075
  links: sceneDataRef.current.links,
2088
2076
  quest_counter: sceneDataRef.current.quest_counter || 1
2089
2077
  };
2090
- const questFilePayload = {
2091
- nodes: originalData.nodes,
2092
- links: originalData.links,
2093
- milestones: sceneDataRef.current.milestones || []
2094
- };
2095
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2096
- savePromises.push(context.actions.save_view_data(questSaveUrl, questFilePayload));
2078
+ for (const nodeId of nodesToDelete) {
2079
+ const questNode = (originalData.nodes || []).find((n) => String(n.id) === String(nodeId));
2080
+ if (questNode && questNode.is_quest) {
2081
+ await context.actions.delete_quest(ownerId, context.sceneConfigId, nodeId);
2082
+ }
2083
+ }
2084
+ for (const linkId of linksToDelete) {
2085
+ await context.actions.delete_quest_link(ownerId, context.sceneConfigId, linkId);
2086
+ }
2097
2087
  } else {
2098
2088
  filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
2099
2089
  payloadToSave = originalData;
@@ -2185,15 +2175,9 @@ var userActionHandlers = {
2185
2175
  links: newVisualLinks,
2186
2176
  quest_counter: sceneDataRef.current.quest_counter || 1
2187
2177
  };
2188
- const questFilePayload = {
2189
- nodes: specificParentData.nodes,
2190
- links: specificParentData.links,
2191
- milestones: sceneDataRef.current.milestones || []
2192
- };
2193
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2194
2178
  try {
2195
2179
  await context.actions.save_view_data(filenameToSave, payloadToSave);
2196
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
2180
+ await context.actions.delete_quest(ownerId, context.sceneConfigId, nodeIdToDelete);
2197
2181
  graphDataRef.current[parentFileId] = specificParentData;
2198
2182
  setters.setDetailsNode(
2199
2183
  (prev) => String(prev == null ? void 0 : prev.id) === String(nodeIdToDelete) ? null : prev
@@ -2223,7 +2207,7 @@ var userActionHandlers = {
2223
2207
  }
2224
2208
  },
2225
2209
  handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
2226
- var _a, _b, _c, _d;
2210
+ var _a, _b, _c;
2227
2211
  const { graphDataRef, sceneDataRef, stateRef, setters } = context;
2228
2212
  if (!graphDataRef.current || !sceneDataRef.current) return;
2229
2213
  const {
@@ -2350,40 +2334,17 @@ var userActionHandlers = {
2350
2334
  ...nodeToSave
2351
2335
  };
2352
2336
  }
2353
- if (nodeToSave.is_quest && context.actions.save_quest_action) {
2354
- await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, nodeToSave, sceneDataRef.current.quest_counter);
2355
- if (isNewDone && ((_d = nodeToSave.recurrence_config) == null ? void 0 : _d.enabled)) {
2356
- const createdRecurrenceQuest = specificParentData.nodes[specificParentData.nodes.length - 1];
2357
- if (createdRecurrenceQuest && String(createdRecurrenceQuest.id) !== String(nodeToSave.id)) {
2358
- await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, createdRecurrenceQuest, sceneDataRef.current.quest_counter);
2359
- }
2360
- }
2361
- const viewFilePayload = {
2362
- parent_dbs: sceneDataRef.current.parent_dbs,
2363
- nodes: sceneDataRef.current.nodes,
2364
- links: sceneDataRef.current.links,
2365
- quest_counter: sceneDataRef.current.quest_counter || 1
2366
- };
2367
- await context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
2368
- } else {
2369
- const viewFilePayload = {
2370
- parent_dbs: sceneDataRef.current.parent_dbs,
2371
- nodes: sceneDataRef.current.nodes,
2372
- links: sceneDataRef.current.links,
2373
- quest_counter: sceneDataRef.current.quest_counter || 1
2374
- };
2375
- const questFilePayload = {
2376
- nodes: specificParentData.nodes,
2377
- links: specificParentData.links,
2378
- milestones: sceneDataRef.current.milestones || []
2379
- };
2380
- await context.actions.save_view_data(
2381
- context.sceneSaveUrl,
2382
- viewFilePayload
2383
- );
2384
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2385
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
2386
- }
2337
+ const viewFilePayload = {
2338
+ parent_dbs: sceneDataRef.current.parent_dbs,
2339
+ nodes: sceneDataRef.current.nodes,
2340
+ links: sceneDataRef.current.links,
2341
+ quest_counter: sceneDataRef.current.quest_counter || 1
2342
+ };
2343
+ await context.actions.save_view_data(
2344
+ context.sceneSaveUrl,
2345
+ viewFilePayload
2346
+ );
2347
+ await context.actions.save_quest(ownerId, context.sceneConfigId, nodeToSave);
2387
2348
  } else {
2388
2349
  const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
2389
2350
  await context.actions.save_view_data(
@@ -15495,13 +15456,10 @@ function XViewScene({
15495
15456
  get_view_members,
15496
15457
  create_google_doc_action,
15497
15458
  open_google_picker_action,
15498
- // Firestore Atomic Actions (Quests & Milestones)
15499
15459
  save_quest_action,
15500
15460
  delete_quest_action,
15501
15461
  save_quest_link_action,
15502
- delete_quest_link_action,
15503
- save_milestone_action,
15504
- delete_milestone_action
15462
+ delete_quest_link_action
15505
15463
  }) {
15506
15464
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
15507
15465
  const { data: session, status } = (0, import_react34.useSession)();
@@ -18009,12 +17967,10 @@ function XViewScene({
18009
17967
  get_scene_view_data,
18010
17968
  upload_file: upload_file_action,
18011
17969
  delete_file: delete_file_action,
18012
- save_quest_action,
18013
- delete_quest_action,
18014
- save_quest_link_action,
18015
- delete_quest_link_action,
18016
- save_milestone_action,
18017
- delete_milestone_action
17970
+ save_quest: save_quest_action,
17971
+ delete_quest: delete_quest_action,
17972
+ save_quest_link: save_quest_link_action,
17973
+ delete_quest_link: delete_quest_link_action
18018
17974
  }
18019
17975
  };
18020
17976
  },
@@ -18037,9 +17993,7 @@ function XViewScene({
18037
17993
  save_quest_action,
18038
17994
  delete_quest_action,
18039
17995
  save_quest_link_action,
18040
- delete_quest_link_action,
18041
- save_milestone_action,
18042
- delete_milestone_action
17996
+ delete_quest_link_action
18043
17997
  ]
18044
17998
  );
18045
17999
  const handleStartVersioning = (nodeData) => {
@@ -18245,28 +18199,19 @@ function XViewScene({
18245
18199
  parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
18246
18200
  }
18247
18201
  }
18248
- if (save_quest_action) {
18249
- const updatedNodeData2 = sceneData.quest_nodes[questIndex];
18250
- await save_quest_action(ownerId, sceneConfigId, updatedNodeData2, sceneData.quest_counter || 1);
18251
- } else {
18252
- const sceneFileData = {
18253
- ...sceneData,
18254
- nodes: sceneData.nodes || [],
18255
- links: sceneData.links || [],
18256
- quest_counter: sceneData.quest_counter || 1
18257
- };
18258
- const questFileData = {
18259
- nodes: sceneData.quest_nodes || [],
18260
- links: sceneData.quest_links || [],
18261
- milestones: sceneData.milestones || []
18262
- };
18263
- await save_view_data(sceneSaveUrl, sceneFileData);
18264
- const questSaveUrl = sceneSaveUrl.replace(
18265
- "x_view_scenes",
18266
- "x_view_quests"
18267
- );
18268
- await save_view_data(questSaveUrl, questFileData);
18269
- }
18202
+ const sceneFileData = {
18203
+ ...sceneData,
18204
+ nodes: sceneData.nodes || [],
18205
+ links: sceneData.links || [],
18206
+ quest_counter: sceneData.quest_counter || 1
18207
+ };
18208
+ const questFileData = {
18209
+ nodes: sceneData.quest_nodes || [],
18210
+ links: sceneData.quest_links || [],
18211
+ milestones: sceneData.milestones || []
18212
+ };
18213
+ await save_view_data(sceneSaveUrl, sceneFileData);
18214
+ await save_quest_action(ownerId, sceneConfigId, updatedNodeData);
18270
18215
  }
18271
18216
  const updatedNodeData = sceneData.quest_nodes[questIndex];
18272
18217
  const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
@@ -18347,20 +18292,14 @@ function XViewScene({
18347
18292
  ...sceneDataRef2.current,
18348
18293
  quest_counter: currentCounter + 1
18349
18294
  };
18295
+ const questFileData = {
18296
+ nodes: graphDataRef2.current[sceneConfigId2].nodes,
18297
+ links: graphDataRef2.current[sceneConfigId2].links,
18298
+ milestones: sceneDataRef2.current.milestones || []
18299
+ };
18350
18300
  try {
18351
- if (actions.save_quest_action) {
18352
- await actions.save_quest_action(ownerId2, sceneConfigId2, newNode, currentCounter + 1);
18353
- await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18354
- } else {
18355
- const questFileData = {
18356
- nodes: graphDataRef2.current[sceneConfigId2].nodes,
18357
- links: graphDataRef2.current[sceneConfigId2].links,
18358
- milestones: sceneDataRef2.current.milestones || []
18359
- };
18360
- await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18361
- const questSaveUrl = sceneSaveUrl2.replace("x_view_scenes", "x_view_quests");
18362
- await actions.save_view_data(questSaveUrl, questFileData);
18363
- }
18301
+ await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18302
+ await actions.save_quest(ownerId2, sceneConfigId2, newNode);
18364
18303
  sceneDataRef2.current.quest_counter = currentCounter + 1;
18365
18304
  stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
18366
18305
  parentFileId: sceneConfigId2,
@@ -18436,25 +18375,21 @@ function XViewScene({
18436
18375
  if (parentFileIdToSave === sceneConfigId2) {
18437
18376
  const specificParentData = graphDataRef2.current[sceneConfigId2];
18438
18377
  specificParentData.links.push(newLink);
18439
- if (context.actions.save_quest_link_action && (isSourceQuest || isTargetQuest)) {
18440
- await context.actions.save_quest_link_action(ownerId2, sceneConfigId2, newLink);
18441
- } else {
18442
- const viewFilePayload = {
18443
- ...sceneDataRef2.current,
18444
- quest_counter: sceneDataRef2.current.quest_counter || 1
18445
- };
18446
- const questFilePayload = {
18447
- nodes: specificParentData.nodes,
18448
- links: specificParentData.links,
18449
- milestones: sceneDataRef2.current.milestones || []
18450
- };
18451
- await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18452
- const questSaveUrl = sceneSaveUrl2.replace(
18453
- "x_view_scenes",
18454
- "x_view_quests"
18455
- );
18456
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
18457
- }
18378
+ const viewFilePayload = {
18379
+ ...sceneDataRef2.current,
18380
+ quest_counter: sceneDataRef2.current.quest_counter || 1
18381
+ };
18382
+ const questFilePayload = {
18383
+ nodes: specificParentData.nodes,
18384
+ links: specificParentData.links,
18385
+ milestones: sceneDataRef2.current.milestones || []
18386
+ };
18387
+ await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18388
+ const questSaveUrl = sceneSaveUrl2.replace(
18389
+ "x_view_scenes",
18390
+ "x_view_quests"
18391
+ );
18392
+ await context.actions.save_view_data(questSaveUrl, questFilePayload);
18458
18393
  } else {
18459
18394
  const specificParentData = JSON.parse(
18460
18395
  JSON.stringify(graphDataRef2.current[parentFileIdToSave])
@@ -18487,7 +18422,9 @@ function XViewScene({
18487
18422
  if (line.material) line.material.dispose();
18488
18423
  });
18489
18424
  renderedAncestries.splice(renderIndex, 1);
18490
- stateRef.current.ancestryLinks = renderedAncestries.flatMap((a) => a.lines);
18425
+ stateRef.current.ancestryLinks = renderedAncestries.flatMap(
18426
+ (a) => a.lines
18427
+ );
18491
18428
  }
18492
18429
  }, []);
18493
18430
  const handleRenderAncestry = (0, import_react33.useCallback)(
@@ -19060,7 +18997,9 @@ function XViewScene({
19060
18997
  });
19061
18998
  };
19062
18999
  renderVertical(fullTree, rootNodeMesh, rootTargetPos, 1);
19063
- stateRef.current.ancestryLinks = renderedAncestries.flatMap((a) => a.lines);
19000
+ stateRef.current.ancestryLinks = renderedAncestries.flatMap(
19001
+ (a) => a.lines
19002
+ );
19064
19003
  tweenToTarget(rootTargetPos, 0.7);
19065
19004
  },
19066
19005
  [
@@ -19195,7 +19134,10 @@ function XViewScene({
19195
19134
  };
19196
19135
  const descriptionText = targetAncestryInfo.description || "";
19197
19136
  const savedSections = targetAncestryInfo.description_sections || [];
19198
- const sections = parseDescriptionSections(descriptionText, savedSections);
19137
+ const sections = parseDescriptionSections(
19138
+ descriptionText,
19139
+ savedSections
19140
+ );
19199
19141
  let focusTargetId = null;
19200
19142
  if (popped && popped.nodeId) {
19201
19143
  const mentionTag = `[[MENTION:node:${popped.nodeId}]]`;
@@ -19972,7 +19914,10 @@ function XViewScene({
19972
19914
  }
19973
19915
  if (ancestry_save_url && isExternalSave && get_ancestry_file) {
19974
19916
  try {
19975
- const viewDbResponse = await get_ancestry_file(sceneConfigId, ownerId);
19917
+ const viewDbResponse = await get_ancestry_file(
19918
+ sceneConfigId,
19919
+ ownerId
19920
+ );
19976
19921
  if (viewDbResponse.success && Array.isArray(viewDbResponse.data)) {
19977
19922
  const hasInViewDb = viewDbResponse.data.some(
19978
19923
  (anc) => String(anc.ancestry_id) === String(ancestryIdToDelete)
@@ -20162,58 +20107,33 @@ function XViewScene({
20162
20107
  async (newMilestones) => {
20163
20108
  var _a2, _b2, _c2;
20164
20109
  if (!sceneDataRef.current) return;
20165
- const oldMilestones = sceneDataRef.current.milestones || [];
20166
- const removedMilestones = oldMilestones.filter(
20167
- (oldM) => !newMilestones.some((newM) => String(newM.id) === String(oldM.id))
20168
- );
20169
- const addedOrUpdatedMilestones = newMilestones.filter(
20170
- (newM) => !oldMilestones.some((oldM) => JSON.stringify(oldM) === JSON.stringify(newM))
20171
- );
20172
20110
  sceneDataRef.current.milestones = newMilestones;
20173
20111
  setSceneVersion((v) => v + 1);
20174
20112
  const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20175
20113
  if (!isView || !save_view_data || !sceneSaveUrl) return;
20114
+ const sceneFileData = {
20115
+ ...sceneDataRef.current,
20116
+ nodes: sceneDataRef.current.nodes || [],
20117
+ links: sceneDataRef.current.links || [],
20118
+ quest_counter: sceneDataRef.current.quest_counter || 1
20119
+ };
20120
+ const questFileData = {
20121
+ nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20122
+ links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
20123
+ milestones: newMilestones
20124
+ };
20176
20125
  try {
20177
- if (save_milestone_action) {
20178
- const promises = [];
20179
- if (delete_milestone_action) {
20180
- removedMilestones.forEach((m) => promises.push(delete_milestone_action(ownerId, sceneConfigId, m.id)));
20181
- }
20182
- if (addedOrUpdatedMilestones.length > 0) {
20183
- addedOrUpdatedMilestones.forEach((m) => promises.push(save_milestone_action(ownerId, sceneConfigId, m)));
20184
- }
20185
- await Promise.all(promises);
20186
- const sceneFileData = {
20187
- ...sceneDataRef.current,
20188
- nodes: sceneDataRef.current.nodes || [],
20189
- links: sceneDataRef.current.links || [],
20190
- quest_counter: sceneDataRef.current.quest_counter || 1
20191
- };
20192
- await save_view_data(sceneSaveUrl, sceneFileData);
20193
- } else {
20194
- const sceneFileData = {
20195
- ...sceneDataRef.current,
20196
- nodes: sceneDataRef.current.nodes || [],
20197
- links: sceneDataRef.current.links || [],
20198
- quest_counter: sceneDataRef.current.quest_counter || 1
20199
- };
20200
- const questFileData = {
20201
- nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20202
- links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
20203
- milestones: newMilestones
20204
- };
20205
- await save_view_data(sceneSaveUrl, sceneFileData);
20206
- const questSaveUrl = sceneSaveUrl.replace(
20207
- "x_view_scenes",
20208
- "x_view_quests"
20209
- );
20210
- await save_view_data(questSaveUrl, questFileData);
20211
- }
20126
+ await save_view_data(sceneSaveUrl, sceneFileData);
20127
+ const questSaveUrl = sceneSaveUrl.replace(
20128
+ "x_view_scenes",
20129
+ "x_view_quests"
20130
+ );
20131
+ await save_view_data(questSaveUrl, questFileData);
20212
20132
  } catch (error) {
20213
20133
  console.error("Erro ao salvar milestones:", error);
20214
20134
  }
20215
20135
  },
20216
- [sceneConfigId, sceneSaveUrl, save_view_data, save_milestone_action, delete_milestone_action, viewParams == null ? void 0 : viewParams.type]
20136
+ [sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
20217
20137
  );
20218
20138
  const handleSaveCurrentView = (0, import_react33.useCallback)(async () => {
20219
20139
  var _a2, _b2, _c2;
@@ -20961,12 +20881,18 @@ function XViewScene({
20961
20881
  data: multiContextMenu,
20962
20882
  userRole: userPermissionRole,
20963
20883
  onClose: () => setMultiContextMenu((prev) => ({ ...prev, visible: false })),
20964
- onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(actionHandlerContext, ids),
20884
+ onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
20885
+ actionHandlerContext,
20886
+ ids
20887
+ ),
20965
20888
  onDismissOtherNodes: (ids) => userActionHandlers.handleDismissOtherMultipleNodes(
20966
20889
  actionHandlerContext,
20967
20890
  ids
20968
20891
  ),
20969
- onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(actionHandlerContext, ids)
20892
+ onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
20893
+ actionHandlerContext,
20894
+ ids
20895
+ )
20970
20896
  }
20971
20897
  ),
20972
20898
  /* @__PURE__ */ import_react33.default.createElement(
@@ -21148,7 +21074,29 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21148
21074
  );
21149
21075
  const parentResponsesResults = await Promise.allSettled(parentResponsesPromises);
21150
21076
  const parentData = {};
21151
- let questDataObj = null;
21077
+ let currentQuestNodes = [];
21078
+ let currentQuestLinks = [];
21079
+ let currentMilestones = [];
21080
+ if (isView) {
21081
+ const firestoreQuestsRes = await db_services.get_view_quests_and_links(owner_id, scene_config);
21082
+ const isMigrated = sceneData.quests_migrated === true;
21083
+ if (firestoreQuestsRes.success && (firestoreQuestsRes.data.nodes.length > 0 || isMigrated)) {
21084
+ currentQuestNodes = firestoreQuestsRes.data.nodes;
21085
+ currentQuestLinks = firestoreQuestsRes.data.links;
21086
+ currentMilestones = sceneData.milestones || [];
21087
+ } else {
21088
+ console.log(`Iniciando Lazy Migration para View ${scene_config}...`);
21089
+ const legacyQuestsRes = await db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`);
21090
+ if (legacyQuestsRes.success && legacyQuestsRes.data) {
21091
+ const legacyData = legacyQuestsRes.data;
21092
+ currentQuestNodes = legacyData.nodes || [];
21093
+ currentQuestLinks = legacyData.links || [];
21094
+ currentMilestones = legacyData.milestones || [];
21095
+ sceneData.milestones = currentMilestones;
21096
+ await db_services.migrate_legacy_quests(owner_id, scene_config, legacyData);
21097
+ }
21098
+ }
21099
+ }
21152
21100
  for (let i = 0; i < parentResponsesResults.length; i++) {
21153
21101
  const result = parentResponsesResults[i];
21154
21102
  const db_info = parentDbObjects[i];
@@ -21161,22 +21109,6 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21161
21109
  );
21162
21110
  }
21163
21111
  }
21164
- if (isView) {
21165
- if (db_services.get_x_view_quests_data) {
21166
- const questDataRes = await db_services.get_x_view_quests_data(session, owner_id, scene_config);
21167
- if (questDataRes && questDataRes.success) {
21168
- questDataObj = questDataRes.data;
21169
- }
21170
- } else {
21171
- const questDataRes = await db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`);
21172
- if (questDataRes && questDataRes.success) {
21173
- questDataObj = questDataRes.data;
21174
- }
21175
- }
21176
- }
21177
- const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
21178
- const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
21179
- const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
21180
21112
  if (isView) {
21181
21113
  parentData[scene_config] = {
21182
21114
  dataset_name: "Quests Internas (View)",
package/dist/index.mjs CHANGED
@@ -1506,17 +1506,11 @@ var userActionHandlers = {
1506
1506
  links: sceneDataRef.current.links,
1507
1507
  quest_counter: sceneDataRef.current.quest_counter || 1
1508
1508
  };
1509
- const questFilePayload = {
1510
- nodes: specificParentData.nodes,
1511
- links: specificParentData.links,
1512
- milestones: sceneDataRef.current.milestones || []
1513
- };
1514
1509
  await context.actions.save_view_data(
1515
1510
  context.sceneSaveUrl,
1516
1511
  viewFilePayload
1517
1512
  );
1518
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
1519
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
1513
+ await context.actions.save_quest_link(context.ownerId, context.sceneConfigId, newLink);
1520
1514
  } else {
1521
1515
  const specificParentData = JSON.parse(
1522
1516
  JSON.stringify(graphDataRef.current[parentFileIdToSave])
@@ -1803,20 +1797,14 @@ var userActionHandlers = {
1803
1797
  links: sceneDataRef.current.links,
1804
1798
  quest_counter: sceneDataRef.current.quest_counter || 1
1805
1799
  };
1806
- questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
1807
- questFilePayload = {
1808
- nodes: specificParentData.nodes,
1809
- links: specificParentData.links,
1810
- milestones: sceneDataRef.current.milestones || []
1811
- };
1812
1800
  } else {
1813
1801
  filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
1814
1802
  payloadToSave = specificParentData;
1815
1803
  }
1816
1804
  try {
1817
1805
  await context.actions.save_view_data(filenameToSave, payloadToSave);
1818
- if (questSaveUrl && questFilePayload) {
1819
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
1806
+ if (isView && parentFileId === context.sceneConfigId && context.actions.delete_quest_link) {
1807
+ await context.actions.delete_quest_link(ownerId, context.sceneConfigId, linkIdToDelete);
1820
1808
  }
1821
1809
  graphDataRef.current[parentFileId] = specificParentData;
1822
1810
  setters.setDetailsLink(
@@ -2048,13 +2036,15 @@ var userActionHandlers = {
2048
2036
  links: sceneDataRef.current.links,
2049
2037
  quest_counter: sceneDataRef.current.quest_counter || 1
2050
2038
  };
2051
- const questFilePayload = {
2052
- nodes: originalData.nodes,
2053
- links: originalData.links,
2054
- milestones: sceneDataRef.current.milestones || []
2055
- };
2056
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2057
- savePromises.push(context.actions.save_view_data(questSaveUrl, questFilePayload));
2039
+ for (const nodeId of nodesToDelete) {
2040
+ const questNode = (originalData.nodes || []).find((n) => String(n.id) === String(nodeId));
2041
+ if (questNode && questNode.is_quest) {
2042
+ await context.actions.delete_quest(ownerId, context.sceneConfigId, nodeId);
2043
+ }
2044
+ }
2045
+ for (const linkId of linksToDelete) {
2046
+ await context.actions.delete_quest_link(ownerId, context.sceneConfigId, linkId);
2047
+ }
2058
2048
  } else {
2059
2049
  filenameToSave = `x_view_dbs/${ownerId}/${parentFileId}`;
2060
2050
  payloadToSave = originalData;
@@ -2146,15 +2136,9 @@ var userActionHandlers = {
2146
2136
  links: newVisualLinks,
2147
2137
  quest_counter: sceneDataRef.current.quest_counter || 1
2148
2138
  };
2149
- const questFilePayload = {
2150
- nodes: specificParentData.nodes,
2151
- links: specificParentData.links,
2152
- milestones: sceneDataRef.current.milestones || []
2153
- };
2154
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2155
2139
  try {
2156
2140
  await context.actions.save_view_data(filenameToSave, payloadToSave);
2157
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
2141
+ await context.actions.delete_quest(ownerId, context.sceneConfigId, nodeIdToDelete);
2158
2142
  graphDataRef.current[parentFileId] = specificParentData;
2159
2143
  setters.setDetailsNode(
2160
2144
  (prev) => String(prev == null ? void 0 : prev.id) === String(nodeIdToDelete) ? null : prev
@@ -2184,7 +2168,7 @@ var userActionHandlers = {
2184
2168
  }
2185
2169
  },
2186
2170
  handleSaveNodeDetails: async (context, updatedNode, keepOpen = false) => {
2187
- var _a, _b, _c, _d;
2171
+ var _a, _b, _c;
2188
2172
  const { graphDataRef, sceneDataRef, stateRef, setters } = context;
2189
2173
  if (!graphDataRef.current || !sceneDataRef.current) return;
2190
2174
  const {
@@ -2311,40 +2295,17 @@ var userActionHandlers = {
2311
2295
  ...nodeToSave
2312
2296
  };
2313
2297
  }
2314
- if (nodeToSave.is_quest && context.actions.save_quest_action) {
2315
- await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, nodeToSave, sceneDataRef.current.quest_counter);
2316
- if (isNewDone && ((_d = nodeToSave.recurrence_config) == null ? void 0 : _d.enabled)) {
2317
- const createdRecurrenceQuest = specificParentData.nodes[specificParentData.nodes.length - 1];
2318
- if (createdRecurrenceQuest && String(createdRecurrenceQuest.id) !== String(nodeToSave.id)) {
2319
- await context.actions.save_quest_action(context.ownerId, context.sceneConfigId, createdRecurrenceQuest, sceneDataRef.current.quest_counter);
2320
- }
2321
- }
2322
- const viewFilePayload = {
2323
- parent_dbs: sceneDataRef.current.parent_dbs,
2324
- nodes: sceneDataRef.current.nodes,
2325
- links: sceneDataRef.current.links,
2326
- quest_counter: sceneDataRef.current.quest_counter || 1
2327
- };
2328
- await context.actions.save_view_data(context.sceneSaveUrl, viewFilePayload);
2329
- } else {
2330
- const viewFilePayload = {
2331
- parent_dbs: sceneDataRef.current.parent_dbs,
2332
- nodes: sceneDataRef.current.nodes,
2333
- links: sceneDataRef.current.links,
2334
- quest_counter: sceneDataRef.current.quest_counter || 1
2335
- };
2336
- const questFilePayload = {
2337
- nodes: specificParentData.nodes,
2338
- links: specificParentData.links,
2339
- milestones: sceneDataRef.current.milestones || []
2340
- };
2341
- await context.actions.save_view_data(
2342
- context.sceneSaveUrl,
2343
- viewFilePayload
2344
- );
2345
- const questSaveUrl = context.sceneSaveUrl.replace("x_view_scenes", "x_view_quests");
2346
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
2347
- }
2298
+ const viewFilePayload = {
2299
+ parent_dbs: sceneDataRef.current.parent_dbs,
2300
+ nodes: sceneDataRef.current.nodes,
2301
+ links: sceneDataRef.current.links,
2302
+ quest_counter: sceneDataRef.current.quest_counter || 1
2303
+ };
2304
+ await context.actions.save_view_data(
2305
+ context.sceneSaveUrl,
2306
+ viewFilePayload
2307
+ );
2308
+ await context.actions.save_quest(ownerId, context.sceneConfigId, nodeToSave);
2348
2309
  } else {
2349
2310
  const filenameForSpecificParent = `x_view_dbs/${ownerId}/${parentFileId}`;
2350
2311
  await context.actions.save_view_data(
@@ -15558,13 +15519,10 @@ function XViewScene({
15558
15519
  get_view_members,
15559
15520
  create_google_doc_action,
15560
15521
  open_google_picker_action,
15561
- // Firestore Atomic Actions (Quests & Milestones)
15562
15522
  save_quest_action,
15563
15523
  delete_quest_action,
15564
15524
  save_quest_link_action,
15565
- delete_quest_link_action,
15566
- save_milestone_action,
15567
- delete_milestone_action
15525
+ delete_quest_link_action
15568
15526
  }) {
15569
15527
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
15570
15528
  const { data: session, status } = useSession();
@@ -18072,12 +18030,10 @@ function XViewScene({
18072
18030
  get_scene_view_data,
18073
18031
  upload_file: upload_file_action,
18074
18032
  delete_file: delete_file_action,
18075
- save_quest_action,
18076
- delete_quest_action,
18077
- save_quest_link_action,
18078
- delete_quest_link_action,
18079
- save_milestone_action,
18080
- delete_milestone_action
18033
+ save_quest: save_quest_action,
18034
+ delete_quest: delete_quest_action,
18035
+ save_quest_link: save_quest_link_action,
18036
+ delete_quest_link: delete_quest_link_action
18081
18037
  }
18082
18038
  };
18083
18039
  },
@@ -18100,9 +18056,7 @@ function XViewScene({
18100
18056
  save_quest_action,
18101
18057
  delete_quest_action,
18102
18058
  save_quest_link_action,
18103
- delete_quest_link_action,
18104
- save_milestone_action,
18105
- delete_milestone_action
18059
+ delete_quest_link_action
18106
18060
  ]
18107
18061
  );
18108
18062
  const handleStartVersioning = (nodeData) => {
@@ -18308,28 +18262,19 @@ function XViewScene({
18308
18262
  parentDataRef.current[sceneConfigId].nodes[parentIndex].quest_abstraction_tree = formattedAbstractionTree;
18309
18263
  }
18310
18264
  }
18311
- if (save_quest_action) {
18312
- const updatedNodeData2 = sceneData.quest_nodes[questIndex];
18313
- await save_quest_action(ownerId, sceneConfigId, updatedNodeData2, sceneData.quest_counter || 1);
18314
- } else {
18315
- const sceneFileData = {
18316
- ...sceneData,
18317
- nodes: sceneData.nodes || [],
18318
- links: sceneData.links || [],
18319
- quest_counter: sceneData.quest_counter || 1
18320
- };
18321
- const questFileData = {
18322
- nodes: sceneData.quest_nodes || [],
18323
- links: sceneData.quest_links || [],
18324
- milestones: sceneData.milestones || []
18325
- };
18326
- await save_view_data(sceneSaveUrl, sceneFileData);
18327
- const questSaveUrl = sceneSaveUrl.replace(
18328
- "x_view_scenes",
18329
- "x_view_quests"
18330
- );
18331
- await save_view_data(questSaveUrl, questFileData);
18332
- }
18265
+ const sceneFileData = {
18266
+ ...sceneData,
18267
+ nodes: sceneData.nodes || [],
18268
+ links: sceneData.links || [],
18269
+ quest_counter: sceneData.quest_counter || 1
18270
+ };
18271
+ const questFileData = {
18272
+ nodes: sceneData.quest_nodes || [],
18273
+ links: sceneData.quest_links || [],
18274
+ milestones: sceneData.milestones || []
18275
+ };
18276
+ await save_view_data(sceneSaveUrl, sceneFileData);
18277
+ await save_quest_action(ownerId, sceneConfigId, updatedNodeData);
18333
18278
  }
18334
18279
  const updatedNodeData = sceneData.quest_nodes[questIndex];
18335
18280
  const nodeMesh = (_a2 = stateRef.current.nodeObjects) == null ? void 0 : _a2[String(questNodeId)];
@@ -18410,20 +18355,14 @@ function XViewScene({
18410
18355
  ...sceneDataRef2.current,
18411
18356
  quest_counter: currentCounter + 1
18412
18357
  };
18358
+ const questFileData = {
18359
+ nodes: graphDataRef2.current[sceneConfigId2].nodes,
18360
+ links: graphDataRef2.current[sceneConfigId2].links,
18361
+ milestones: sceneDataRef2.current.milestones || []
18362
+ };
18413
18363
  try {
18414
- if (actions.save_quest_action) {
18415
- await actions.save_quest_action(ownerId2, sceneConfigId2, newNode, currentCounter + 1);
18416
- await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18417
- } else {
18418
- const questFileData = {
18419
- nodes: graphDataRef2.current[sceneConfigId2].nodes,
18420
- links: graphDataRef2.current[sceneConfigId2].links,
18421
- milestones: sceneDataRef2.current.milestones || []
18422
- };
18423
- await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18424
- const questSaveUrl = sceneSaveUrl2.replace("x_view_scenes", "x_view_quests");
18425
- await actions.save_view_data(questSaveUrl, questFileData);
18426
- }
18364
+ await actions.save_view_data(sceneSaveUrl2, sceneFileData);
18365
+ await actions.save_quest(ownerId2, sceneConfigId2, newNode);
18427
18366
  sceneDataRef2.current.quest_counter = currentCounter + 1;
18428
18367
  stateRef2.current.nodeIdToParentFileMap.set(String(newNode.id), {
18429
18368
  parentFileId: sceneConfigId2,
@@ -18499,25 +18438,21 @@ function XViewScene({
18499
18438
  if (parentFileIdToSave === sceneConfigId2) {
18500
18439
  const specificParentData = graphDataRef2.current[sceneConfigId2];
18501
18440
  specificParentData.links.push(newLink);
18502
- if (context.actions.save_quest_link_action && (isSourceQuest || isTargetQuest)) {
18503
- await context.actions.save_quest_link_action(ownerId2, sceneConfigId2, newLink);
18504
- } else {
18505
- const viewFilePayload = {
18506
- ...sceneDataRef2.current,
18507
- quest_counter: sceneDataRef2.current.quest_counter || 1
18508
- };
18509
- const questFilePayload = {
18510
- nodes: specificParentData.nodes,
18511
- links: specificParentData.links,
18512
- milestones: sceneDataRef2.current.milestones || []
18513
- };
18514
- await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18515
- const questSaveUrl = sceneSaveUrl2.replace(
18516
- "x_view_scenes",
18517
- "x_view_quests"
18518
- );
18519
- await context.actions.save_view_data(questSaveUrl, questFilePayload);
18520
- }
18441
+ const viewFilePayload = {
18442
+ ...sceneDataRef2.current,
18443
+ quest_counter: sceneDataRef2.current.quest_counter || 1
18444
+ };
18445
+ const questFilePayload = {
18446
+ nodes: specificParentData.nodes,
18447
+ links: specificParentData.links,
18448
+ milestones: sceneDataRef2.current.milestones || []
18449
+ };
18450
+ await context.actions.save_view_data(sceneSaveUrl2, viewFilePayload);
18451
+ const questSaveUrl = sceneSaveUrl2.replace(
18452
+ "x_view_scenes",
18453
+ "x_view_quests"
18454
+ );
18455
+ await context.actions.save_view_data(questSaveUrl, questFilePayload);
18521
18456
  } else {
18522
18457
  const specificParentData = JSON.parse(
18523
18458
  JSON.stringify(graphDataRef2.current[parentFileIdToSave])
@@ -18550,7 +18485,9 @@ function XViewScene({
18550
18485
  if (line.material) line.material.dispose();
18551
18486
  });
18552
18487
  renderedAncestries.splice(renderIndex, 1);
18553
- stateRef.current.ancestryLinks = renderedAncestries.flatMap((a) => a.lines);
18488
+ stateRef.current.ancestryLinks = renderedAncestries.flatMap(
18489
+ (a) => a.lines
18490
+ );
18554
18491
  }
18555
18492
  }, []);
18556
18493
  const handleRenderAncestry = useCallback7(
@@ -19123,7 +19060,9 @@ function XViewScene({
19123
19060
  });
19124
19061
  };
19125
19062
  renderVertical(fullTree, rootNodeMesh, rootTargetPos, 1);
19126
- stateRef.current.ancestryLinks = renderedAncestries.flatMap((a) => a.lines);
19063
+ stateRef.current.ancestryLinks = renderedAncestries.flatMap(
19064
+ (a) => a.lines
19065
+ );
19127
19066
  tweenToTarget(rootTargetPos, 0.7);
19128
19067
  },
19129
19068
  [
@@ -19258,7 +19197,10 @@ function XViewScene({
19258
19197
  };
19259
19198
  const descriptionText = targetAncestryInfo.description || "";
19260
19199
  const savedSections = targetAncestryInfo.description_sections || [];
19261
- const sections = parseDescriptionSections(descriptionText, savedSections);
19200
+ const sections = parseDescriptionSections(
19201
+ descriptionText,
19202
+ savedSections
19203
+ );
19262
19204
  let focusTargetId = null;
19263
19205
  if (popped && popped.nodeId) {
19264
19206
  const mentionTag = `[[MENTION:node:${popped.nodeId}]]`;
@@ -20035,7 +19977,10 @@ function XViewScene({
20035
19977
  }
20036
19978
  if (ancestry_save_url && isExternalSave && get_ancestry_file) {
20037
19979
  try {
20038
- const viewDbResponse = await get_ancestry_file(sceneConfigId, ownerId);
19980
+ const viewDbResponse = await get_ancestry_file(
19981
+ sceneConfigId,
19982
+ ownerId
19983
+ );
20039
19984
  if (viewDbResponse.success && Array.isArray(viewDbResponse.data)) {
20040
19985
  const hasInViewDb = viewDbResponse.data.some(
20041
19986
  (anc) => String(anc.ancestry_id) === String(ancestryIdToDelete)
@@ -20225,58 +20170,33 @@ function XViewScene({
20225
20170
  async (newMilestones) => {
20226
20171
  var _a2, _b2, _c2;
20227
20172
  if (!sceneDataRef.current) return;
20228
- const oldMilestones = sceneDataRef.current.milestones || [];
20229
- const removedMilestones = oldMilestones.filter(
20230
- (oldM) => !newMilestones.some((newM) => String(newM.id) === String(oldM.id))
20231
- );
20232
- const addedOrUpdatedMilestones = newMilestones.filter(
20233
- (newM) => !oldMilestones.some((oldM) => JSON.stringify(oldM) === JSON.stringify(newM))
20234
- );
20235
20173
  sceneDataRef.current.milestones = newMilestones;
20236
20174
  setSceneVersion((v) => v + 1);
20237
20175
  const isView = ((_a2 = viewParams == null ? void 0 : viewParams.type) == null ? void 0 : _a2.toLowerCase()) === "view";
20238
20176
  if (!isView || !save_view_data || !sceneSaveUrl) return;
20177
+ const sceneFileData = {
20178
+ ...sceneDataRef.current,
20179
+ nodes: sceneDataRef.current.nodes || [],
20180
+ links: sceneDataRef.current.links || [],
20181
+ quest_counter: sceneDataRef.current.quest_counter || 1
20182
+ };
20183
+ const questFileData = {
20184
+ nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20185
+ links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
20186
+ milestones: newMilestones
20187
+ };
20239
20188
  try {
20240
- if (save_milestone_action) {
20241
- const promises = [];
20242
- if (delete_milestone_action) {
20243
- removedMilestones.forEach((m) => promises.push(delete_milestone_action(ownerId, sceneConfigId, m.id)));
20244
- }
20245
- if (addedOrUpdatedMilestones.length > 0) {
20246
- addedOrUpdatedMilestones.forEach((m) => promises.push(save_milestone_action(ownerId, sceneConfigId, m)));
20247
- }
20248
- await Promise.all(promises);
20249
- const sceneFileData = {
20250
- ...sceneDataRef.current,
20251
- nodes: sceneDataRef.current.nodes || [],
20252
- links: sceneDataRef.current.links || [],
20253
- quest_counter: sceneDataRef.current.quest_counter || 1
20254
- };
20255
- await save_view_data(sceneSaveUrl, sceneFileData);
20256
- } else {
20257
- const sceneFileData = {
20258
- ...sceneDataRef.current,
20259
- nodes: sceneDataRef.current.nodes || [],
20260
- links: sceneDataRef.current.links || [],
20261
- quest_counter: sceneDataRef.current.quest_counter || 1
20262
- };
20263
- const questFileData = {
20264
- nodes: ((_b2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _b2.nodes) || sceneDataRef.current.quest_nodes || [],
20265
- links: ((_c2 = parentDataRef.current[sceneConfigId]) == null ? void 0 : _c2.links) || sceneDataRef.current.quest_links || [],
20266
- milestones: newMilestones
20267
- };
20268
- await save_view_data(sceneSaveUrl, sceneFileData);
20269
- const questSaveUrl = sceneSaveUrl.replace(
20270
- "x_view_scenes",
20271
- "x_view_quests"
20272
- );
20273
- await save_view_data(questSaveUrl, questFileData);
20274
- }
20189
+ await save_view_data(sceneSaveUrl, sceneFileData);
20190
+ const questSaveUrl = sceneSaveUrl.replace(
20191
+ "x_view_scenes",
20192
+ "x_view_quests"
20193
+ );
20194
+ await save_view_data(questSaveUrl, questFileData);
20275
20195
  } catch (error) {
20276
20196
  console.error("Erro ao salvar milestones:", error);
20277
20197
  }
20278
20198
  },
20279
- [sceneConfigId, sceneSaveUrl, save_view_data, save_milestone_action, delete_milestone_action, viewParams == null ? void 0 : viewParams.type]
20199
+ [sceneConfigId, sceneSaveUrl, save_view_data, viewParams == null ? void 0 : viewParams.type]
20280
20200
  );
20281
20201
  const handleSaveCurrentView = useCallback7(async () => {
20282
20202
  var _a2, _b2, _c2;
@@ -21024,12 +20944,18 @@ function XViewScene({
21024
20944
  data: multiContextMenu,
21025
20945
  userRole: userPermissionRole,
21026
20946
  onClose: () => setMultiContextMenu((prev) => ({ ...prev, visible: false })),
21027
- onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(actionHandlerContext, ids),
20947
+ onDismissNodes: (ids) => userActionHandlers.handleDismissMultipleNodes(
20948
+ actionHandlerContext,
20949
+ ids
20950
+ ),
21028
20951
  onDismissOtherNodes: (ids) => userActionHandlers.handleDismissOtherMultipleNodes(
21029
20952
  actionHandlerContext,
21030
20953
  ids
21031
20954
  ),
21032
- onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(actionHandlerContext, ids)
20955
+ onDeleteNodes: (ids) => userActionHandlers.handleDeleteMultipleNodes(
20956
+ actionHandlerContext,
20957
+ ids
20958
+ )
21033
20959
  }
21034
20960
  ),
21035
20961
  /* @__PURE__ */ React32.createElement(
@@ -21211,7 +21137,29 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21211
21137
  );
21212
21138
  const parentResponsesResults = await Promise.allSettled(parentResponsesPromises);
21213
21139
  const parentData = {};
21214
- let questDataObj = null;
21140
+ let currentQuestNodes = [];
21141
+ let currentQuestLinks = [];
21142
+ let currentMilestones = [];
21143
+ if (isView) {
21144
+ const firestoreQuestsRes = await db_services.get_view_quests_and_links(owner_id, scene_config);
21145
+ const isMigrated = sceneData.quests_migrated === true;
21146
+ if (firestoreQuestsRes.success && (firestoreQuestsRes.data.nodes.length > 0 || isMigrated)) {
21147
+ currentQuestNodes = firestoreQuestsRes.data.nodes;
21148
+ currentQuestLinks = firestoreQuestsRes.data.links;
21149
+ currentMilestones = sceneData.milestones || [];
21150
+ } else {
21151
+ console.log(`Iniciando Lazy Migration para View ${scene_config}...`);
21152
+ const legacyQuestsRes = await db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`);
21153
+ if (legacyQuestsRes.success && legacyQuestsRes.data) {
21154
+ const legacyData = legacyQuestsRes.data;
21155
+ currentQuestNodes = legacyData.nodes || [];
21156
+ currentQuestLinks = legacyData.links || [];
21157
+ currentMilestones = legacyData.milestones || [];
21158
+ sceneData.milestones = currentMilestones;
21159
+ await db_services.migrate_legacy_quests(owner_id, scene_config, legacyData);
21160
+ }
21161
+ }
21162
+ }
21215
21163
  for (let i = 0; i < parentResponsesResults.length; i++) {
21216
21164
  const result = parentResponsesResults[i];
21217
21165
  const db_info = parentDbObjects[i];
@@ -21224,22 +21172,6 @@ async function get_scene_view_data_logic(db_services, scene_config, owner_id, ty
21224
21172
  );
21225
21173
  }
21226
21174
  }
21227
- if (isView) {
21228
- if (db_services.get_x_view_quests_data) {
21229
- const questDataRes = await db_services.get_x_view_quests_data(session, owner_id, scene_config);
21230
- if (questDataRes && questDataRes.success) {
21231
- questDataObj = questDataRes.data;
21232
- }
21233
- } else {
21234
- const questDataRes = await db_services.get_file(`x_view_quests/${owner_id}/${scene_config}`);
21235
- if (questDataRes && questDataRes.success) {
21236
- questDataObj = questDataRes.data;
21237
- }
21238
- }
21239
- }
21240
- const currentQuestNodes = (questDataObj == null ? void 0 : questDataObj.nodes) || [];
21241
- const currentQuestLinks = (questDataObj == null ? void 0 : questDataObj.links) || [];
21242
- const currentMilestones = (questDataObj == null ? void 0 : questDataObj.milestones) || [];
21243
21175
  if (isView) {
21244
21176
  parentData[scene_config] = {
21245
21177
  dataset_name: "Quests Internas (View)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lv-x-software-house/x_view",
3
- "version": "1.2.8-dev.2",
3
+ "version": "1.2.8-dev.3",
4
4
  "description": "Pacote privado contendo os componentes e lógica de renderização 3D do X View.",
5
5
  "author": "iv.x - Engenharia de Software - ivxsoftwarehouse@gmail.com",
6
6
  "license": "UNLICENSED",