chore: fix duplicate file name error when exporting notes and refactor file name utils (#2877) [skip e2e]

This commit is contained in:
Aman Harwara
2024-05-07 15:45:50 +05:30
committed by GitHub
parent 71d2dbca6c
commit c3265d7930
16 changed files with 61 additions and 56 deletions

View File

@@ -8,8 +8,7 @@ import ImagePreview from './ImagePreview'
import { ImageZoomLevelProps } from './ImageZoomLevelProps'
import { PreviewableTextFileTypes, RequiresNativeFilePreview } from './isFilePreviewable'
import TextPreview from './TextPreview'
import { parseFileName } from '@standardnotes/filepicker'
import { sanitizeFileName } from '@standardnotes/ui-services'
import { parseFileName, sanitizeFileName } from '@standardnotes/utils'
import VideoPreview from './VideoPreview'
type Props = {

View File

@@ -1,4 +1,4 @@
import { alertDialog, sanitizeFileName } from '@standardnotes/ui-services'
import { alertDialog } from '@standardnotes/ui-services'
import {
STRING_IMPORT_SUCCESS,
STRING_INVALID_IMPORT_FILE,
@@ -10,6 +10,7 @@ import {
STRING_ENC_NOT_ENABLED,
} from '@/Constants/Strings'
import { BackupFile } from '@standardnotes/snjs'
import { sanitizeFileName } from '@standardnotes/utils'
import { ChangeEventHandler, MouseEventHandler, useCallback, useEffect, useRef, useState } from 'react'
import { WebApplication } from '@/Application/WebApplication'
import { observer } from 'mobx-react-lite'

View File

@@ -1,5 +1,5 @@
import { DecoratorBlockNode, SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode'
import { parseAndCreateZippableFileName } from '@standardnotes/ui-services'
import { parseAndCreateZippableFileName } from '@standardnotes/utils'
import { DOMExportOutput, Spread } from 'lexical'
type SerializedFileExportNode = Spread<

View File

@@ -18,7 +18,7 @@ import { $createFileExportNode } from '../Lexical/Nodes/FileExportNode'
import { $createInlineFileNode } from '../Plugins/InlineFilePlugin/InlineFileNode'
import { $convertFromMarkdownString } from '../Lexical/Utils/MarkdownImport'
import { $convertToMarkdownString } from '../Lexical/Utils/MarkdownExport'
import { parseFileName } from '@standardnotes/filepicker'
import { parseFileName } from '@standardnotes/utils'
export class HeadlessSuperConverter implements SuperConverterServiceInterface {
private importEditor: LexicalEditor

View File

@@ -11,18 +11,12 @@ import {
ArchiveManager,
confirmDialog,
IsNativeMobileWeb,
parseAndCreateZippableFileName,
VaultDisplayServiceInterface,
} from '@standardnotes/ui-services'
import { Strings, StringUtils } from '@/Constants/Strings'
import { concatenateUint8Arrays } from '@/Utils/ConcatenateUint8Arrays'
import {
ClassicFileReader,
StreamingFileReader,
StreamingFileSaver,
ClassicFileSaver,
parseFileName,
} from '@standardnotes/filepicker'
import { ClassicFileReader, StreamingFileReader, StreamingFileSaver, ClassicFileSaver } from '@standardnotes/filepicker'
import { parseAndCreateZippableFileName, parseFileName } from '@standardnotes/utils'
import {
AlertService,
ChallengeReason,

View File

@@ -1,8 +1,7 @@
import { getBase64FromBlob } from '@/Utils'
import { parseFileName } from '@standardnotes/filepicker'
import { parseFileName, sanitizeFileName } from '@standardnotes/utils'
import { MobileDeviceInterface } from '@standardnotes/snjs'
import { addToast, ToastType, dismissToast } from '@standardnotes/toast'
import { sanitizeFileName } from '@standardnotes/ui-services'
export const downloadBlobOnAndroid = async (
mobileDevice: MobileDeviceInterface,

View File

@@ -1,8 +1,8 @@
import { WebApplication } from '@/Application/WebApplication'
import { HeadlessSuperConverter } from '@/Components/SuperEditor/Tools/HeadlessSuperConverter'
import { NoteType, PrefKey, SNNote, PrefDefaults, FileItem, PrefValue } from '@standardnotes/snjs'
import { WebApplicationInterface, parseAndCreateZippableFileName } from '@standardnotes/ui-services'
import { ZipDirectoryEntry } from '@zip.js/zip.js'
import { WebApplicationInterface } from '@standardnotes/ui-services'
import { type ZipDirectoryEntry } from '@zip.js/zip.js'
// @ts-expect-error Using inline loaders to load CSS as string
import superEditorCSS from '!css-loader?{"sourceMap":false}!sass-loader!../Components/SuperEditor/Lexical/Theme/editor.scss'
// @ts-expect-error Using inline loaders to load CSS as string
@@ -10,7 +10,7 @@ import snColorsCSS from '!css-loader?{"sourceMap":false}!sass-loader!@standardno
// @ts-expect-error Using inline loaders to load CSS as string
import exportOverridesCSS from '!css-loader?{"sourceMap":false}!sass-loader!../Components/SuperEditor/Lexical/Theme/export-overrides.scss'
import { getBase64FromBlob } from './Utils'
import { parseFileName } from '@standardnotes/filepicker'
import { parseFileName, parseAndCreateZippableFileName } from '@standardnotes/utils'
export const getNoteFormat = (application: WebApplicationInterface, note: SNNote) => {
if (note.noteType === NoteType.Super) {
@@ -238,7 +238,7 @@ export const createNoteExport = async (
for (const note of notes) {
const blob = await getNoteBlob(application, note, superEmbedBehaviorPref)
const _name = getNoteFileName(application, note)
const _name = parseAndCreateZippableFileName(getNoteFileName(application, note))
filenameCounts[_name] = filenameCounts[_name] == undefined ? 0 : filenameCounts[_name] + 1