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