diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-02-02 09:07:14 +0200 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-02-02 09:07:14 +0200 |
| commit | 040a7485b9f5fea5334b14ddb1f8a223a7e62cc6 (patch) | |
| tree | e15b7963e18f1c8f6edd0adb91404964326e5153 /src | |
| parent | 5c1216e864004c5694b3475b45e4047c2617a2d2 (diff) | |
| download | DevHive-040a7485b9f5fea5334b14ddb1f8a223a7e62cc6.tar DevHive-040a7485b9f5fea5334b14ddb1f8a223a7e62cc6.tar.gz DevHive-040a7485b9f5fea5334b14ddb1f8a223a7e62cc6.zip | |
Fixed comment array in post model
Diffstat (limited to 'src')
4 files changed, 12 insertions, 9 deletions
diff --git a/src/DevHive.Angular/src/app/components/post-page/post-page.component.html b/src/DevHive.Angular/src/app/components/post-page/post-page.component.html index 5d29e5d..f22646d 100644 --- a/src/DevHive.Angular/src/app/components/post-page/post-page.component.html +++ b/src/DevHive.Angular/src/app/components/post-page/post-page.component.html @@ -18,7 +18,7 @@ </form> <div> <div class="comment" *ngFor="let comm of post?.comments"> - <app-comment [paramId]="comm.commentId.toString()"></app-comment> + <app-comment [paramId]="comm.id.toString()"></app-comment> </div> </div> <div> diff --git a/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts b/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts index ef149a0..a7843e3 100644 --- a/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts +++ b/src/DevHive.Angular/src/app/components/post-page/post-page.component.ts @@ -35,9 +35,6 @@ export class PostPageComponent implements OnInit { this._postService.getPostRequest(this.postId).subscribe( (result: object) => { this.post = result as Post; - this.post.comments = this.post.comments.sort((x, y) => { - return Date.parse(y.timeCreated.toString()) - Date.parse(x.timeCreated.toString()); - }); this.editable = this.post.creatorUsername === this._tokenService.getUsernameFromSessionStorageToken(); }, (err: HttpErrorResponse) => { diff --git a/src/DevHive.Angular/src/models/post-comment.ts b/src/DevHive.Angular/src/models/post-comment.ts new file mode 100644 index 0000000..5d1e346 --- /dev/null +++ b/src/DevHive.Angular/src/models/post-comment.ts @@ -0,0 +1,5 @@ +import { Guid } from 'guid-typescript'; + +export class PostComment { + public id: Guid; +} diff --git a/src/DevHive.Angular/src/models/post.ts b/src/DevHive.Angular/src/models/post.ts index 4d49a06..1c6e26c 100644 --- a/src/DevHive.Angular/src/models/post.ts +++ b/src/DevHive.Angular/src/models/post.ts @@ -1,5 +1,6 @@ import { Guid } from 'guid-typescript'; -import {Comment} from './comment'; +import { Comment } from './comment'; +import { PostComment } from './post-comment'; export class Post { private _postId: Guid; @@ -8,10 +9,10 @@ export class Post { private _creatorUsername: string; private _message: string; private _timeCreated: Date; - private _comments: Comment[]; + private _comments: PostComment[]; // _files - constructor(postId: Guid, creatorFirstName: string, creatorLastName: string, creatorUsername: string, message: string, timeCreated: Date, comments: Comment[]) { + constructor(postId: Guid, creatorFirstName: string, creatorLastName: string, creatorUsername: string, message: string, timeCreated: Date, comments: PostComment[]) { this.postId = postId; this.creatorFirstName = creatorFirstName; this.creatorLastName = creatorLastName; @@ -63,10 +64,10 @@ export class Post { this._timeCreated = v; } - public get comments(): Comment[] { + public get comments(): PostComment[] { return this._comments; } - public set comments(v: Comment[]) { + public set comments(v: PostComment[]) { this._comments = v; } } |
