mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-02-24 00:40:00 -05:00
simplify config and fix refresh
This commit is contained in:
parent
c9e0831555
commit
d3cdca17c5
@ -343,13 +343,14 @@ class AccountRepository {
|
|||||||
|
|
||||||
await _userLogins.set(newUserLogins);
|
await _userLogins.set(newUserLogins);
|
||||||
await _activeLocalAccount.set(identityMaster.masterRecordKey);
|
await _activeLocalAccount.set(identityMaster.masterRecordKey);
|
||||||
_streamController
|
|
||||||
..add(AccountRepositoryChange.userLogins)
|
|
||||||
..add(AccountRepositoryChange.activeLocalAccount);
|
|
||||||
|
|
||||||
// Ensure all logins are opened
|
// Ensure all logins are opened
|
||||||
await _openLoggedInDHTRecords();
|
await _openLoggedInDHTRecords();
|
||||||
|
|
||||||
|
_streamController
|
||||||
|
..add(AccountRepositoryChange.userLogins)
|
||||||
|
..add(AccountRepositoryChange.activeLocalAccount);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ class DHTRecordPool with TableDBBacked<DHTRecordPoolAllocations> {
|
|||||||
subkeys: allSubkeys, expiration: maxExpiration, count: totalCount);
|
subkeys: allSubkeys, expiration: maxExpiration, count: totalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateWatchExpirations(
|
void _updateWatchRealExpirations(
|
||||||
Iterable<DHTRecord> records, Timestamp realExpiration) {
|
Iterable<DHTRecord> records, Timestamp realExpiration) {
|
||||||
for (final rec in records) {
|
for (final rec in records) {
|
||||||
final ws = rec.watchState;
|
final ws = rec.watchState;
|
||||||
@ -636,7 +636,7 @@ class DHTRecordPool with TableDBBacked<DHTRecordPoolAllocations> {
|
|||||||
// Update watch states with real expiration
|
// Update watch states with real expiration
|
||||||
if (realExpiration.value != BigInt.zero) {
|
if (realExpiration.value != BigInt.zero) {
|
||||||
openedRecordInfo.shared.needsWatchStateUpdate = false;
|
openedRecordInfo.shared.needsWatchStateUpdate = false;
|
||||||
_updateWatchExpirations(
|
_updateWatchRealExpirations(
|
||||||
openedRecordInfo.records, realExpiration);
|
openedRecordInfo.records, realExpiration);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ class DHTShortArray {
|
|||||||
for (final skr in subkeys) {
|
for (final skr in subkeys) {
|
||||||
for (var subkey = skr.low; subkey <= skr.high; subkey++) {
|
for (var subkey = skr.low; subkey <= skr.high; subkey++) {
|
||||||
// Skip head subkey
|
// Skip head subkey
|
||||||
if (subkey == 0) {
|
if (updateHead && subkey == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Get the subkey, which caches the result in the local record store
|
// Get the subkey, which caches the result in the local record store
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:veilid/veilid.dart';
|
import 'package:veilid/veilid.dart';
|
||||||
|
import 'dart:io' show Platform;
|
||||||
|
|
||||||
Map<String, dynamic> getDefaultVeilidPlatformConfig(
|
Map<String, dynamic> getDefaultVeilidPlatformConfig(
|
||||||
bool isWeb, String appName) {
|
bool isWeb, String appName) {
|
||||||
@ -43,8 +44,18 @@ Map<String, dynamic> getDefaultVeilidPlatformConfig(
|
|||||||
.toJson();
|
.toJson();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<VeilidConfig> getVeilidConfig(bool isWeb, String appName) async {
|
Future<VeilidConfig> getVeilidConfig(bool isWeb, String programName) async {
|
||||||
var config = await getDefaultVeilidConfig(appName);
|
var config = await getDefaultVeilidConfig(
|
||||||
|
isWeb: isWeb,
|
||||||
|
programName: programName,
|
||||||
|
// ignore: avoid_redundant_argument_values, do_not_use_environment
|
||||||
|
namespace: const String.fromEnvironment('NAMESPACE'),
|
||||||
|
// ignore: avoid_redundant_argument_values, do_not_use_environment
|
||||||
|
bootstrap: const String.fromEnvironment('BOOTSTRAP'),
|
||||||
|
// ignore: avoid_redundant_argument_values, do_not_use_environment
|
||||||
|
networkKeyPassword: const String.fromEnvironment('NETWORK_KEY'),
|
||||||
|
);
|
||||||
|
|
||||||
// ignore: do_not_use_environment
|
// ignore: do_not_use_environment
|
||||||
if (const String.fromEnvironment('DELETE_TABLE_STORE') == '1') {
|
if (const String.fromEnvironment('DELETE_TABLE_STORE') == '1') {
|
||||||
config =
|
config =
|
||||||
@ -73,35 +84,12 @@ Future<VeilidConfig> getVeilidConfig(bool isWeb, String appName) async {
|
|||||||
config.network.routingTable.copyWith(bootstrap: bootstrap)));
|
config.network.routingTable.copyWith(bootstrap: bootstrap)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: do_not_use_environment
|
|
||||||
const envNetworkKey = String.fromEnvironment('NETWORK_KEY');
|
|
||||||
if (envNetworkKey.isNotEmpty) {
|
|
||||||
config = config.copyWith(
|
|
||||||
network: config.network.copyWith(networkKeyPassword: envNetworkKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
// ignore: do_not_use_environment
|
|
||||||
const envBootstrap = String.fromEnvironment('BOOTSTRAP');
|
|
||||||
if (envBootstrap.isNotEmpty) {
|
|
||||||
final bootstrap = envBootstrap.split(',').map((e) => e.trim()).toList();
|
|
||||||
config = config.copyWith(
|
|
||||||
network: config.network.copyWith(
|
|
||||||
routingTable:
|
|
||||||
config.network.routingTable.copyWith(bootstrap: bootstrap)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return config.copyWith(
|
return config.copyWith(
|
||||||
capabilities:
|
capabilities:
|
||||||
// XXX: Remove DHTV and DHTW when we get background sync implemented
|
// XXX: Remove DHTV and DHTW when we get background sync implemented
|
||||||
const VeilidConfigCapabilities(disable: ['DHTV', 'DHTW', 'TUNL']),
|
const VeilidConfigCapabilities(disable: ['DHTV', 'DHTW', 'TUNL']),
|
||||||
protectedStore: config.protectedStore.copyWith(allowInsecureFallback: true),
|
protectedStore:
|
||||||
// network: config.network.copyWith(
|
// XXX: Linux often does not have a secret storage mechanism installed
|
||||||
// dht: config.network.dht.copyWith(
|
config.protectedStore.copyWith(allowInsecureFallback: Platform.isLinux),
|
||||||
// getValueCount: 3,
|
|
||||||
// getValueFanout: 8,
|
|
||||||
// getValueTimeoutMs: 5000,
|
|
||||||
// setValueCount: 4,
|
|
||||||
// setValueFanout: 10,
|
|
||||||
// setValueTimeoutMs: 5000))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user