@crowdin/app-project-module 1.0.1 → 1.1.0

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.
@@ -622,6 +622,17 @@
622
622
  }
623
623
  };
624
624
  }, []);
625
+ // Expose centralized API to global scope for main.js compatibility
626
+ reactExports.useEffect(() => {
627
+ window.app = {
628
+ subscriptionModal: subscriptionModal,
629
+ subscriptionLink: subscriptionLink,
630
+ openModal: openModal,
631
+ };
632
+ return () => {
633
+ delete window.app;
634
+ };
635
+ }, []);
625
636
  // crowdin-users-select doesn't trigger onChange reliably, using native event listener instead
626
637
  reactExports.useEffect(() => {
627
638
  const selectElement = usersSelectRef.current;
@@ -1686,11 +1697,17 @@
1686
1697
  const allFolderFiles = scheduleModal.querySelector('#all-folder-files').checked || false;
1687
1698
  const type = scheduleModal.getAttribute('data-type');
1688
1699
  if (type === 'crowdin') {
1700
+ const crowdinFiles = await appComponent.current.getCrowdinFilesData();
1701
+ const syncedFileIds = Object.keys(syncData.current);
1702
+ const crowdinFolderIds = crowdinFiles
1703
+ .filter((file) => file.node_type === folderType || file.node_type === branchType)
1704
+ .filter((file) => syncedFileIds.includes(String(file.id)))
1705
+ .map((file) => String(file.id));
1689
1706
  appComponent.current.setCrowdinScheduleSync(syncData.current, newFile, selectedFiles);
1690
1707
  appComponent.current.setCrowdinFilesHasSyncOption(true);
1691
1708
  const syncedFiles = await appComponent.current.getCrowdinScheduleSync(true);
1692
1709
  appComponent.current.setAttribute('is-crowdin-sync-settings-in-progress', true);
1693
- updateSyncSettings(syncedFiles, 'schedule', 'crowdin');
1710
+ updateSyncSettings(syncedFiles, 'schedule', 'crowdin', [], crowdinFolderIds);
1694
1711
  }
1695
1712
  else if (type === 'integration') {
1696
1713
  if (syncNewElements === null || syncNewElements === void 0 ? void 0 : syncNewElements.integration) {
@@ -1917,7 +1934,7 @@
1917
1934
  }
1918
1935
  updateSyncSettings(syncedFiles, 'schedule', 'crowdin');
1919
1936
  }
1920
- function updateSyncSettings(files, type, provider, expandIntegrationFolders = []) {
1937
+ function updateSyncSettings(files, type, provider, expandIntegrationFolders = [], folderIds = []) {
1921
1938
  checkOrigin()
1922
1939
  .then((restParams) => fetch('api/sync-settings' + restParams, {
1923
1940
  method: 'POST',
@@ -1928,6 +1945,7 @@
1928
1945
  provider,
1929
1946
  expandIntegrationFolders,
1930
1947
  hasLoadMoreElements: hasLoadMoreElements.current,
1948
+ folderIds,
1931
1949
  }),
1932
1950
  }))
1933
1951
  .then(checkResponse)