mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-29 20:11:55 +03:00
25 lines
771 B
JavaScript
25 lines
771 B
JavaScript
|
//NOTE(martina): this file is for utility functions that do not involve API calls
|
||
|
//For API related utility functions, see common/user-behaviors.js
|
||
|
//And for uploading related utility functions, see common/file-utilities.js
|
||
|
|
||
|
export const getPublicAndPrivateFiles = ({ viewer }) => {
|
||
|
let publicFileIds = [];
|
||
|
for (let slate of viewer.slates) {
|
||
|
if (slate.data.public) {
|
||
|
publicFileIds.push(...slate.data.objects.map((obj) => obj.id));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let publicFiles = [];
|
||
|
let privateFiles = [];
|
||
|
let library = viewer.library[0]?.children || [];
|
||
|
for (let file of library) {
|
||
|
if (file.public || publicFileIds.includes(file.id)) {
|
||
|
publicFiles.push(file);
|
||
|
} else {
|
||
|
privateFiles.push(file);
|
||
|
}
|
||
|
}
|
||
|
return { publicFiles, privateFiles };
|
||
|
};
|