mirror of
https://github.com/wassname/talk.git
synced 2026-07-12 03:52:39 +08:00
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
const Asset = {
|
|
recentComments({id}, _, {loaders: {Comments}}) {
|
|
return Comments.genRecentComments.load(id);
|
|
},
|
|
comments({id}, {sort, limit}, {loaders: {Comments}}) {
|
|
return Comments.getByQuery({
|
|
asset_id: id,
|
|
sort,
|
|
limit,
|
|
parent_id: null
|
|
});
|
|
},
|
|
commentCount({id, commentCount}, _, {loaders: {Comments}}) {
|
|
if (commentCount != null) {
|
|
return commentCount;
|
|
}
|
|
|
|
return Comments.parentCountByAssetID.load(id);
|
|
},
|
|
totalCommentCount({id, totalCommentCount}, _, {loaders: {Comments}}) {
|
|
if (totalCommentCount != null) {
|
|
return totalCommentCount;
|
|
}
|
|
|
|
return Comments.countByAssetID.load(id);
|
|
},
|
|
settings({settings = null}, _, {loaders: {Settings}}) {
|
|
return Settings.load()
|
|
.then((globalSettings) => {
|
|
if (settings) {
|
|
settings = Object.assign({}, globalSettings.toObject(), settings);
|
|
} else {
|
|
settings = globalSettings.toObject();
|
|
}
|
|
return settings;
|
|
});
|
|
}
|
|
};
|
|
|
|
module.exports = Asset;
|