From 63bff7c4f84afa9bc7f82c7ecda0f65abf29c839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 13 Dec 2019 10:29:10 +0100 Subject: [PATCH 1/6] MOBILE-3213 forum: Fix discussion links when nested view is on --- .../mod/forum/pages/discussion/discussion.ts | 18 +++++++++++------- .../forum/providers/discussion-link-handler.ts | 2 +- src/addon/mod/forum/providers/forum.ts | 9 ++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/addon/mod/forum/pages/discussion/discussion.ts b/src/addon/mod/forum/pages/discussion/discussion.ts index cc4cd42f6..e49b8684d 100644 --- a/src/addon/mod/forum/pages/discussion/discussion.ts +++ b/src/addon/mod/forum/pages/discussion/discussion.ts @@ -326,10 +326,17 @@ export class AddonModForumDiscussionPage implements OnDestroy { }).then(() => { let posts = offlineReplies.concat(onlinePosts); + const startingPost = this.forumProvider.extractStartingPost(posts); + if (startingPost) { + // Update discussion data from first post. + this.discussion = Object.assign(this.discussion || {}, startingPost); + } + // If sort type is nested, normal sorting is disabled and nested posts will be displayed. if (this.sort == 'nested') { // Sort first by creation date to make format tree work. this.forumProvider.sortDiscussionPosts(posts, 'ASC'); + posts = this.utils.formatTree(posts, 'parent', 'id', this.discussion.id); } else { // Set default reply subject. @@ -364,7 +371,7 @@ export class AddonModForumDiscussionPage implements OnDestroy { } })); - // Fetch the discussion if not passed as parameter. + // The discussion object was not passed as parameter and there is no starting post. Should not happen. if (!this.discussion) { promises.push(this.loadDiscussion(this.forumId, this.discussionId)); } @@ -373,12 +380,9 @@ export class AddonModForumDiscussionPage implements OnDestroy { }).catch(() => { // Ignore errors. }).then(() => { - const startingPost = this.forumProvider.extractStartingPost(posts); - if (startingPost) { - // Update discussion data from first post. - this.discussion = Object.assign(this.discussion || {}, startingPost); - } else if (!this.discussion) { - // The discussion object was not passed as parameter and there is no starting post. + + if (!this.discussion) { + // The discussion object was not passed as parameter and there is no starting post. Should not happen. return Promise.reject('Invalid forum discussion.'); } diff --git a/src/addon/mod/forum/providers/discussion-link-handler.ts b/src/addon/mod/forum/providers/discussion-link-handler.ts index e884b6545..546e477f0 100644 --- a/src/addon/mod/forum/providers/discussion-link-handler.ts +++ b/src/addon/mod/forum/providers/discussion-link-handler.ts @@ -51,7 +51,7 @@ export class AddonModForumDiscussionLinkHandler extends CoreContentLinksHandlerB return [{ action: (siteId, navCtrl?): void => { const pageParams: any = { - courseId: courseId || parseInt(params.courseid, 10) || parseInt(params.cid, 10), + courseId: courseId || parseInt(params.courseid, 10) || parseInt(params.cid, 10) || undefined, discussionId: parseInt(params.d, 10), cmId: data.cmid && parseInt(data.cmid, 10), forumId: data.instance && parseInt(data.instance, 10) diff --git a/src/addon/mod/forum/providers/forum.ts b/src/addon/mod/forum/providers/forum.ts index a852c2aec..96fd64ce1 100644 --- a/src/addon/mod/forum/providers/forum.ts +++ b/src/addon/mod/forum/providers/forum.ts @@ -278,14 +278,9 @@ export class AddonModForumProvider { * @return Starting post or undefined if not found. */ extractStartingPost(posts: any[]): any { - // Check the last post first, since they'll usually be ordered by create time. - for (let i = posts.length - 1; i >= 0; i--) { - if (posts[i].parent == 0) { - return posts.splice(i, 1).pop(); // Remove it from the array. - } - } + const index = posts.findIndex((post) => post.parent == 0); - return undefined; + return index >= 0 ? posts.splice(index, 1).pop() : undefined; } /** From 438ae42a169ba6e3885e64797b95901628519fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 13 Dec 2019 11:10:28 +0100 Subject: [PATCH 2/6] MOBILE-3213 style: Fix some darkmode styles --- src/app/app.scss | 5 +++++ src/components/rich-text-editor/rich-text-editor.scss | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/app.scss b/src/app/app.scss index a77cf58e8..6e71d9caf 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -367,6 +367,9 @@ ion-app.app-root { color: $black; border-radius: 5px; background: rgba(255, 255, 255, .5); + @include darkmode() { + background-color: rgba(0, 0, 0, .5); + } text-align: center; width: 32px; @@ -376,6 +379,8 @@ ion-app.app-root { font-size: 24px; ion-icon { font-size: 24px; + + } } diff --git a/src/components/rich-text-editor/rich-text-editor.scss b/src/components/rich-text-editor/rich-text-editor.scss index d4ba94b06..e2dd2ac07 100644 --- a/src/components/rich-text-editor/rich-text-editor.scss +++ b/src/components/rich-text-editor/rich-text-editor.scss @@ -7,7 +7,7 @@ ion-app.app-root core-rich-text-editor { display: flex; flex-direction: column; @include darkmode() { - background-color: $black; + background-color: $gray-darker; } .core-rte-editor, .core-textarea { @@ -17,7 +17,7 @@ ion-app.app-root core-rich-text-editor { resize: none; background-color: $white; @include darkmode() { - background-color: $black; + background-color: $gray-darker; color: $white; } } From 9ee135e0b59504ddf20c3ff0fa6da402cca24c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 13 Dec 2019 12:13:33 +0100 Subject: [PATCH 3/6] MOBILE-3213 settings: Hide space usage values when loading --- src/core/settings/pages/space-usage/space-usage.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/settings/pages/space-usage/space-usage.html b/src/core/settings/pages/space-usage/space-usage.html index a21f0208d..f4d247a89 100644 --- a/src/core/settings/pages/space-usage/space-usage.html +++ b/src/core/settings/pages/space-usage/space-usage.html @@ -12,8 +12,8 @@

{{ site.fullName }}

-

{{ site.spaceUsage | coreBytesToSize }}

-

{{ 'core.settings.entriesincache' | translate: { $a: site.cacheEntries } }}

+

{{ site.spaceUsage | coreBytesToSize }}

+

{{ 'core.settings.entriesincache' | translate: { $a: site.cacheEntries } }}