Skip to content

Commit

Permalink
fix(personal-files): correctly filters groupfolders now
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
  • Loading branch information
emoral435 committed Mar 25, 2024
1 parent 46906b7 commit ef613ad
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions apps/files/src/services/PersonalFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,22 @@ const currUserID = getCurrentUser()?.uid
* @param {FileStat} node that contains
* @return {Boolean}
*/
export const personalFile = function(node: File): Boolean {
const isNotShared = currUserID ? node.owner === currUserID : true
&& node.attributes['mount-type'] !== 'group'
&& node.attributes['mount-type'] !== 'shared'
return isNotShared
export const isPersonalFile = function(node: File): Boolean {
// the type of mounts that determine whether the file is shared
const sharedMountTypes = ["group", "shared"]
const mountType = node.attributes['mount-type']
// the check to determine whether the current logged in user is the owner / creator of the node
const currUserCreated = currUserID ? node.owner === currUserID : true

return currUserCreated && !sharedMountTypes.includes(mountType)
}

export const getContents = (path: string = "/"): Promise<ContentsWithRoot> => {
// get all the files from the current path as a cancellable promise
// then filter the files that the user does not own, or has shared / is a group folder
return getFiles(path)
.then(c => {
c.contents = c.contents.filter(personalFile) as File[]
c.contents = c.contents.filter(isPersonalFile) as File[]
return c
})
}

0 comments on commit ef613ad

Please sign in to comment.