MOBILE-3833 comments: Don't display Sync option in offline
parent
ef834b34ea
commit
525218a4a0
|
@ -18,7 +18,7 @@
|
|||
<core-context-menu-item [hidden]="!(commentsLoaded && !hasOffline)" [priority]="100" [content]="'core.refresh' | translate"
|
||||
(action)="refreshComments(false)" [iconAction]="refreshIcon" [closeOnClick]="true">
|
||||
</core-context-menu-item>
|
||||
<core-context-menu-item [hidden]="!(commentsLoaded && hasOffline)" [priority]="100"
|
||||
<core-context-menu-item [hidden]="!(commentsLoaded && hasOffline && isOnline)" [priority]="100"
|
||||
[content]="'core.settings.synchronizenow' | translate" (action)="refreshComments(true)" [iconAction]="syncIcon"
|
||||
[closeOnClick]="false">
|
||||
</core-context-menu-item>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<core-loading [hideUntil]="commentsLoaded">
|
||||
<core-empty-box *ngIf="!comments || !comments.length" icon="fas-comments" [message]="'core.comments.nocomments' | translate">
|
||||
<core-empty-box *ngIf="!comments?.length && !offlineComment" icon="fas-comments" [message]="'core.comments.nocomments' | translate">
|
||||
</core-empty-box>
|
||||
|
||||
<!-- Load previous messages. -->
|
||||
|
|
|
@ -30,7 +30,7 @@ import {
|
|||
import { IonContent, IonRefresher } from '@ionic/angular';
|
||||
import { ContextLevel, CoreConstants } from '@/core/constants';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { Translate } from '@singletons';
|
||||
import { Network, NgZone, Translate } from '@singletons';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUser } from '@features/user/services/user';
|
||||
|
@ -41,6 +41,7 @@ import { CoreCommentsDBRecord } from '@features/comments/services/database/comme
|
|||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreApp } from '@services/app';
|
||||
import moment from 'moment';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Page that displays comments.
|
||||
|
@ -77,9 +78,11 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
|||
currentUserId: number;
|
||||
sending = false;
|
||||
newComment = '';
|
||||
isOnline: boolean;
|
||||
|
||||
protected addDeleteCommentsAvailable = false;
|
||||
protected syncObserver?: CoreEventObserver;
|
||||
protected onlineObserver: Subscription;
|
||||
protected viewDestroyed = false;
|
||||
|
||||
constructor(
|
||||
|
@ -104,6 +107,14 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
|||
this.fetchComments(false);
|
||||
}
|
||||
}, CoreSites.getCurrentSiteId());
|
||||
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||
// Execute the callback in the Angular zone, so change detection doesn't stop working.
|
||||
NgZone.run(() => {
|
||||
this.isOnline = CoreApp.isOnline();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -596,6 +607,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
|||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.syncObserver?.off();
|
||||
this.onlineObserver.unsubscribe();
|
||||
this.viewDestroyed = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue