diff --git a/src/libs/actions/Device/generateDeviceID/index.android.ts b/src/libs/actions/Device/generateDeviceID/index.android.ts index 80e79d57710b..0f6a7140e648 100644 --- a/src/libs/actions/Device/generateDeviceID/index.android.ts +++ b/src/libs/actions/Device/generateDeviceID/index.android.ts @@ -1,5 +1,6 @@ import DeviceInfo from 'react-native-device-info'; import Str from 'expensify-common/lib/str'; +import GenerateDeviceID from './types'; const deviceID = DeviceInfo.getDeviceId(); const uniqueID = Str.guid(deviceID); @@ -23,8 +24,6 @@ const uniqueID = Str.guid(deviceID); * Furthermore, the deviceID prefix is not unique to a specific device, but is likely to change from one type of device to another. * Including this prefix will tell us with a reasonable degree of confidence if the user just uninstalled and reinstalled the app, or if they got a new device. */ -function generateDeviceID(): Promise { - return Promise.resolve(uniqueID); -} +const generateDeviceID: GenerateDeviceID = () => Promise.resolve(uniqueID); export default generateDeviceID; diff --git a/src/libs/actions/Device/generateDeviceID/index.desktop.ts b/src/libs/actions/Device/generateDeviceID/index.desktop.ts index 5403fcfec9f7..04a291c5b3bb 100644 --- a/src/libs/actions/Device/generateDeviceID/index.desktop.ts +++ b/src/libs/actions/Device/generateDeviceID/index.desktop.ts @@ -1,10 +1,9 @@ import ELECTRON_EVENTS from '../../../../../desktop/ELECTRON_EVENTS'; +import GenerateDeviceID from './types'; /** * Get the unique ID of the current device. This should remain the same even if the user uninstalls and reinstalls the app. */ -function generateDeviceID(): Promise { - return window.electron.invoke(ELECTRON_EVENTS.REQUEST_DEVICE_ID); -} +const generateDeviceID: GenerateDeviceID = () => window.electron.invoke(ELECTRON_EVENTS.REQUEST_DEVICE_ID); export default generateDeviceID; diff --git a/src/libs/actions/Device/generateDeviceID/index.ios.ts b/src/libs/actions/Device/generateDeviceID/index.ios.ts index 6cd568d5630e..9562fc8bbf9b 100644 --- a/src/libs/actions/Device/generateDeviceID/index.ios.ts +++ b/src/libs/actions/Device/generateDeviceID/index.ios.ts @@ -1,12 +1,11 @@ import DeviceInfo from 'react-native-device-info'; +import GenerateDeviceID from './types'; const deviceID = DeviceInfo.getDeviceId(); /** * Get the unique ID of the current device. This should remain the same even if the user uninstalls and reinstalls the app. */ -function generateDeviceID(): Promise { - return DeviceInfo.getUniqueId().then((uniqueID) => `${deviceID}_${uniqueID}`); -} +const generateDeviceID: GenerateDeviceID = () => DeviceInfo.getUniqueId().then((uniqueID) => `${deviceID}_${uniqueID}`); export default generateDeviceID; diff --git a/src/libs/actions/Device/generateDeviceID/index.website.ts b/src/libs/actions/Device/generateDeviceID/index.ts similarity index 87% rename from src/libs/actions/Device/generateDeviceID/index.website.ts rename to src/libs/actions/Device/generateDeviceID/index.ts index 20eb71919e67..cc631547e750 100644 --- a/src/libs/actions/Device/generateDeviceID/index.website.ts +++ b/src/libs/actions/Device/generateDeviceID/index.ts @@ -1,4 +1,5 @@ import Str from 'expensify-common/lib/str'; +import GenerateDeviceID from './types'; const uniqueID = Str.guid(); @@ -14,8 +15,6 @@ const uniqueID = Str.guid(); * While this isn't perfect, it's just as good as any other obvious web solution, such as this one https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/deviceId * which is also different/reset under the same circumstances */ -function generateDeviceID(): Promise { - return Promise.resolve(uniqueID); -} +const generateDeviceID: GenerateDeviceID = () => Promise.resolve(uniqueID); export default generateDeviceID; diff --git a/src/libs/actions/Device/generateDeviceID/types.ts b/src/libs/actions/Device/generateDeviceID/types.ts new file mode 100644 index 000000000000..43b6b89f6154 --- /dev/null +++ b/src/libs/actions/Device/generateDeviceID/types.ts @@ -0,0 +1,3 @@ +type GenerateDeviceID = () => Promise; + +export default GenerateDeviceID;