mirror of
https://github.com/ducbao414/win32.run.git
synced 2025-12-15 08:42:49 +09:00
add date_created, date_modified attrs to fs item
This commit is contained in:
@@ -61,6 +61,7 @@ export function del_fs(id){
|
||||
|
||||
hardDrive.update(data => {
|
||||
data[obj.parent].children = data[obj.parent].children.filter(el => el != obj.id);
|
||||
data[obj.parent].date_modified = (new Date()).getTime();
|
||||
return data;
|
||||
})
|
||||
}
|
||||
@@ -132,6 +133,7 @@ export function clone_fs(obj_current_id, parent_id, new_id=null){
|
||||
|
||||
hardDrive.update(data => {
|
||||
data[parent_id].children.push(obj.id);
|
||||
data[parent_id].date_modified = (new Date()).getTime();
|
||||
return data;
|
||||
})
|
||||
|
||||
@@ -147,6 +149,7 @@ export async function new_fs_item(type, ext, seedname, parent_id, file=null){
|
||||
return;
|
||||
}
|
||||
|
||||
let now = (new Date()).getTime();
|
||||
let item = {
|
||||
"id": short.generate(),
|
||||
"type": type,
|
||||
@@ -159,7 +162,9 @@ export async function new_fs_item(type, ext, seedname, parent_id, file=null){
|
||||
"parent": parent_id,
|
||||
"size": 1,
|
||||
"children": [],
|
||||
"basename": ""
|
||||
"basename": "",
|
||||
date_created: now,
|
||||
date_modified: now
|
||||
}
|
||||
|
||||
let children = get(hardDrive)[parent_id].children.map(el => get(hardDrive)[el]);
|
||||
@@ -199,6 +204,7 @@ export async function new_fs_item(type, ext, seedname, parent_id, file=null){
|
||||
})
|
||||
hardDrive.update(data => {
|
||||
data[parent_id].children.push(item.id);
|
||||
data[parent_id].date_modified = now;
|
||||
return data;
|
||||
})
|
||||
|
||||
@@ -227,6 +233,9 @@ export async function new_fs_item_raw(item, parent_id){
|
||||
if(item.children == null){
|
||||
item.children = [];
|
||||
}
|
||||
let now = (new Date()).getTime();
|
||||
item.date_created = now;
|
||||
item.date_modified = now;
|
||||
|
||||
let children = get(hardDrive)[parent_id].children.map(el => get(hardDrive)[el]);
|
||||
|
||||
@@ -260,6 +269,7 @@ export async function new_fs_item_raw(item, parent_id){
|
||||
})
|
||||
hardDrive.update(data => {
|
||||
data[parent_id].children.push(item.id);
|
||||
data[parent_id].date_modified = now;
|
||||
return data;
|
||||
})
|
||||
|
||||
|
||||
@@ -74,6 +74,19 @@ export let default_wallpapers = [
|
||||
];
|
||||
|
||||
|
||||
export let SortOptions = Object.freeze({
|
||||
NONE: 0,
|
||||
NAME: 1,
|
||||
SIZE: 2,
|
||||
DATE_CREATED: 3,
|
||||
DATE_MODIFIED: 4,
|
||||
})
|
||||
|
||||
export let SortOptionOrders = Object.freeze({
|
||||
ASCENDING: 0,
|
||||
DESCENDING: 1
|
||||
})
|
||||
|
||||
export let my_music_id = 'tjhEdnks6c4wPBWcqyoWQz';
|
||||
export let my_pictures_id = 'neRHxqN8SPnG1xrivxXxRq';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {set, get} from 'idb-keyval';
|
||||
import axios from 'axios';
|
||||
import { hardDrive, wallpaper, contextMenu } from '../../lib/store';
|
||||
import { bliss_wallpaper, wallpapers_folder } from '../../lib/system';
|
||||
import { bliss_wallpaper, wallpapers_folder, SortOptions, SortOptionOrders } from '../../lib/system';
|
||||
let dispatcher = createEventDispatcher();
|
||||
|
||||
let assets_loaded = false;
|
||||
@@ -68,6 +68,7 @@
|
||||
}
|
||||
|
||||
function migrate_files_format(drive){
|
||||
let now = (new Date()).getTime();
|
||||
for(let key of Object.keys(drive)){
|
||||
let obj = drive[key];
|
||||
if(obj.children == null){
|
||||
@@ -75,6 +76,18 @@
|
||||
delete obj.files;
|
||||
delete obj.folders;
|
||||
}
|
||||
if(obj.date_created == null){
|
||||
obj.date_created = now;
|
||||
}
|
||||
if(obj.date_modified == null){
|
||||
obj.date_modified = now;
|
||||
}
|
||||
if(obj.sort_option == null){
|
||||
obj.sort_option = SortOptions.NONE;
|
||||
}
|
||||
if(obj.sort_option_order == null){
|
||||
obj.sort_option_order = SortOptionOrders.ASCENDING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user