Skip to content

Commit

Permalink
Subscribe Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Aug 26, 2024
1 parent 32635f4 commit 3d954e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/dotnet/APIView/APIViewWeb/Managers/NotificationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ public async Task ToggleSubscribedAsync(ClaimsPrincipal user, string reviewId, b
var review = await _reviewRepository.GetReviewAsync(reviewId);
if (PageModelHelpers.IsUserSubscribed(user, review.Subscribers))
{
if (state == false)
if (state == true)
{
return; // already unsubscribed
return; // already subscribed
}

await UnsubscribeAsync(review, user);
}
else
{
if (state == true)
if (state == false)
{
return; // already subscribed
return; // already unsubscribed
}

await SubscribeAsync(review, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<app-page-options-section sectionName="Review Options">
<ul class="list-group">
<li class="list-group-item">
<p-inputSwitch [(ngModel)]="markedAsViewSwitch"
<p-inputSwitch [(ngModel)]="subscribeSwitch"
(onChange)="onSubscribeSwitchChange($event)" />
<label class="ms-2">Subscribe</label>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,28 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges{
}

ngOnChanges(changes: SimpleChanges) {
if (changes['diffStyleInput']) {
if (changes['diffStyleInput'] && changes['diffStyleInput'].currentValue != undefined) {
this.setSelectedDiffStyle();
}

if (changes['userProfile']) {
if (changes['userProfile'] && changes['userProfile'].currentValue != undefined) {
this.setSubscribeSwitch();
this.setMarkedAsViewSwitch();
this.setPageOptionValues();
}

if (changes['activeAPIRevision'] && changes['activeAPIRevision'].currentValue != undefined) {
this.markedAsViewSwitch = this.activeAPIRevision!.viewedBy.includes(this.userProfile?.userName!);
this.setMarkedAsViewSwitch();
this.selectedApprovers = this.activeAPIRevision!.assignedReviewers.map(reviewer => reviewer.assingedTo);
this.setAPIRevisionApprovalStates();
}

if (changes['diffAPIRevision']) {
if (changes['diffAPIRevision'] && changes['diffAPIRevision'].currentValue != undefined) {
this.setAPIRevisionApprovalStates();
}

if (changes['review']) {
this.subscribeSwitch = this.review!.subscribers.includes(this.userProfile?.userName!);
if (changes['review'] && changes['review'].currentValue != undefined) {
this.setSubscribeSwitch();
this.setReviewApprovalStatus();
}
}
Expand Down Expand Up @@ -273,6 +275,14 @@ export class ReviewPageOptionsComponent implements OnInit, OnChanges{
}
}

setSubscribeSwitch() {
this.subscribeSwitch = (this.userProfile && this.review) ? this.review!.subscribers.includes(this.userProfile?.email!) : this.subscribeSwitch;
}

setMarkedAsViewSwitch() {
this.markedAsViewSwitch = (this.activeAPIRevision && this.userProfile)? this.activeAPIRevision!.viewedBy.includes(this.userProfile?.userName!): this.markedAsViewSwitch;
}

handleAPIRevisionApprovalAction() {
if (!this.activeAPIRevisionIsApprovedByCurrentUser && (this.hasActiveConversation || this.hasFatalDiagnostics)) {
this.showAPIRevisionApprovalModal = true;
Expand Down

0 comments on commit 3d954e9

Please sign in to comment.