slate/common/search.js
2020-08-27 16:52:49 -07:00

46 lines
940 B
JavaScript

createUserSearchResult = (user) => {
return {
id: user.id,
type: "user",
name: user.data.name,
username: user.username,
url: user.data.photo,
};
};
createSlateSearchResult = (slate) => {
let files;
if (slate.data.objects.length > 3) {
files = slate.data.objects.slice(0, 3);
} else {
files = slate.data.objects;
}
return {
id: slate.id,
type: "slate",
name: slate.slatename,
username: slate.user.username,
url: files.map((file) => {
return {
type: file.type
? file.type.includes("image")
? "image"
: "file"
: "file",
name: file.name,
url: file.url,
};
}),
};
};
createFileSearchResult = (file) => {
return {
id: file.id,
type: file.type ? (file.type.includes("image") ? "image" : "file") : "file",
name: file.name,
username: file.user.username,
url: file.url,
};
};