refactor(web): dependency management (#2386)

This commit is contained in:
Mo
2023-08-05 12:48:39 -05:00
committed by GitHub
parent b07da5b663
commit d8d4052a52
274 changed files with 4065 additions and 3873 deletions

View File

@@ -37,7 +37,7 @@ export default function FilePlugin({ currentNote }: { currentNote: SNNote }): JS
if (uploadedFile) {
editor.dispatchCommand(INSERT_FILE_COMMAND, uploadedFile.uuid)
void linkingController.linkItemToSelectedItem(uploadedFile)
void application.changeAndSaveItem(uploadedFile, (mutator) => {
void application.changeAndSaveItem.execute(uploadedFile, (mutator) => {
mutator.protected = currentNote.protected
})
}

View File

@@ -23,14 +23,16 @@ export const ExportPlugin = () => {
const downloadData = useCallback(
(data: Blob, fileName: string) => {
if (!application.isNativeMobileWeb()) {
application.getArchiveService().downloadData(data, fileName)
application.archiveService.downloadData(data, fileName)
return
}
if (application.platform === Platform.Android) {
downloadBlobOnAndroid(application, data, fileName).catch(console.error)
downloadBlobOnAndroid(application.mobileDevice, data, fileName).catch(console.error)
} else {
shareBlobOnMobile(application, data, fileName).catch(console.error)
shareBlobOnMobile(application.mobileDevice, application.isNativeMobileWeb(), data, fileName).catch(
console.error,
)
}
},
[application],

View File

@@ -9,7 +9,7 @@ const ReadonlyPlugin = ({ note }: { note: SNNote }) => {
const [readOnly, setReadOnly] = useState(note.locked)
useEffect(() => {
return application.streamItems<SNNote>(ContentType.TYPES.Note, ({ changed }) => {
return application.items.streamItems<SNNote>(ContentType.TYPES.Note, ({ changed }) => {
const changedNoteItem = changed.find((changedItem) => changedItem.uuid === note.uuid)
if (changedNoteItem) {

View File

@@ -1,7 +1,7 @@
import { useApplication } from '@/Components/ApplicationProvider'
import Icon from '@/Components/Icon/Icon'
import Spinner from '@/Components/Spinner/Spinner'
import { isDesktopApplication, isIOS } from '@/Utils'
import { isDesktopApplication } from '@/Utils'
import { BlockWithAlignableContents } from '@lexical/react/LexicalBlockWithAlignableContents'
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
import { classNames, Platform } from '@standardnotes/snjs'
@@ -9,6 +9,7 @@ import { ElementFormatType, NodeKey } from 'lexical'
import { useCallback, useState } from 'react'
import { $createFileNode } from '../EncryptedFilePlugin/Nodes/FileUtils'
import { RemoteImageNode } from './RemoteImageNode'
import { isIOS } from '@standardnotes/ui-services'
type Props = {
src: string
@@ -41,7 +42,7 @@ const RemoteImageComponent = ({ className, src, alt, node, format, nodeKey }: Pr
const blob = await response.blob()
const file = new File([blob], src, { type: blob.type })
const { filesController, linkingController } = application.controllers
const { filesController, linkingController } = application
const uploadedFile = await filesController.uploadNewFile(file, false)

View File

@@ -94,7 +94,17 @@ const SuperNoteConverter = ({
const performConvert = useCallback(
async (text: string) => {
const controller = new NoteViewController(application, note)
const controller = new NoteViewController(
note,
application.items,
application.mutator,
application.sync,
application.sessions,
application.preferences,
application.componentManager,
application.alerts,
application.isNativeMobileWebUseCase,
)
await controller.initialize()
await controller.saveAndAwaitLocalPropagation({
text,

View File

@@ -43,7 +43,17 @@ export const SuperNoteImporter: FunctionComponent<Props> = ({ note, application,
const performConvert = useCallback(
async (text: string, previewPlain: string) => {
const controller = new NoteViewController(application, note)
const controller = new NoteViewController(
note,
application.items,
application.mutator,
application.sync,
application.sessions,
application.preferences,
application.componentManager,
application.alerts,
application.isNativeMobileWebUseCase,
)
await controller.initialize()
await controller.saveAndAwaitLocalPropagation({
text: text,