Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/core/interceptors/api.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HttpInterceptorFn } from '@angular/common/http';

export const apiInterceptor: HttpInterceptorFn = (req, next) => {
const apiReq = req.clone({ url: `https://api.realworld.show/api${req.url}` });
const apiReq = req.clone({ url: `http://localhost:8080${req.url}` });
return next(apiReq);
};
67 changes: 46 additions & 21 deletions src/app/features/article/components/article-comment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,57 @@ import { AsyncPipe, DatePipe } from '@angular/common';
selector: 'app-article-comment',
template: `
@if (comment) {
<div class="card">
<div class="card-block">
<p class="card-text">
{{ comment.body }}
</p>
@if (comment.status === 'REMOVED') {
<div class="card">
<div class="card-block">
<p class="card-text">This comment has been deleted.</p>
</div>
</div>
<div class="card-footer">
<a class="comment-author" [routerLink]="['/profile', comment.author.username]">
<img [src]="comment.author.image" class="comment-author-img" />
</a>
&nbsp;
<a class="comment-author" [routerLink]="['/profile', comment.author.username]">
{{ comment.author.username }}
</a>
<span class="date-posted">
{{ comment.createdAt | date: 'longDate' }}
</span>
@if (canModify$ | async) {
<span class="mod-options">
<i class="ion-trash-a" (click)="delete.emit(true)"></i>
} @else {
<div class="card">
<div class="card-block">
<p class="card-text">
{{ comment.body }}
</p>
</div>
<div class="card-footer">
<a class="comment-author" [routerLink]="['/profile', comment.author.username]">
<img [src]="comment.author.image" class="comment-author-img" />
</a>
&nbsp;
<a class="comment-author" [routerLink]="['/profile', comment.author.username]">
{{ comment.author.username }}
</a>
<span class="date-posted">
{{ comment.createdAt | date: 'longDate' }}
</span>
}
@if (canModify$ | async) {
<span class="mod-options">
<i class="ion-trash-a" (click)="delete.emit(true)"></i>
</span>
}
</div>
</div>
</div>
}
}
`,
styles: [
`
.comment {
padding: 12px;
border-bottom: 1px solid #e0e0e0;
}

.deleted {
font-style: italic;
color: #888;
}

.deleted-text {
margin: 0;
}
`,
],
imports: [RouterLink, DatePipe, AsyncPipe],
})
export class ArticleCommentComponent {
Expand Down
1 change: 1 addition & 0 deletions src/app/features/article/models/comment.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export interface Comment {
id: string;
body: string;
createdAt: string;
status: string;
author: Profile;
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default class ArticleComponent implements OnInit {

deleteComment(comment: Comment): void {
this.commentsService
.delete(comment.id, this.article.slug)
.softDelete(comment.id, this.article.slug)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.comments = this.comments.filter(item => item !== comment);
Expand Down
13 changes: 13 additions & 0 deletions src/app/features/article/pages/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ <h1 class="logo-font">conduit</h1>
Global Feed
</a>
</li>

<li class="nav-item">
<a
class="nav-link"
[ngClass]="{
active: listConfig.type === 'trending' && !listConfig.filters.tag,
}"
(click)="setListTo('trending')"
>
Trending Feed
</a>
</li>

<li class="nav-item" [hidden]="!listConfig.filters.tag">
<a class="nav-link active"> <i class="ion-pound"></i> {{ listConfig.filters.tag }} </a>
</li>
Expand Down
1 change: 1 addition & 0 deletions src/app/features/article/pages/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class HomeComponent implements OnInit {
} else {
this.setListTo('all');
}
this.setListTo('trending');
}),
takeUntilDestroyed(this.destroyRef),
)
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/article/services/articles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ArticlesService {
});

return this.http.get<{ articles: Article[]; articlesCount: number }>(
'/articles' + (config.type === 'feed' ? '/feed' : ''),
'/articles' + (config.type === 'feed' ? '/feed' : config.type == 'trending' ? '/trending' : ''),
{ params },
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/features/article/services/comments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ export class CommentsService {
delete(commentId: string, slug: string): Observable<void> {
return this.http.delete<void>(`/articles/${slug}/comments/${commentId}`);
}

softDelete(commentId: string, slug: string): Observable<void> {
return this.http.patch<void>(`/articles/${slug}/comments/${commentId}/remove`, {});
}
}