mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 00:23:03 +00:00
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
/*
|
|
* Copyright (C) 2020-2021 StApps
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
* Software Foundation, version 3.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* 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 {Injectable} from '@angular/core';
|
|
import {SCMessage} from '@openstapps/core';
|
|
import {DataProvider} from '../data/data.provider';
|
|
/**
|
|
* Service for providing news messages
|
|
*/
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class NewsProvider {
|
|
constructor(private dataProvider: DataProvider) {
|
|
}
|
|
|
|
/**
|
|
* Get news messages
|
|
*
|
|
* @param size How many messages/news to fetch
|
|
*/
|
|
async getList(size: number): Promise<SCMessage[]> {
|
|
const result = await this.dataProvider.search({
|
|
filter: {
|
|
type: 'value',
|
|
arguments: {
|
|
field: 'type',
|
|
value: 'message',
|
|
},
|
|
},
|
|
sort: [{
|
|
type: 'generic',
|
|
arguments: {
|
|
field: 'datePublished',
|
|
},
|
|
order: 'desc',
|
|
}],
|
|
size: size,
|
|
});
|
|
|
|
return result.data as SCMessage[];
|
|
}
|
|
}
|