[Gekidou - MM-44645] Search Screen - show results from server (#6314)

Co-authored-by: Daniel Espino García <larkox@gmail.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Jason Frerich
2022-06-15 08:29:32 -05:00
committed by GitHub
parent 9370a9c54e
commit 196f922b6a
25 changed files with 784 additions and 279 deletions

View File

@@ -24,6 +24,8 @@ const EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
const CONTENT_DISPOSITION_REGEXP = /inline;filename=".*\.([a-z]+)";/i;
const DEFAULT_SERVER_MAX_FILE_SIZE = 50 * 1024 * 1024;// 50 Mb
export type FileFilter = 'all' | 'documents' | 'spreadsheets'| 'presentations' | 'code' | 'images' | 'audio' | 'videos'
export const GENERAL_SUPPORTED_DOCS_FORMAT = [
'application/json',
'application/msword',
@@ -58,6 +60,22 @@ const SUPPORTED_VIDEO_FORMAT = Platform.select({
const types: Record<string, string> = {};
const extensions: Record<string, readonly string[]> = {};
export function filterFiles<T extends FileModel | FileInfo>(files: T[], filter: FileFilter) {
switch (filter) {
case 'all':
return files;
case 'videos':
return files.filter((f) => isVideo(f));
case 'documents':
return files.filter((f) => isDocument(f));
case 'images':
return files.filter((f) => isImage(f));
default:
// TODO create the rest of the filters
return files.filter((f) => !isVideo(f) && !isDocument(f) && !isImage(f));
}
}
/**
* Populate the extensions and types maps.
* @private