Merge pull request #2875 from NoelDeMartin/MOBILE-3320

MOBILE-3320: Calendar + Database fixes
main
Dani Palou 2021-07-06 13:09:01 +02:00 committed by GitHub
commit 27e7674183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 9 deletions

View File

@ -19,3 +19,4 @@ FROM nginx:alpine as serve-stage
# Copy assets & config # Copy assets & config
COPY --from=build-stage /app/www /usr/share/nginx/html COPY --from=build-stage /app/www /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/conf.d/default.conf COPY ./nginx.conf /etc/nginx/conf.d/default.conf
HEALTHCHECK --interval=10s --timeout=4s CMD curl -f http://localhost/assets/env.json || exit 1

View File

@ -450,8 +450,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
async submit(): Promise<void> { async submit(): Promise<void> {
// Validate data. // Validate data.
const formData = this.form.value; const formData = this.form.value;
const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart); const timeStartDate = CoreTimeUtils.convertToTimestamp(formData.timestart, true);
const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil); const timeUntilDate = CoreTimeUtils.convertToTimestamp(formData.timedurationuntil, true);
const timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10); const timeDurationMinutes = parseInt(formData.timedurationminutes || '', 10);
let error: string | undefined; let error: string | undefined;

View File

@ -498,9 +498,11 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
}; };
// Try to find page number and offset of the entry. // Try to find page number and offset of the entry.
const pageXOffset = this.entries.findIndex((entry) => entry.id == entryId); if (!this.search.searching) {
if (pageXOffset >= 0) { const pageXOffset = this.entries.findIndex((entry) => entry.id == entryId);
params.offset = this.search.page * AddonModDataProvider.PER_PAGE + pageXOffset; if (pageXOffset >= 0) {
params.offset = this.search.page * AddonModDataProvider.PER_PAGE + pageXOffset;
}
} }
CoreNavigator.navigateToSitePath( CoreNavigator.navigateToSitePath(

View File

@ -328,15 +328,23 @@ export class CoreTimeUtilsProvider {
/** /**
* Convert a text into user timezone timestamp. * Convert a text into user timezone timestamp.
* *
* @todo The `applyOffset` argument is only used as a workaround, it should be removed once
* MOBILE-3784 is resolved.
*
* @param date To convert to timestamp. * @param date To convert to timestamp.
* @param applyOffset Whether to apply offset to date or not.
* @return Converted timestamp. * @return Converted timestamp.
*/ */
convertToTimestamp(date: string): number { convertToTimestamp(date: string, applyOffset?: boolean): number {
if (typeof date == 'string' && date.slice(-1) == 'Z') { const timestamp = moment(date).unix();
return moment(date).unix() - (moment().utcOffset() * 60);
if (typeof applyOffset !== 'undefined') {
return applyOffset ? timestamp - moment().utcOffset() * 60 : timestamp;
} }
return moment(date).unix(); return typeof date == 'string' && date.slice(-1) == 'Z'
? timestamp - moment().utcOffset() * 60
: timestamp;
} }
/** /**