mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +03:00
46 lines
940 B
JavaScript
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,
|
|
};
|
|
};
|