Return review with message ID stripped when querying by ID
This commit is contained in:
parent
a17b7595c1
commit
a720a9a0a2
|
@ -5,7 +5,7 @@ import {
|
|||
userRating,
|
||||
UserSideReview,
|
||||
} from "../types";
|
||||
import { appendId, checkFile } from "./functions";
|
||||
import { appendId, checkFile, stripId } from "./functions";
|
||||
|
||||
export class ReviewData {
|
||||
public data: ServerSideReview[];
|
||||
|
@ -44,7 +44,7 @@ export class ReviewData {
|
|||
public getReviewById(id: string): ServerSideReview | {} {
|
||||
for (const review of this.data) {
|
||||
if (review.id === id) {
|
||||
return review;
|
||||
return stripId(review);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,3 +35,12 @@ export function appendId(userReview: UserSideReview): ServerSideReview {
|
|||
id: generateId(),
|
||||
};
|
||||
}
|
||||
|
||||
export function stripId(serverReview: ServerSideReview): UserSideReview {
|
||||
return {
|
||||
rating: serverReview.rating,
|
||||
username: serverReview.username,
|
||||
title: serverReview.title,
|
||||
content: serverReview.content
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue