mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-04 20:30:35 +00:00
Added do not remember version
This commit is contained in:
parent
d9af69a240
commit
2ee2eafdca
4 changed files with 50 additions and 5 deletions
|
@ -120,7 +120,7 @@ class _BaseState extends State<Base> with WidgetsBindingObserver {
|
|||
|
||||
final result = await checkInstallationSource();
|
||||
|
||||
if (result != null) {
|
||||
if (result != null && widget.appConfigProvider.doNotRememberVersion != result.tagName) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => UpdateModal(
|
||||
|
|
|
@ -34,6 +34,8 @@ class AppConfigProvider with ChangeNotifier {
|
|||
|
||||
int _showNameTimeLogs = 0;
|
||||
|
||||
String? _doNotRememberVersion;
|
||||
|
||||
PackageInfo? get getAppInfo {
|
||||
return _appInfo;
|
||||
}
|
||||
|
@ -112,6 +114,10 @@ class AppConfigProvider with ChangeNotifier {
|
|||
return _showNameTimeLogs == 1 ? true : false;
|
||||
}
|
||||
|
||||
String? get doNotRememberVersion {
|
||||
return _doNotRememberVersion;
|
||||
}
|
||||
|
||||
void setDbInstance(Database db) {
|
||||
_dbInstance = db;
|
||||
}
|
||||
|
@ -237,6 +243,21 @@ class AppConfigProvider with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> setDoNotRememberVersion(String value) async {
|
||||
try {
|
||||
return await _dbInstance!.transaction((txn) async {
|
||||
await txn.rawUpdate(
|
||||
'UPDATE appConfig SET doNotRememberVersion = "$value"',
|
||||
);
|
||||
_doNotRememberVersion = value;
|
||||
notifyListeners();
|
||||
return true;
|
||||
});
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _updateThemeDb(int value) async {
|
||||
try {
|
||||
return await _dbInstance!.transaction((txn) async {
|
||||
|
@ -334,8 +355,9 @@ class AppConfigProvider with ChangeNotifier {
|
|||
_hideZeroValues = dbData['hideZeroValues'];
|
||||
_useDynamicColor = convertFromIntToBool(dbData['useDynamicColor'])!;
|
||||
_staticColor = dbData['staticColor'];
|
||||
_useThemeColorForStatus = convertFromIntToBool(dbData['useThemeColorForStatus'])!;
|
||||
_useThemeColorForStatus = dbData['useThemeColorForStatus'] != null ? convertFromIntToBool(dbData['useThemeColorForStatus'])! : false;
|
||||
_showNameTimeLogs = dbData['showNameTimeLogs'];
|
||||
_doNotRememberVersion = dbData['doNotRememberVersion'];
|
||||
|
||||
_dbInstance = dbInstance;
|
||||
notifyListeners();
|
||||
|
|
|
@ -61,12 +61,22 @@ Future<Map<String, dynamic>> loadDb(bool acceptsDynamicTheme) async {
|
|||
});
|
||||
}
|
||||
|
||||
Future upgradeDbToV7(Database db) async {
|
||||
await db.execute("ALTER TABLE appConfig ADD COLUMN doNotRememberVersion TEXT");
|
||||
|
||||
await db.transaction((txn) async{
|
||||
await txn.rawQuery(
|
||||
'SELECT * FROM appConfig',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Database db = await openDatabase(
|
||||
'adguard_home_manager.db',
|
||||
version: 6,
|
||||
version: 7,
|
||||
onCreate: (Database db, int version) async {
|
||||
await db.execute("CREATE TABLE servers (id TEXT PRIMARY KEY, name TEXT, connectionMethod TEXT, domain TEXT, path TEXT, port INTEGER, user TEXT, password TEXT, defaultServer INTEGER, authToken TEXT, runningOnHa INTEGER)");
|
||||
await db.execute("CREATE TABLE appConfig (theme NUMERIC, overrideSslCheck NUMERIC, hideZeroValues NUMERIC, useDynamicColor NUMERIC, staticColor NUMERIC, useThemeColorForStatus NUMERIC, showNameTimeLogs NUMERIC)");
|
||||
await db.execute("CREATE TABLE appConfig (theme NUMERIC, overrideSslCheck NUMERIC, hideZeroValues NUMERIC, useDynamicColor NUMERIC, staticColor NUMERIC, useThemeColorForStatus NUMERIC, showNameTimeLogs NUMERIC, doNotRememberVersion TEXT)");
|
||||
await db.execute("INSERT INTO appConfig (theme, overrideSslCheck, hideZeroValues, useDynamicColor, staticColor, useThemeColorForStatus, showNameTimeLogs) VALUES (0, 0, 0, ${acceptsDynamicTheme == true ? 1 : 0}, 0, 0, 0)");
|
||||
},
|
||||
onUpgrade: (Database db, int oldVersion, int newVersion) async {
|
||||
|
@ -76,24 +86,32 @@ Future<Map<String, dynamic>> loadDb(bool acceptsDynamicTheme) async {
|
|||
await upgradeDbToV4(db);
|
||||
await upgradeDbToV5(db);
|
||||
await upgradeDbToV6(db);
|
||||
await upgradeDbToV7(db);
|
||||
}
|
||||
if (oldVersion == 2) {
|
||||
await upgradeDbToV3(db);
|
||||
await upgradeDbToV4(db);
|
||||
await upgradeDbToV5(db);
|
||||
await upgradeDbToV6(db);
|
||||
await upgradeDbToV7(db);
|
||||
}
|
||||
if (oldVersion == 3) {
|
||||
await upgradeDbToV4(db);
|
||||
await upgradeDbToV5(db);
|
||||
await upgradeDbToV6(db);
|
||||
await upgradeDbToV7(db);
|
||||
}
|
||||
if (oldVersion == 4) {
|
||||
await upgradeDbToV5(db);
|
||||
await upgradeDbToV6(db);
|
||||
await upgradeDbToV7(db);
|
||||
}
|
||||
if (oldVersion == 5) {
|
||||
await upgradeDbToV6(db);
|
||||
await upgradeDbToV7(db);
|
||||
}
|
||||
if (oldVersion == 6) {
|
||||
await upgradeDbToV7(db);
|
||||
}
|
||||
},
|
||||
onOpen: (Database db) async {
|
||||
|
|
|
@ -88,7 +88,12 @@ class _UpdateModalState extends State<UpdateModal> {
|
|||
child: Text(AppLocalizations.of(context)!.download)
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: () {
|
||||
if (doNotRemember == true) {
|
||||
appConfigProvider.setDoNotRememberVersion(widget.gitHubRelease.tagName);
|
||||
}
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(AppLocalizations.of(context)!.close)
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue