diff --git a/changelog b/changelog index 54a6e14..8dcbb00 100644 --- a/changelog +++ b/changelog @@ -109,4 +109,6 @@ v0.2.6: - Fixed "Open in folder" not selecting files on linux - Remove all sync stuff - Fixed scroll to top button not animating out - - Fixed scroll to top button being ontop of filters menu \ No newline at end of file + - Fixed scroll to top button being ontop of filters menu + - Fixed photo ordering + - Fixed automatic updates \ No newline at end of file diff --git a/src-tauri/src/frontend_calls/load_photos.rs b/src-tauri/src/frontend_calls/load_photos.rs index 703fead..24544f0 100644 --- a/src-tauri/src/frontend_calls/load_photos.rs +++ b/src-tauri/src/frontend_calls/load_photos.rs @@ -36,7 +36,9 @@ pub fn load_photos(window: tauri::Window, cache: State ) { let name = name.to_str().unwrap(); let re1_match = // This is the current format used by VRChat - Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}.png").unwrap().is_match(name); + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}.png").unwrap().is_match(name) || + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}_Player.png").unwrap().is_match(name) || + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}_Environment.png").unwrap().is_match(name); let re2_match = // This is the format VRCX uses if you enable renaming photos Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap().is_match(name); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a0915b9..0d697a7 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -98,13 +98,15 @@ fn main() { let path = event.paths.first().unwrap(); let name = path.file_name().unwrap().to_str().unwrap().to_owned(); - let re1 = Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}.png").unwrap(); - let re2 = Regex::new(r"(?m)/VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{4}x[0-9]{4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png/gm").unwrap(); + let re1_match = // This is the current format used by VRChat + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}.png").unwrap().is_match(&name) || + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}_Player.png").unwrap().is_match(&name) || + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}_Environment.png").unwrap().is_match(&name); - if - re1.is_match(&name) || - re2.is_match(&name) - { + let re2_match = // This is the format VRCX uses if you enable renaming photos + Regex::new(r"(?m)VRChat_[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}-[0-9]{2}.[0-9]{3}_[0-9]{3,4}x[0-9]{3,4}_wrld_[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}.png").unwrap().is_match(&name); + + if re1_match || re2_match{ sender.send((2, path.strip_prefix(get_photo_path()).unwrap().to_str().unwrap().to_owned())).unwrap(); } }, diff --git a/src/Components/Managers/PhotoManager.tsx b/src/Components/Managers/PhotoManager.tsx index dc6f078..30df18e 100644 --- a/src/Components/Managers/PhotoManager.tsx +++ b/src/Components/Managers/PhotoManager.tsx @@ -61,6 +61,7 @@ export class PhotoManager{ }) this.Photos = MergeSort(this.Photos); + console.log(this.Photos); console.log(this.Photos.length + ' Photos found.'); if(this.Photos.length === 0 || photoPaths.length > Vars.MAX_PHOTOS_BULK_LOAD){ @@ -116,16 +117,11 @@ export class PhotoManager{ photo.onMetaLoaded = () => this.ReloadFilters(); photo.loadMeta(); - - if(!window.SyncManager.IsSyncing()){ - window.SyncManager.TriggerSync(); - } }) - + listen('photo_remove', ( event: any ) => { this.Photos = this.Photos.filter(x => x.path !== event.payload); - this.FilteredPhotos = this.FilteredPhotos.filter(x => x.path !== event.payload); - + if(event.payload === window.PhotoViewerManager.CurrentPhoto()?.path) window.PhotoViewerManager.Close() @@ -168,10 +164,15 @@ export class PhotoManager{ public ReloadFilters(){ this.FilteredPhotos = []; + if(this._filter === ''){ + this.FilteredPhotos = this.Photos; + window.PhotoListRenderingManager.ComputeLayout(); + + return; + } + switch(this._filterType){ case FilterType.USER: - if(this._filter === '')return this.FilteredPhotos = this.Photos; - this.Photos.map(p => { if(p.metadata){ try{ @@ -187,8 +188,6 @@ export class PhotoManager{ }) break; case FilterType.WORLD: - if(this._filter === '')return this.FilteredPhotos = this.Photos; - this.Photos.map(p => { if(p.metadata){ try{ diff --git a/src/Components/PhotoViewer.tsx b/src/Components/PhotoViewer.tsx index 870a7df..752c2e9 100644 --- a/src/Components/PhotoViewer.tsx +++ b/src/Components/PhotoViewer.tsx @@ -272,8 +272,10 @@ let PhotoViewer = () => { let id = doc.getElementsByTagName('xmp:Author')[0]!.innerHTML; authorProfileButton!.style.display = 'flex'; - authorProfileButton!.onclick = () => + authorProfileButton!.onclick = () => { + console.log(id); invoke('open_url', { url: 'https://vrchat.com/home/user/' + id }); + } } catch(e){ console.error(e); console.log('Couldn\'t decode metadata') @@ -286,6 +288,8 @@ let PhotoViewer = () => { } } else{ trayButton.style.display = 'none'; + authorProfileButton!.style.display = 'none'; + closeTray(); } } diff --git a/src/Components/Structs/Photo.ts b/src/Components/Structs/Photo.ts index e7f4eaf..cca0881 100644 --- a/src/Components/Structs/Photo.ts +++ b/src/Components/Structs/Photo.ts @@ -43,7 +43,14 @@ export class Photo{ else this.dateString = split[1]; + let timeString; + if(this.legacy) + timeString = split[3]; + else + timeString = split[2]; + let splitDateString = this.dateString.split('-'); + let splitTimeString = timeString.split('-'); this.date = new Date(); @@ -51,6 +58,10 @@ export class Photo{ this.date.setMonth(parseInt(splitDateString[1])); this.date.setDate(parseInt(splitDateString[2])); + this.date.setHours(parseInt(splitTimeString[0])); + this.date.setMinutes(parseInt(splitTimeString[1])); + this.date.setSeconds(parseInt(splitTimeString[2])); + let resSplit = split[3].split('x'); let width = parseInt(resSplit[0]);