mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-16 18:47:28 -05:00
Add support for per-feed user agent
This commit is contained in:
@@ -1,22 +1,31 @@
|
||||
using FeedCenter.Data;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FeedCenter.Data;
|
||||
using FeedCenter.Options;
|
||||
using Realms;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace FeedCenter;
|
||||
|
||||
public class FeedCenterEntities
|
||||
{
|
||||
public Realm RealmInstance { get; }
|
||||
|
||||
public RealmObservableCollection<Category> Categories { get; }
|
||||
public RealmObservableCollection<Feed> Feeds { get; private set; }
|
||||
public RealmObservableCollection<Setting> Settings { get; private set; }
|
||||
|
||||
public FeedCenterEntities()
|
||||
{
|
||||
var realmConfiguration = new RealmConfiguration($"{Database.DatabaseFile}");
|
||||
var realmConfiguration = new RealmConfiguration($"{Database.DatabaseFile}")
|
||||
{
|
||||
SchemaVersion = 1,
|
||||
MigrationCallback = (migration, oldSchemaVersion) =>
|
||||
{
|
||||
var newVersionFeeds = migration.NewRealm.All<Feed>();
|
||||
|
||||
foreach (var newVersionFeed in newVersionFeeds)
|
||||
{
|
||||
if (oldSchemaVersion == 0)
|
||||
{
|
||||
newVersionFeed.UserAgent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RealmInstance = Realm.GetInstance(realmConfiguration);
|
||||
|
||||
@@ -30,6 +39,17 @@ public class FeedCenterEntities
|
||||
}
|
||||
}
|
||||
|
||||
public RealmObservableCollection<Category> Categories { get; }
|
||||
|
||||
public Category DefaultCategory
|
||||
{
|
||||
get { return Categories.First(c => c.IsDefault); }
|
||||
}
|
||||
|
||||
public RealmObservableCollection<Feed> Feeds { get; private set; }
|
||||
private Realm RealmInstance { get; }
|
||||
public RealmObservableCollection<Setting> Settings { get; private set; }
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
RealmInstance.Refresh();
|
||||
@@ -44,9 +64,4 @@ public class FeedCenterEntities
|
||||
{
|
||||
return RealmInstance.BeginWrite();
|
||||
}
|
||||
|
||||
public Category DefaultCategory
|
||||
{
|
||||
get { return Categories.First(c => c.IsDefault); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user