From e1e2b839332bef8b29ceaecf269b1939ada7a87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Fri, 25 Oct 2019 12:32:28 +0200 Subject: [PATCH] MOBILE-3205 forum: Save forum discussion sorting --- .../mod/forum/pages/discussion/discussion.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/addon/mod/forum/pages/discussion/discussion.ts b/src/addon/mod/forum/pages/discussion/discussion.ts index dec2adf0a..b4b5d424d 100644 --- a/src/addon/mod/forum/pages/discussion/discussion.ts +++ b/src/addon/mod/forum/pages/discussion/discussion.ts @@ -131,13 +131,17 @@ export class AddonModForumDiscussionPage implements OnDestroy { * View loaded. */ ionViewDidLoad(): void { - this.fetchPosts(true, false, true).then(() => { - if (this.postId) { - // Scroll to the post. - setTimeout(() => { - this.domUtils.scrollToElementBySelector(this.content, '#addon-mod_forum-post-' + this.postId); - }); - } + this.sitesProvider.getCurrentSite().getLocalSiteConfig('AddonModForumDiscussionSort', this.sort).then((value) => { + this.sort = value; + }).finally(() => { + this.fetchPosts(true, false, true).then(() => { + if (this.postId) { + // Scroll to the post. + setTimeout(() => { + this.domUtils.scrollToElementBySelector(this.content, '#addon-mod_forum-post-' + this.postId); + }); + } + }); }); } @@ -513,6 +517,7 @@ export class AddonModForumDiscussionPage implements OnDestroy { changeSort(type: SortType): Promise { this.discussionLoaded = false; this.sort = type; + this.sitesProvider.getCurrentSite().setLocalSiteConfig('AddonModForumDiscussionSort', this.sort); this.domUtils.scrollToTop(this.content); return this.fetchPosts();