From 593c99b31ec4b5381c2724c5b050f538e6d8bb85 Mon Sep 17 00:00:00 2001 From: Ramya krishna Date: Tue, 20 Aug 2024 12:41:25 +0530 Subject: [PATCH] changes --- includes/Services/InstaMigrateService.php | 5 +++ includes/import-tools-changes.js | 52 +++++++---------------- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/includes/Services/InstaMigrateService.php b/includes/Services/InstaMigrateService.php index a2a97bb..fcc5816 100644 --- a/includes/Services/InstaMigrateService.php +++ b/includes/Services/InstaMigrateService.php @@ -25,6 +25,11 @@ class InstaMigrateService { */ private $insta_api_key = ''; + /** + * Retry count + * + * @var $count + */ private $count = 0; /** * Set required api keys for insta to initiate the migration diff --git a/includes/import-tools-changes.js b/includes/import-tools-changes.js index d3a2b12..147e4ae 100644 --- a/includes/import-tools-changes.js +++ b/includes/import-tools-changes.js @@ -28,42 +28,7 @@ node.setAttribute("id", "migration-progress-modal") document.getElementById("wpbody-content").appendChild(node) -// load a pop up when user clicks on run importer for wordpress migration tool - document.querySelector('a[href*="import=site_migration_wordpress_importer"]')?.addEventListener('click', function(e) { - e.preventDefault(); - document.getElementById("migration-progress-modal").style.display = "flex"; - - fetch( - nfdplugin.restApiUrl + "/newfold-migration/v1/migrate/connect&_locale=user", - { - credentials: 'same-origin', - headers: { - 'Content-Type': 'application/json', - 'X-WP-Nonce': nfdplugin.restApiNonce, - }, - } - ) - .then((response) => response.json()) - .then(res => { - document.getElementById("migration-progress-modal").style.display = "none"; - if(res?.success){ - window.open(res?.data?.redirect_url, "_self") - } - // else{ - // document.getElementsByClassName("wrap")[0]; - // // alert("please try again in sometime. Thanks!") - // } - }) - .catch(err => console.error(err)) - - }); - - - let params = new URLSearchParams(document.location.search); - let canMigrateSite = params.get("migrate"); - -if(canMigrateSite === "true"){ - console.log("helloo") +function startMigration(){ document.getElementById("migration-progress-modal").style.display = "flex"; fetch( @@ -87,4 +52,19 @@ if(canMigrateSite === "true"){ // // alert("please try again in sometime. Thanks!") // } }) +} +// load a pop up when user clicks on run importer for wordpress migration tool + document.querySelector('a[href*="import=site_migration_wordpress_importer"]')?.addEventListener('click', function(e) { + e.preventDefault(); + startMigration(); + + }); + + + // trigger migration when user lands on tools page with migrate param +const params = new URLSearchParams(document.location.search); +const canMigrateSite = params.get("migrate"); + +if(canMigrateSite === "true"){ + startMigration() } \ No newline at end of file