Cleanup presenters
This commit is contained in:
@ -5,15 +5,13 @@ import presentUser from './presenters/user';
|
||||
|
||||
export { presentUser };
|
||||
|
||||
export function presentTeam(ctx, team) {
|
||||
export async function presentTeam(ctx, team) {
|
||||
ctx.cache.set(team.id, team);
|
||||
|
||||
return new Promise(async (resolve, _reject) => {
|
||||
resolve({
|
||||
return {
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export async function presentDocument(ctx, document, options) {
|
||||
@ -77,14 +75,13 @@ export async function presentDocument(ctx, document, options) {
|
||||
return data;
|
||||
}
|
||||
|
||||
export function presentCollection(
|
||||
export async function presentCollection(
|
||||
ctx,
|
||||
collection,
|
||||
includeRecentDocuments = false
|
||||
) {
|
||||
ctx.cache.set(collection.id, collection);
|
||||
|
||||
return new Promise(async (resolve, _reject) => {
|
||||
const data = {
|
||||
id: collection.id,
|
||||
url: collection.getUrl(),
|
||||
@ -117,15 +114,10 @@ export function presentCollection(
|
||||
);
|
||||
})
|
||||
);
|
||||
data.recentDocuments = _.orderBy(
|
||||
recentDocuments,
|
||||
['updatedAt'],
|
||||
['desc']
|
||||
);
|
||||
data.recentDocuments = _.orderBy(recentDocuments, ['updatedAt'], ['desc']);
|
||||
}
|
||||
|
||||
resolve(data);
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export function presentApiKey(ctx, key) {
|
||||
|
@ -1,15 +1,15 @@
|
||||
const presentUser = (ctx, user) => {
|
||||
// @flow
|
||||
import User from '../models/User';
|
||||
|
||||
async function presentUser(ctx: Object, user: User) {
|
||||
ctx.cache.set(user.id, user);
|
||||
|
||||
return new Promise(async (resolve, _reject) => {
|
||||
const data = {
|
||||
return {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
avatarUrl: user.slackData ? user.slackData.image_192 : null,
|
||||
};
|
||||
resolve(data);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default presentUser;
|
||||
|
Reference in New Issue
Block a user