Skip to content

Commit b18e58f

Browse files
authored
Merge pull request #4592 from crazyserver/MOBILE-4842
MOBILE-4842 calendar: Fix leaving edit view when offline
2 parents 5492206 + 033639f commit b18e58f

File tree

42 files changed

+71
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+71
-77
lines changed

src/addons/calendar/pages/edit-event/edit-event.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ import { DEFAULT_TEXT_FORMAT } from '@singletons/text';
7171
})
7272
export default class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
7373

74-
readonly descriptionEditor = viewChild.required(CoreEditorRichTextEditorComponent);
75-
readonly formElement = viewChild.required<ElementRef<HTMLFormElement>>('editEventForm');
74+
readonly formElement = viewChild<ElementRef<HTMLFormElement>>('editEventForm');
7675

7776
title = 'addon.calendar.newevent';
7877
component = ADDON_CALENDAR_COMPONENT;
@@ -160,8 +159,6 @@ export default class AddonCalendarEditEventPage implements OnInit, OnDestroy, Ca
160159

161160
/**
162161
* Fetch the data needed to render the form.
163-
*
164-
* @returns Promise resolved when done.
165162
*/
166163
protected async fetchData(): Promise<void> {
167164
this.error = false;
@@ -448,7 +445,6 @@ export default class AddonCalendarEditEventPage implements OnInit, OnDestroy, Ca
448445
* Load groups of a certain course.
449446
*
450447
* @param courseId Course ID.
451-
* @returns Promise resolved when done.
452448
*/
453449
protected async loadGroups(courseId: number): Promise<void> {
454450
this.loadingGroups = true;
@@ -629,8 +625,6 @@ export default class AddonCalendarEditEventPage implements OnInit, OnDestroy, Ca
629625

630626
/**
631627
* Init reminders.
632-
*
633-
* @returns Promise resolved when done.
634628
*/
635629
protected async initReminders(): Promise<void> {
636630
// Don't init reminders when editing an event. Right now, only allow adding reminders for new events.

src/addons/calendar/pages/event/event.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ <h1>
1616
<core-context-menu-item [hidden]="!eventLoaded || (!hasOffline && event && !event.deleted) || !isOnline()" [priority]="400"
1717
[content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(undefined, $event, true)"
1818
[iconAction]="syncIcon" [closeOnClick]="false" />
19-
<core-context-menu-item [hidden]="!event || !event.canedit || event.deleted || (!canEdit && event.id > 0)" [priority]="300"
20-
[content]="'core.edit' | translate" (action)="openEdit()" iconAction="fas-pen" />
19+
<core-context-menu-item [hidden]="!event || !event.canedit || event.deleted || (!canEdit && event.id > 0) || !isOnline()"
20+
[priority]="300" [content]="'core.edit' | translate" (action)="openEdit()" iconAction="fas-pen" />
2121
<core-context-menu-item [hidden]="!event || !event.candelete || event.deleted" [priority]="200"
2222
[content]="'core.delete' | translate" (action)="deleteEvent()" iconAction="fas-trash" />
2323
<core-context-menu-item [hidden]="!event || !event.deleted" [priority]="200" [content]="'core.restore' | translate"

src/addons/messages/pages/discussion/discussion.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import { CoreSharedModule } from '@/core/shared.module';
7070
})
7171
export default class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterViewInit {
7272

73-
readonly content = viewChild(IonContent);
73+
readonly content = viewChild.required(IonContent);
7474
readonly infinite = viewChild(CoreInfiniteLoadingComponent);
7575

7676
protected fetching = false;
@@ -174,7 +174,7 @@ export default class AddonMessagesDiscussionPage implements OnInit, OnDestroy, A
174174
* @inheritdoc
175175
*/
176176
async ngAfterViewInit(): Promise<void> {
177-
this.scrollElement = await this.content()?.getScrollElement();
177+
this.scrollElement = await this.content().getScrollElement();
178178
}
179179

180180
/**
@@ -878,7 +878,7 @@ export default class AddonMessagesDiscussionPage implements OnInit, OnDestroy, A
878878
const newScrollHeight = (this.scrollElement?.scrollHeight || 0);
879879
const scrollTo = newScrollHeight - oldScrollBottom + infiniteHeight;
880880

881-
this.content()?.scrollToPoint(0, scrollTo, 0);
881+
this.content().scrollToPoint(0, scrollTo, 0);
882882
}, 30);
883883
}, 30);
884884
}

src/addons/messages/pages/group-conversations/group-conversations.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const enum AddonMessagesGroupConversationOptionNames {
7373
export default class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy {
7474

7575
readonly splitView = viewChild.required(CoreSplitViewComponent);
76-
readonly content = viewChild(IonContent);
76+
readonly content = viewChild.required(IonContent);
7777
readonly accordionGroup = viewChild.required<IonAccordionGroup>('accordionGroup');
7878

7979
loaded = false;
@@ -189,7 +189,7 @@ export default class AddonMessagesGroupConversationsPage implements OnInit, OnDe
189189

190190
if (isNewer) {
191191
// The last message is newer than the previous one, scroll to top to keep viewing the conversation.
192-
this.content()?.scrollToTop();
192+
this.content().scrollToTop();
193193
}
194194
}
195195
},

src/addons/mod/assign/pages/index/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class AddonModAssignIndexPage extends CoreCourseModuleMainActivit
3535

3636
private action?: string;
3737

38-
readonly activityComponent = viewChild(AddonModAssignIndexComponent);
38+
readonly activityComponent = viewChild.required(AddonModAssignIndexComponent);
3939

4040
constructor() {
4141
super();
@@ -49,8 +49,8 @@ export default class AddonModAssignIndexPage extends CoreCourseModuleMainActivit
4949
async ngAfterViewInit(): Promise<void> {
5050
switch (this.action) {
5151
case 'editsubmission':
52-
await CoreWait.waitFor(() => !!this.activityComponent()?.submissionComponent(), { timeout: 5000 });
53-
await this.activityComponent()?.submissionComponent()?.goToEdit();
52+
await CoreWait.waitFor(() => !!this.activityComponent().submissionComponent(), { timeout: 5000 });
53+
await this.activityComponent().submissionComponent()?.goToEdit();
5454

5555
break;
5656
}

src/addons/mod/assign/submission/comments/component/comments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { ADDON_MOD_ASSIGN_COMMENTS_AREA, ADDON_MOD_ASSIGN_COMMENTS_COMPONENT_NAM
3333
})
3434
export class AddonModAssignSubmissionCommentsComponent extends AddonModAssignSubmissionPluginBaseComponent {
3535

36-
readonly commentsComponent = viewChild.required(CoreCommentsCommentsComponent);
36+
readonly commentsComponent = viewChild(CoreCommentsCommentsComponent);
3737

3838
commentsEnabled: boolean;
3939

src/addons/mod/bigbluebuttonbn/pages/index/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ import { CoreSharedModule } from '@/core/shared.module';
3030
})
3131
export default class AddonModBBBIndexPage extends CoreCourseModuleMainActivityPage<AddonModBBBIndexComponent> {
3232

33-
readonly activityComponent = viewChild(AddonModBBBIndexComponent);
33+
readonly activityComponent = viewChild.required(AddonModBBBIndexComponent);
3434

3535
}

src/addons/mod/book/pages/index/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ import { CoreSharedModule } from '@/core/shared.module';
3030
})
3131
export default class AddonModBookIndexPage extends CoreCourseModuleMainActivityPage<AddonModBookIndexComponent> {
3232

33-
readonly activityComponent = viewChild(AddonModBookIndexComponent);
33+
readonly activityComponent = viewChild.required(AddonModBookIndexComponent);
3434

3535
}

src/addons/mod/chat/pages/chat/chat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave
4949

5050
protected static readonly POLL_INTERVAL = 4000;
5151

52-
readonly content = viewChild(IonContent);
52+
readonly content = viewChild.required(IonContent);
5353
readonly sendMessageForm = viewChild(CoreSendMessageFormComponent);
5454

5555
loaded = false;
@@ -360,7 +360,7 @@ export default class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave
360360
// Need a timeout to leave time to the view to be rendered.
361361
await CoreWait.nextTick();
362362
if (!this.viewDestroyed) {
363-
this.content()?.scrollToBottom();
363+
this.content().scrollToBottom();
364364
}
365365
}
366366

src/addons/mod/chat/pages/index/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ import { CoreSharedModule } from '@/core/shared.module';
3030
})
3131
export default class AddonModChatIndexPage extends CoreCourseModuleMainActivityPage<AddonModChatIndexComponent> {
3232

33-
readonly activityComponent = viewChild(AddonModChatIndexComponent);
33+
readonly activityComponent = viewChild.required(AddonModChatIndexComponent);
3434

3535
}

0 commit comments

Comments
 (0)