Basic ass "display"
This commit is contained in:
@@ -21,6 +21,17 @@ class Game {
|
||||
this.lastUpdated = '',
|
||||
}) : _internalVersionRegex = RegExp(versionRegex);
|
||||
|
||||
factory Game.fromMap(Map<String, dynamic> map) {
|
||||
return Game(
|
||||
name: map['name'],
|
||||
versionRegex: map['version_regex'],
|
||||
lastPlayed: map['last_played'],
|
||||
rssFeedUrl: map['rss_feed_url'],
|
||||
actualVersion: map['actual_version'],
|
||||
lastUpdated: map['last_updated'],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateActualVersion() async {
|
||||
final response = await http.get(Uri.parse(rssFeedUrl));
|
||||
final document = RssFeed.parse(response.body);
|
||||
@@ -74,6 +85,14 @@ last_updated = excluded.last_updated
|
||||
);
|
||||
return game;
|
||||
}
|
||||
|
||||
static Future<List<Game>> getAll() async {
|
||||
final db = DB.db;
|
||||
final games = await db.rawQuery(
|
||||
'SELECT name, actual_version, last_played, rss_feed_url, version_regex, last_updated FROM games',
|
||||
);
|
||||
return games.map((e) => Game.fromMap(e)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
//CREATE TABLE IF NOT EXISTS games (
|
||||
|
Reference in New Issue
Block a user