mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
refactor: sort news by datePublished on backend
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component} from '@angular/core';
|
||||
import {IonRefresher} from '@ionic/angular';
|
||||
import {SCMessage} from '@openstapps/core';
|
||||
import {NewsProvider} from '../news.provider';
|
||||
@@ -23,20 +23,21 @@ import {NewsProvider} from '../news.provider';
|
||||
selector: 'stapps-news-page',
|
||||
templateUrl: 'news-page.html',
|
||||
})
|
||||
export class NewsPageComponent implements OnInit {
|
||||
export class NewsPageComponent {
|
||||
/**
|
||||
* News (messages) to show
|
||||
*/
|
||||
news: SCMessage[] = [];
|
||||
|
||||
constructor(private newsProvider: NewsProvider) {}
|
||||
constructor(private newsProvider: NewsProvider) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch news from the backend
|
||||
*/
|
||||
async fetchNews() {
|
||||
/* eslint-disable no-magic-numbers */
|
||||
this.news = await this.newsProvider.getList(30, true);
|
||||
/* tslint:disable:no-magic-numbers */
|
||||
this.news = await this.newsProvider.getList(30);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,7 @@ export class NewsPageComponent implements OnInit {
|
||||
async refresh(refresher: IonRefresher) {
|
||||
try {
|
||||
await this.fetchNews();
|
||||
} catch {
|
||||
} catch (e) {
|
||||
this.news = [];
|
||||
} finally {
|
||||
await refresher.complete();
|
||||
|
||||
Reference in New Issue
Block a user