Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #954 from filecoin-project/@aminejv/new-filtering
Filtering feature
- Loading branch information
Showing
33 changed files
with
1,156 additions
and
180 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { | ||
isImageType, | ||
isVideoType, | ||
isAudioType, | ||
isDocument, | ||
isTwitterLink, | ||
isYoutubeLink, | ||
isTwitchLink, | ||
isGithubLink, | ||
isInstagramLink, | ||
} from "~/common/validations"; | ||
|
||
export const FILTER_VIEWS_IDS = { | ||
initial: "initial", | ||
browser: "browser", | ||
}; | ||
|
||
export const FILTER_SUBVIEWS_IDS = { | ||
browser: { saved: "saved" }, | ||
}; | ||
|
||
export const FILTER_TYPES = { | ||
[FILTER_VIEWS_IDS.initial]: { | ||
filters: { | ||
initial: "library", | ||
library: "library", | ||
images: "images", | ||
videos: "videos", | ||
audios: "audios", | ||
documents: "documents", | ||
}, | ||
}, | ||
[FILTER_VIEWS_IDS.browser]: { | ||
filters: { all: "all", initial: "all" }, | ||
subviews: { | ||
[FILTER_SUBVIEWS_IDS.browser.saved]: { | ||
filters: { | ||
initial: "all", | ||
all: "all", | ||
twitter: "twitter", | ||
youtube: "youtube", | ||
twitch: "twitch", | ||
github: "github", | ||
instagram: "instagram", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const FILTERING_HANDLERS = { | ||
[FILTER_VIEWS_IDS.initial]: { | ||
filters: { | ||
library: (object) => object, | ||
images: (object) => isImageType(object.type), | ||
videos: (object) => isVideoType(object.type), | ||
audios: (object) => isAudioType(object.type), | ||
documents: (object) => isDocument(object.filename, object.type), | ||
}, | ||
}, | ||
[FILTER_VIEWS_IDS.browser]: { | ||
filters: { all: (object) => object.isLink }, | ||
subviews: { | ||
[FILTER_SUBVIEWS_IDS.browser.saved]: { | ||
filters: { | ||
all: (object) => object.isLink, | ||
twitter: isTwitterLink, | ||
youtube: isYoutubeLink, | ||
twitch: isTwitchLink, | ||
github: isGithubLink, | ||
instagram: isInstagramLink, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const getViewData = (view) => { | ||
return FILTER_TYPES[view]; | ||
}; | ||
|
||
export const getFilterHandler = ({ view, subview, type }) => { | ||
const nextView = FILTERING_HANDLERS[view]; | ||
if (subview) return nextView.subviews[subview].filters[type]; | ||
return nextView.filters[type]; | ||
}; |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export { default as ViewMoreContent } from "./ViewMoreContent"; | ||
export { default as ProfileInfo } from "./ProfileInfo"; | ||
export { default as ActivityCollectionGroup } from "./ActivityCollectionGroup"; | ||
export { default as ActivityFileGroup } from "./ActivityFileGroup"; | ||
export { default as ActivityProfileGroup } from "./ActivityProfileGroup"; | ||
export { default as ViewMoreContent } from "~/components/core/ActivityGroup/components/ViewMoreContent"; | ||
export { default as ProfileInfo } from "~/components/core/ActivityGroup/components/ProfileInfo"; | ||
export { default as ActivityCollectionGroup } from "~/components/core/ActivityGroup/components/ActivityCollectionGroup"; | ||
export { default as ActivityFileGroup } from "~/components/core/ActivityGroup/components/ActivityFileGroup"; | ||
export { default as ActivityProfileGroup } from "~/components/core/ActivityGroup/components/ActivityProfileGroup"; |
Oops, something went wrong.