-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Communication
: Refactor sidebar design
#9356
base: develop
Are you sure you want to change the base?
Changes from 11 commits
5e0990e
8a1d9b3
46ec02f
484ad39
8913b9b
8b55957
87a0c5c
a556e90
d8dde0c
e6fa965
d7c7787
f36fc33
d1b1f5b
b80e041
9fcb02c
94308dd
5a078b2
739c420
d7b4d1a
40f3913
cf15dfb
eb2010f
9c80f6d
b908c5a
468c4e8
6eb7168
bf14c71
256716f
3683388
e0f3f02
cb8cb07
d040704
5f5bf5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,10 +3,10 @@ import { ConversationDTO } from 'app/entities/metis/conversation/conversation.mo | |||||||||||||||||||||||||||||||||||||||||||||||||
import { Post } from 'app/entities/metis/post.model'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ActivatedRoute, Router } from '@angular/router'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { EMPTY, Subject, Subscription, from, take, takeUntil } from 'rxjs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { catchError } from 'rxjs/operators'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { EMPTY, Observable, Subject, Subscription, from, take, takeUntil } from 'rxjs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { catchError, debounceTime, distinctUntilChanged } from 'rxjs/operators'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { MetisConversationService } from 'app/shared/metis/metis-conversation.service'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ChannelSubType, getAsChannelDTO } from 'app/entities/metis/conversation/channel.model'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ChannelDTO, ChannelSubType, getAsChannelDTO } from 'app/entities/metis/conversation/channel.model'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { MetisService } from 'app/shared/metis/metis.service'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { Course, isMessagingEnabled } from 'app/entities/course.model'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { PageType, SortDirection } from 'app/shared/metis/metis.util'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -16,11 +16,12 @@ import { CourseWideSearchComponent, CourseWideSearchConfig } from 'app/overview/ | |||||||||||||||||||||||||||||||||||||||||||||||||
import { AccordionGroups, ChannelAccordionShowAdd, ChannelTypeIcons, CollapseState, SidebarCardElement, SidebarData } from 'app/types/sidebar'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { CourseOverviewService } from 'app/overview/course-overview.service'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { GroupChatCreateDialogComponent } from 'app/overview/course-conversations/dialogs/group-chat-create-dialog/group-chat-create-dialog.component'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { defaultFirstLayerDialogOptions } from 'app/overview/course-conversations/other/conversation.util'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { defaultFirstLayerDialogOptions, defaultSecondLayerDialogOptions } from 'app/overview/course-conversations/other/conversation.util'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { UserPublicInfoDTO } from 'app/core/user/user.model'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { OneToOneChatCreateDialogComponent } from 'app/overview/course-conversations/dialogs/one-to-one-chat-create-dialog/one-to-one-chat-create-dialog.component'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ChannelsOverviewDialogComponent } from 'app/overview/course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ChannelAction, ChannelsOverviewDialogComponent } from 'app/overview/course-conversations/dialogs/channels-overview-dialog/channels-overview-dialog.component'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { ChannelsCreateDialogComponent } from 'app/overview/course-conversations/dialogs/channels-create-dialog/channels-create-dialog.component'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
const DEFAULT_CHANNEL_GROUPS: AccordionGroups = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
favoriteChannels: { entityData: [] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -114,7 +115,9 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
faFilter = faFilter; | ||||||||||||||||||||||||||||||||||||||||||||||||||
faSearch = faSearch; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
// MetisConversationService is created in course overview, so we can use it here | ||||||||||||||||||||||||||||||||||||||||||||||||||
createChannelFn?: (channel: ChannelDTO) => Observable<never>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify the return type of The function |
||||||||||||||||||||||||||||||||||||||||||||||||||
channelActions$ = new Subject<ChannelAction>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
asliayk marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||
constructor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
private router: Router, | ||||||||||||||||||||||||||||||||||||||||||||||||||
private activatedRoute: ActivatedRoute, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -162,6 +165,16 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
this.metisConversationService.checkIsCodeOfConductAccepted(this.course!); | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.isServiceSetUp = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.channelActions$ | ||||||||||||||||||||||||||||||||||||||||||||||||||
.pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||
debounceTime(500), | ||||||||||||||||||||||||||||||||||||||||||||||||||
distinctUntilChanged((prev, curr) => prev.action === curr.action && prev.channel.id === curr.channel.id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
takeUntil(this.ngUnsubscribe), | ||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.subscribe((channelAction) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.performChannelAction(channelAction); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+168
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling to the In the subscription to Apply this diff to add error handling: this.channelActions$
.pipe(
debounceTime(500),
distinctUntilChanged((prev, curr) => prev.action === curr.action && prev.channel.id === curr.channel.id),
takeUntil(this.ngUnsubscribe),
)
- .subscribe((channelAction) => {
+ .subscribe({
+ next: (channelAction) => {
this.performChannelAction(channelAction);
+ },
+ error: (error) => {
+ console.error('Error processing channel action:', error);
+ // Optionally, display an error message to the user
+ },
+ }); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
this.createChannelFn = (channel: ChannelDTO) => this.metisConversationService.createChannel(channel); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
this.profileSubscription = this.profileService.getProfileInfo()?.subscribe((profileInfo) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -170,6 +183,21 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
performChannelAction(channelAction: ChannelAction) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (this.createChannelFn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.createChannelFn(channelAction.channel) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.pipe(takeUntil(this.ngUnsubscribe)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.subscribe({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
complete: () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.prepareSidebarData(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
error: (error) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
console.error('Error creating channel:', error); | ||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+195
to
+196
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Provide user feedback on channel creation errors Currently, when an error occurs in Apply this diff to display an error message: error: (error) => {
console.error('Error creating channel:', error);
+ this.alertService.error('An error occurred while creating the channel. Please try again.');
}, Ensure that 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
subscribeToQueryParameter() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.activatedRoute.queryParams.pipe(take(1), takeUntil(this.ngUnsubscribe)).subscribe((queryParams) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (queryParams.conversationId) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -276,7 +304,6 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
storageId: 'conversation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
groupedData: this.accordionConversationGroups, | ||||||||||||||||||||||||||||||||||||||||||||||||||
ungroupedData: this.sidebarConversations, | ||||||||||||||||||||||||||||||||||||||||||||||||||
showAccordionAddOption: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
showAccordionLeadingIcon: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -290,14 +317,20 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
this.courseOverviewService.setSidebarCollapseState('conversation', this.isCollapsed); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
onAccordionPlusButtonPressed(chatType: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (chatType === 'groupChats') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openCreateGroupChatDialog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} else if (chatType === 'directMessages') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openCreateOneToOneChatDialog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openChannelOverviewDialog(chatType); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
onCreateChannelPressed() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openCreateChannelDialog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
onCreateGroupChatPressed() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openCreateGroupChatDialog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
onCreateDirectChatPressed() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openCreateOneToOneChatDialog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
onBrowseChannelPressed() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.openChannelOverviewDialog(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
openCreateGroupChatDialog() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -338,8 +371,22 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
openChannelOverviewDialog(groupKey: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
const subType = this.getChannelSubType(groupKey); | ||||||||||||||||||||||||||||||||||||||||||||||||||
openCreateChannelDialog() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
const modalRef: NgbModalRef = this.modalService.open(ChannelsCreateDialogComponent, defaultSecondLayerDialogOptions); | ||||||||||||||||||||||||||||||||||||||||||||||||||
modalRef.componentInstance.course = this.course; | ||||||||||||||||||||||||||||||||||||||||||||||||||
modalRef.componentInstance.initialize(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
from(modalRef.result) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||
catchError(() => EMPTY), | ||||||||||||||||||||||||||||||||||||||||||||||||||
takeUntil(this.ngUnsubscribe), | ||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||
.subscribe((channel: ChannelDTO) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.channelActions$.next({ action: 'create', channel }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ensure consistency in action handling When emitting the channel action in |
||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle errors in In Modify the from(modalRef.result)
.pipe(
- catchError(() => EMPTY),
+ catchError((error) => {
+ console.error('Error in channel creation dialog:', error);
+ // Optionally, display an error message to the user
+ return EMPTY;
+ }),
takeUntil(this.ngUnsubscribe),
)
.subscribe((channel: ChannelDTO) => {
this.channelActions$.next({ action: 'create', channel });
}); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
openChannelOverviewDialog() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
const subType = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||
const modalRef: NgbModalRef = this.modalService.open(ChannelsOverviewDialogComponent, defaultFirstLayerDialogOptions); | ||||||||||||||||||||||||||||||||||||||||||||||||||
modalRef.componentInstance.course = this.course; | ||||||||||||||||||||||||||||||||||||||||||||||||||
modalRef.componentInstance.createChannelFn = subType === ChannelSubType.GENERAL ? this.metisConversationService.createChannel : undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -369,22 +416,6 @@ export class CourseConversationsComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
getChannelSubType(groupKey: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (groupKey === 'exerciseChannels') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ChannelSubType.EXERCISE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (groupKey === 'generalChannels') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ChannelSubType.GENERAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (groupKey === 'lectureChannels') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ChannelSubType.LECTURE; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
if (groupKey === 'examChannels') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ChannelSubType.EXAM; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
return ChannelSubType.GENERAL; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
toggleChannelSearch() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
this.channelSearchCollapsed = !this.channelSearchCollapsed; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { Component, Input, OnDestroy, OnInit } from '@angular/core'; | ||
import { EMPTY, Observable, Subject, debounceTime, distinctUntilChanged, finalize, from, map, takeUntil } from 'rxjs'; | ||
import { Observable, Subject, debounceTime, distinctUntilChanged, finalize, map, takeUntil } from 'rxjs'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Use single quotes for string literals in imports. To adhere to the coding guidelines, please use single quotes for string literals in import statements. Apply this change: -import { Observable, Subject, debounceTime, distinctUntilChanged, finalize, map, takeUntil } from 'rxjs';
+import { Observable, Subject, debounceTime, distinctUntilChanged, finalize, map, takeUntil } from 'rxjs';
-import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; Also applies to: 7-7 |
||
import { faChevronRight } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; | ||
import { onError } from 'app/shared/util/global.utils'; | ||
import { AlertService } from 'app/core/util/alert.service'; | ||
import { NgbActiveModal, NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; | ||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { ChannelService } from 'app/shared/metis/conversations/channel.service'; | ||
import { ChannelDTO, ChannelSubType } from 'app/entities/metis/conversation/channel.model'; | ||
import { Course } from 'app/entities/course.model'; | ||
import { ChannelsCreateDialogComponent } from 'app/overview/course-conversations/dialogs/channels-create-dialog/channels-create-dialog.component'; | ||
import { canCreateChannel } from 'app/shared/metis/conversations/conversation-permissions.utils'; | ||
import { AbstractDialogComponent } from 'app/overview/course-conversations/dialogs/abstract-dialog.component'; | ||
import { defaultSecondLayerDialogOptions } from 'app/overview/course-conversations/other/conversation.util'; | ||
import { catchError } from 'rxjs/operators'; | ||
|
||
export type ChannelActionType = 'register' | 'deregister' | 'view' | 'create'; | ||
export type ChannelAction = { | ||
|
@@ -44,12 +40,10 @@ export class ChannelsOverviewDialogComponent extends AbstractDialogComponent imp | |
channelModificationPerformed = false; | ||
isLoading = false; | ||
channels: ChannelDTO[] = []; | ||
otherChannels: ChannelDTO[] = []; | ||
|
||
isInitialized = false; | ||
|
||
faChevronRight = faChevronRight; | ||
otherChannelsAreCollapsed = true; | ||
|
||
initialize() { | ||
super.initialize(['course', 'channelSubType']); | ||
|
@@ -61,7 +55,6 @@ export class ChannelsOverviewDialogComponent extends AbstractDialogComponent imp | |
constructor( | ||
private channelService: ChannelService, | ||
private alertService: AlertService, | ||
private modalService: NgbModal, | ||
|
||
activeModal: NgbActiveModal, | ||
) { | ||
|
@@ -114,18 +107,6 @@ export class ChannelsOverviewDialogComponent extends AbstractDialogComponent imp | |
case 'view': | ||
this.close([channelAction.channel, this.channelModificationPerformed]); | ||
break; | ||
case 'create': | ||
if (this.createChannelFn) { | ||
this.createChannelFn(channelAction.channel) | ||
.pipe(takeUntil(this.ngUnsubscribe)) | ||
.subscribe({ | ||
complete: () => { | ||
this.loadChannelsOfCourse(); | ||
this.channelModificationPerformed = true; | ||
}, | ||
}); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
|
@@ -142,28 +123,12 @@ export class ChannelsOverviewDialogComponent extends AbstractDialogComponent imp | |
) | ||
.subscribe({ | ||
next: (channels: ChannelDTO[]) => { | ||
this.channels = channels?.filter((channel) => channel.subType === this.channelSubType) ?? []; | ||
this.otherChannels = channels?.filter((channel) => channel.subType !== this.channelSubType) ?? []; | ||
this.channels = channels; | ||
this.noOfChannels = this.channels.length; | ||
Comment on lines
+126
to
127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) LGTM! Consider enhancing error handling. The simplification of the Consider enhancing the error handling to provide more specific error messages, as suggested in the previous review: error: (errorResponse: HttpErrorResponse) => {
const errorMessage = errorResponse.error?.message || 'Failed to load channels';
this.alertService.error(errorMessage, null, null);
}, This change will provide more informative error messages to users when channel loading fails, improving the overall user experience. |
||
}, | ||
error: (errorResponse: HttpErrorResponse) => { | ||
onError(this.alertService, errorResponse); | ||
}, | ||
}); | ||
} | ||
|
||
openCreateChannelDialog(event: MouseEvent) { | ||
event.stopPropagation(); | ||
const modalRef: NgbModalRef = this.modalService.open(ChannelsCreateDialogComponent, defaultSecondLayerDialogOptions); | ||
modalRef.componentInstance.course = this.course; | ||
modalRef.componentInstance.initialize(); | ||
from(modalRef.result) | ||
.pipe( | ||
catchError(() => EMPTY), | ||
takeUntil(this.ngUnsubscribe), | ||
) | ||
.subscribe((channel: ChannelDTO) => { | ||
this.channelActions$.next({ action: 'create', channel }); | ||
}); | ||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you introduce extra methods for the consumption of OutputEvents it did not just call the already existing functions directly?