refactor(web): dependency management (#2386)
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
import { WebApplication } from '@/Application/WebApplication'
|
||||
import { getBase64FromBlob } from '@/Utils'
|
||||
import { parseFileName } from '@standardnotes/filepicker'
|
||||
import { Platform } from '@standardnotes/snjs'
|
||||
import { MobileDeviceInterface } from '@standardnotes/snjs'
|
||||
import { addToast, ToastType, dismissToast } from '@standardnotes/toast'
|
||||
import { sanitizeFileName } from '@standardnotes/ui-services'
|
||||
|
||||
export const downloadBlobOnAndroid = async (
|
||||
application: WebApplication,
|
||||
mobileDevice: MobileDeviceInterface,
|
||||
blob: Blob,
|
||||
filename: string,
|
||||
showToast = true,
|
||||
) => {
|
||||
if (!application.isNativeMobileWeb() || application.platform !== Platform.Android) {
|
||||
throw new Error('Download function being used on non-android platform')
|
||||
}
|
||||
let loadingToastId: string | undefined
|
||||
if (showToast) {
|
||||
loadingToastId = addToast({
|
||||
@@ -25,7 +21,7 @@ export const downloadBlobOnAndroid = async (
|
||||
const { name, ext } = parseFileName(filename)
|
||||
const sanitizedName = sanitizeFileName(name)
|
||||
filename = `${sanitizedName}.${ext}`
|
||||
const downloaded = await application.mobileDevice().downloadBase64AsFile(base64, filename)
|
||||
const downloaded = await mobileDevice.downloadBase64AsFile(base64, filename)
|
||||
if (loadingToastId) {
|
||||
dismissToast(loadingToastId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user