-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed media loading after loading file. Changed setStorage to not throw when storage already set Separated out tests in package.json
- Loading branch information
Showing
15 changed files
with
242 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,61 @@ | ||
import SimpleProject from '@safelight/shared/Project/SimpleProject'; | ||
import type BaseProject from '@safelight/shared/base/Project'; | ||
import { Storage } from '@safelight/shared/base/Storage'; | ||
import MediaManager from '@safelight/shared/Storage/MediaManager'; | ||
|
||
export const useProject = defineStore('Project', () => { | ||
const activeTimelineIndex = ref(0); | ||
const cursor = ref(0); | ||
const timelineViewStart = ref(0); | ||
const timelineViewEnd = ref(0); | ||
|
||
const project = new SimpleProject(); | ||
const project = shallowRef<BaseProject>(); | ||
|
||
function setProject(newProject: BaseProject) { | ||
project.value = newProject; | ||
} | ||
|
||
function loadFile(file: File) { | ||
return new Promise<void>((resolve) => { | ||
const storingProcessing = useObservable(MediaManager.StoreMedia(file)); | ||
watch(storingProcessing, (s) => { | ||
console.log(s?.type, s?.hashProgress); | ||
}); | ||
|
||
watch(storingProcessing, async () => { | ||
if (storingProcessing.value && storingProcessing.value.type == 'done') { | ||
const existingMedia = project.value!.media.some( | ||
(m) => m.id == storingProcessing.value!.id | ||
); | ||
|
||
console.log(existingMedia); | ||
if (!existingMedia) { | ||
const media = await Storage.getStorage().LoadMedia( | ||
storingProcessing.value.id! | ||
); | ||
|
||
if (media) { | ||
project.value!.media.push(media); | ||
save(); | ||
} | ||
// project.activeTimeline.createTimelineItem(media); | ||
} | ||
|
||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function save() { | ||
if (project.value) Storage.getStorage().SaveProject(project.value); | ||
} | ||
|
||
return { | ||
project, | ||
setProject, | ||
loadFile, | ||
cursor, | ||
timelineViewStart, | ||
timelineViewEnd | ||
timelineViewEnd, | ||
save | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.