diff --git a/package-lock.json b/package-lock.json index 14aee79..05c19a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tesla-eyes", - "version": "0.8.1", + "version": "0.8.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tesla-eyes", - "version": "0.8.1", + "version": "0.8.2", "license": "MIT", "dependencies": { "@fortawesome/fontawesome-free": "^6.4.2", diff --git a/package.json b/package.json index 8355017..a0ca3f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tesla-eyes", - "version": "0.8.1", + "version": "0.8.2", "description": "", "scripts": { "start": "vite", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 10d335a..489526f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -64,7 +64,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "app" -version = "0.8.1" +version = "0.8.2" dependencies = [ "serde", "serde_json", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 3a49754..9096637 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "app" -version = "0.8.1" +version = "0.8.2" description = "Tesla eyes app. Sentry Mode and Dashcam viewer" authors = ["adjilino"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index a2df591..75b16f6 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -9,7 +9,7 @@ }, "package": { "productName": "Tesla eyes", - "version": "0.8.1" + "version": "0.8.2" }, "tauri": { "allowlist": { diff --git a/src/components/main-view/Timelime.tsx b/src/components/main-view/Timelime.tsx index 1e5bff2..74133c9 100644 --- a/src/components/main-view/Timelime.tsx +++ b/src/components/main-view/Timelime.tsx @@ -4,14 +4,18 @@ import { Show, createMemo, createSignal } from "solid-js"; import { Occurrence } from "../../models"; import { currentTime, + fileByOccurrence, isPlaying, selectedOccurrence, + selectedOccurrenceFiles, setChangeCurrentTime, + setFilesByOccurrences, setIsPlaying, setSelectedOccurrence, } from "../../stores"; import { Button } from "../../ui"; import timelineStyles from "./Timelime.module.css"; +import { tauri } from "../../utils"; function addVideoShortcutControls() { window.addEventListener("keydown", (event) => { @@ -150,7 +154,7 @@ export function Timeline() { }; const removeOccurence = async (occurence: Occurrence | null) => { - if (!occurence || !occurence.directory || !window["__TAURI__"]?.tauri) { + if (!occurence || !occurence.directory || !tauri?.tauri) { return; } @@ -169,6 +173,16 @@ export function Timeline() { removeDir(occurence.directory, { recursive: true, }); + + const _fileByOccurence = fileByOccurrence(); + const _selectedOccurrenceFile = selectedOccurrenceFiles(); + if (_fileByOccurence && _selectedOccurrenceFile) { + setFilesByOccurrences( + _fileByOccurence.filter( + (file) => file.getId() !== _selectedOccurrenceFile.getId() + ) + ); + } }; return ( diff --git a/src/models/occurence-files.ts b/src/models/occurence-files.ts index b59af42..79df65c 100644 --- a/src/models/occurence-files.ts +++ b/src/models/occurence-files.ts @@ -2,34 +2,40 @@ import { FileEntry } from "@tauri-apps/api/fs"; import { OccurenceBuilder } from "../builders/occurence.builder"; import { Config } from "./config"; import { Occurrence } from "./occurence"; +import { uuidv4 } from "../utils"; export class OccurrenceFiles { - files: Array = []; - config?: Config = undefined; - thumbnail?: string | undefined = undefined; + protected id: string = uuidv4(); + files: Array = []; + config?: Config = undefined; + thumbnail?: string | undefined = undefined; - setConfig(config: Config | undefined): void { - this.config = config; - } - getConfig(): Config | undefined { - return this.config; - } + getId(): string { + return this.id; + } - setThumbnail(thumbnail: string | undefined): void { - this.thumbnail = thumbnail; - } - getThumbnail(): string | undefined { - return this.thumbnail; - } + setConfig(config: Config | undefined): void { + this.config = config; + } + getConfig(): Config | undefined { + return this.config; + } - setFiles(files: Array): void { - this.files = files; - } - getFiles(): Array { - return this.files; - } + setThumbnail(thumbnail: string | undefined): void { + this.thumbnail = thumbnail; + } + getThumbnail(): string | undefined { + return this.thumbnail; + } - toOccurrence(): Promise { - return new OccurenceBuilder().addFiles(this.files).build(); - } + setFiles(files: Array): void { + this.files = files; + } + getFiles(): Array { + return this.files; + } + + toOccurrence(): Promise { + return new OccurenceBuilder().addFiles(this.files).build(); + } } diff --git a/src/utils/index.ts b/src/utils/index.ts index 870822e..6a5779a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1,3 @@ export * from './to-base64'; export * from './tauri'; - +export * from './uuid'; diff --git a/src/utils/uuid.ts b/src/utils/uuid.ts new file mode 100644 index 0000000..8e4eb81 --- /dev/null +++ b/src/utils/uuid.ts @@ -0,0 +1,8 @@ +export function uuidv4() { + return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c: any) => + ( + c ^ + (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4))) + ).toString(16) + ); +}