MOBILE-2486 forum: Invalidate discussion when a rating is updated
This commit is contained in:
		
							parent
							
								
									f6c2babd77
								
							
						
					
					
						commit
						8fe3e09e9b
					
				@ -23,7 +23,7 @@
 | 
				
			|||||||
        </ng-container>
 | 
					        </ng-container>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
</ion-card-content>
 | 
					</ion-card-content>
 | 
				
			||||||
<core-rating-rate *ngIf="forum && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="componentId" [itemId]="post.id" [itemSetId]="discussionId" [courseId]="courseId" [aggregateMethod]="forum.assessed" [scaleId]="forum.scale" [userId]="post.userid"></core-rating-rate>
 | 
					<core-rating-rate *ngIf="forum && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="componentId" [itemId]="post.id" [itemSetId]="discussionId" [courseId]="courseId" [aggregateMethod]="forum.assessed" [scaleId]="forum.scale" [userId]="post.userid" (onUpdate)="ratingUpdated()"></core-rating-rate>
 | 
				
			||||||
<core-rating-aggregate *ngIf="forum && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="componentId" [itemId]="post.id" [courseId]="courseId" [aggregateMethod]="forum.assessed" [scaleId]="forum.scale"></core-rating-aggregate>
 | 
					<core-rating-aggregate *ngIf="forum && ratingInfo" [ratingInfo]="ratingInfo" contextLevel="module" [instanceId]="componentId" [itemId]="post.id" [courseId]="courseId" [aggregateMethod]="forum.assessed" [scaleId]="forum.scale"></core-rating-aggregate>
 | 
				
			||||||
<ion-item no-padding text-end *ngIf="post.id && post.canreply" class="addon-forum-reply-button">
 | 
					<ion-item no-padding text-end *ngIf="post.id && post.canreply" class="addon-forum-reply-button">
 | 
				
			||||||
    <button ion-button icon-left clear small (click)="showReply()" [attr.aria-controls]="'addon-forum-reply-edit-form-' + uniqueId" [attr.aria-expanded]="replyData.replyingTo === post.id">
 | 
					    <button ion-button icon-left clear small (click)="showReply()" [attr.aria-controls]="'addon-forum-reply-edit-form-' + uniqueId" [attr.aria-expanded]="replyData.replyingTo === post.id">
 | 
				
			||||||
 | 
				
			|||||||
@ -307,6 +307,13 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Function called when rating is updated online.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    ratingUpdated(): void {
 | 
				
			||||||
 | 
					        this.forumProvider.invalidateDiscussionPosts(this.discussionId);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Component being destroyed.
 | 
					     * Component being destroyed.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@
 | 
				
			|||||||
// See the License for the specific language governing permissions and
 | 
					// See the License for the specific language governing permissions and
 | 
				
			||||||
// limitations under the License.
 | 
					// limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { Component, Input, OnChanges, SimpleChange } from '@angular/core';
 | 
					import { Component, EventEmitter, Input, OnChanges, Output, SimpleChange  } from '@angular/core';
 | 
				
			||||||
import { TranslateService } from '@ngx-translate/core';
 | 
					import { TranslateService } from '@ngx-translate/core';
 | 
				
			||||||
import { CoreRatingProvider, CoreRatingInfo, CoreRatingInfoItem, CoreRatingScale } from '@core/rating/providers/rating';
 | 
					import { CoreRatingProvider, CoreRatingInfo, CoreRatingInfoItem, CoreRatingScale } from '@core/rating/providers/rating';
 | 
				
			||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
 | 
					import { CoreDomUtilsProvider } from '@providers/utils/dom';
 | 
				
			||||||
@ -35,13 +35,16 @@ export class CoreRatingRateComponent implements OnChanges {
 | 
				
			|||||||
    @Input() aggregateMethod: number;
 | 
					    @Input() aggregateMethod: number;
 | 
				
			||||||
    @Input() scaleId: number;
 | 
					    @Input() scaleId: number;
 | 
				
			||||||
    @Input() userId: number;
 | 
					    @Input() userId: number;
 | 
				
			||||||
 | 
					    @Output() onUpdate: EventEmitter<void>; // Event emitted when the rating is updated online.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    item: CoreRatingInfoItem;
 | 
					    item: CoreRatingInfoItem;
 | 
				
			||||||
    scale: CoreRatingScale;
 | 
					    scale: CoreRatingScale;
 | 
				
			||||||
    rating: number;
 | 
					    rating: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(private domUtils: CoreDomUtilsProvider, private translate: TranslateService,
 | 
					    constructor(private domUtils: CoreDomUtilsProvider, private translate: TranslateService,
 | 
				
			||||||
            private ratingProvider: CoreRatingProvider, private ratingOffline: CoreRatingOfflineProvider) {}
 | 
					            private ratingProvider: CoreRatingProvider, private ratingOffline: CoreRatingOfflineProvider) {
 | 
				
			||||||
 | 
					        this.onUpdate = new EventEmitter<void>();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Detect changes on input properties.
 | 
					     * Detect changes on input properties.
 | 
				
			||||||
@ -96,6 +99,8 @@ export class CoreRatingRateComponent implements OnChanges {
 | 
				
			|||||||
                .then((response) => {
 | 
					                .then((response) => {
 | 
				
			||||||
            if (response == null) {
 | 
					            if (response == null) {
 | 
				
			||||||
                this.domUtils.showToast('core.datastoredoffline', true, 3000);
 | 
					                this.domUtils.showToast('core.datastoredoffline', true, 3000);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                this.onUpdate.emit();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }).catch((error) => {
 | 
					        }).catch((error) => {
 | 
				
			||||||
            this.domUtils.showErrorModal(error);
 | 
					            this.domUtils.showErrorModal(error);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user