Created
March 6, 2019 13:46
-
-
Save pizzacat83/ed55f605913eba04db3c191b0aca3a33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ignored = new Map<string, boolean>(); | |
const isIgnoredItem = (driveItem: ItemWrapper): boolean => { | |
if (ignored.has(driveItem.id)) { | |
return ignored.get(driveItem.id); | |
} | |
if (ignoredList.indexOf(driveItem.id) !== -1) { | |
ignored.set(driveItem.id, true); | |
return true; | |
} | |
if (driveItem.id === rootFolderId) { | |
ignored.set(driveItem.id, false); | |
return false; | |
} | |
let parents = driveItem.content.getParents(); | |
if (!parents.hasNext()) { | |
ignored.set(driveItem.id, false); | |
return false; | |
} | |
while (parents.hasNext()) { | |
// 全ての親がignoredならtrue | |
const parent = parents.next(); | |
const parentWrapper = { content: parent, id: parent.getId() }; | |
if (!isIgnoredItem(parentWrapper)) { | |
ignored.set(driveItem.id, false); | |
return false; | |
} | |
} | |
ignored.set(driveItem.id, true); | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment