diff --git a/src/boot/setup.js b/src/boot/setup.js index d777d2e..8c3c2e8 100755 --- a/src/boot/setup.js +++ b/src/boot/setup.js @@ -11,7 +11,7 @@ import getTheme from "../theme/components"; import variables from "../theme/variables/platform"; const stores2 = config(); -BackgroundJob.cancel({jobKey: "AutomaticSync"}); +BackgroundJob.cancel({ jobKey: "AutomaticSync" }); const backgroundJob = { jobKey: "myJob", job: () => syncObjectValues("sync", stores2, true), diff --git a/src/store/PosStore/DbFunctions.js b/src/store/PosStore/DbFunctions.js index 236bc66..5d6a011 100644 --- a/src/store/PosStore/DbFunctions.js +++ b/src/store/PosStore/DbFunctions.js @@ -39,55 +39,53 @@ export function sync( ) { // if (credentials.url !== undefined && credentials.user_name !== undefined && credentials.password !== undefined) { if (credentials.url) { + if (validUrl.isWebUri(credentials.url.toLowerCase())) { + return FrappeFetch.createClient({ + url: credentials.url.toLowerCase(), + username: credentials.user_name, + password: credentials.password, + }) - if (validUrl.isWebUri(credentials.url.toLowerCase())) { - return FrappeFetch.createClient({ - url: credentials.url.toLowerCase(), - username: credentials.user_name, - password: credentials.password, - }) - - .then(responseLog => { - const {Client} = FrappeFetch; - return Client.postApi( - "tailpos_sync.sync_pos.sync_data", - // "frappe.handler.ping", - { - tailposData: JSON.parse(jsonObject), - trashObject: JSON.parse(trashObj), - deviceId: credentials.deviceId, - typeOfSync: type, - }, - ); - }) - .catch(error => { - store.stateStore.setIsNotSyncing(); - BackgroundJob.cancel({ jobKey: "AutomaticSync" }); - if (!jobStatus) { - Toast.show({ - text: "Unable to sync", - type: "danger", - duration: 5000, - }); - - } - }) - - .then(response => response.json()) - .then(responseJson => { - return responseJson.message.data; - }); - } else { + .then(responseLog => { + const { Client } = FrappeFetch; + return Client.postApi( + "tailpos_sync.sync_pos.sync_data", + // "frappe.handler.ping", + { + tailposData: JSON.parse(jsonObject), + trashObject: JSON.parse(trashObj), + deviceId: credentials.deviceId, + typeOfSync: type, + }, + ); + }) + .catch(error => { store.stateStore.setIsNotSyncing(); - Toast.show({ - text: "Invalid URL", + BackgroundJob.cancel({ jobKey: "AutomaticSync" }); + if (!jobStatus) { + Toast.show({ + text: "Unable to sync", type: "danger", duration: 5000, - }); - BackgroundJob.cancel({ jobKey: "AutomaticSync" }); - } - } else { + }); + } + }) + + .then(response => response.json()) + .then(responseJson => { + return responseJson.message.data; + }); + } else { + store.stateStore.setIsNotSyncing(); + Toast.show({ + text: "Invalid URL", + type: "danger", + duration: 5000, + }); BackgroundJob.cancel({ jobKey: "AutomaticSync" }); + } + } else { + BackgroundJob.cancel({ jobKey: "AutomaticSync" }); } } diff --git a/src/store/PosStore/ReceiptStore.js b/src/store/PosStore/ReceiptStore.js index d084b85..200e8ca 100644 --- a/src/store/PosStore/ReceiptStore.js +++ b/src/store/PosStore/ReceiptStore.js @@ -297,7 +297,6 @@ export const Receipt = types ReceiptStore.delete(self); // Reference }, clear() { - // Yay! self.lines.splice(0, self.lines.length); },