refactor: Add reference to itself in bootstrap onUpdate callback
This commit is contained in:
parent
eed3587cb6
commit
527bcc63ad
|
|
@ -79,7 +79,7 @@ class Encryption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bootstrap bootstrap({void Function()? onUpdate}) => Bootstrap(
|
Bootstrap bootstrap({void Function(Bootstrap)? onUpdate}) => Bootstrap(
|
||||||
encryption: this,
|
encryption: this,
|
||||||
onUpdate: onUpdate,
|
onUpdate: onUpdate,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ enum BootstrapState {
|
||||||
class Bootstrap {
|
class Bootstrap {
|
||||||
final Encryption encryption;
|
final Encryption encryption;
|
||||||
Client get client => encryption.client;
|
Client get client => encryption.client;
|
||||||
void Function()? onUpdate;
|
void Function(Bootstrap)? onUpdate;
|
||||||
BootstrapState get state => _state;
|
BootstrapState get state => _state;
|
||||||
BootstrapState _state = BootstrapState.loading;
|
BootstrapState _state = BootstrapState.loading;
|
||||||
Map<String, OpenSSSS>? oldSsssKeys;
|
Map<String, OpenSSSS>? oldSsssKeys;
|
||||||
|
|
@ -593,7 +593,7 @@ class Bootstrap {
|
||||||
_state = newState;
|
_state = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdate?.call();
|
onUpdate?.call(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ abstract class NativeImplementations {
|
||||||
/// this implementation will catch any non-implemented method
|
/// this implementation will catch any non-implemented method
|
||||||
dynamic noSuchMethod(Invocation invocation) {
|
dynamic noSuchMethod(Invocation invocation) {
|
||||||
final dynamic argument = invocation.positionalArguments.single;
|
final dynamic argument = invocation.positionalArguments.single;
|
||||||
final bool retryInDummy = invocation.namedArguments['retryInDummy'] as bool;
|
final retryInDummy = invocation.namedArguments['retryInDummy'] as bool;
|
||||||
final memberName = invocation.memberName.toString().split('"')[1];
|
final memberName = invocation.memberName.toString().split('"')[1];
|
||||||
|
|
||||||
Logs().w(
|
Logs().w(
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,7 @@ void main() {
|
||||||
|
|
||||||
Bootstrap? bootstrap;
|
Bootstrap? bootstrap;
|
||||||
bootstrap = client.encryption!.bootstrap(
|
bootstrap = client.encryption!.bootstrap(
|
||||||
onUpdate: () async {
|
onUpdate: (bootstrap) async {
|
||||||
while (bootstrap == null) {
|
|
||||||
await Future.delayed(Duration(milliseconds: 5));
|
|
||||||
}
|
|
||||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||||
bootstrap.wipeSsss(true);
|
bootstrap.wipeSsss(true);
|
||||||
} else if (bootstrap.state == BootstrapState.askNewSsss) {
|
} else if (bootstrap.state == BootstrapState.askNewSsss) {
|
||||||
|
|
@ -111,10 +108,7 @@ void main() {
|
||||||
if (!olmEnabled) return;
|
if (!olmEnabled) return;
|
||||||
Bootstrap? bootstrap;
|
Bootstrap? bootstrap;
|
||||||
bootstrap = client.encryption!.bootstrap(
|
bootstrap = client.encryption!.bootstrap(
|
||||||
onUpdate: () async {
|
onUpdate: (bootstrap) async {
|
||||||
while (bootstrap == null) {
|
|
||||||
await Future.delayed(Duration(milliseconds: 5));
|
|
||||||
}
|
|
||||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||||
bootstrap.wipeSsss(false);
|
bootstrap.wipeSsss(false);
|
||||||
} else if (bootstrap.state == BootstrapState.askUseExistingSsss) {
|
} else if (bootstrap.state == BootstrapState.askUseExistingSsss) {
|
||||||
|
|
@ -165,10 +159,7 @@ void main() {
|
||||||
|
|
||||||
Bootstrap? bootstrap;
|
Bootstrap? bootstrap;
|
||||||
bootstrap = client.encryption!.bootstrap(
|
bootstrap = client.encryption!.bootstrap(
|
||||||
onUpdate: () async {
|
onUpdate: (bootstrap) async {
|
||||||
while (bootstrap == null) {
|
|
||||||
await Future.delayed(Duration(milliseconds: 5));
|
|
||||||
}
|
|
||||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||||
bootstrap.wipeSsss(false);
|
bootstrap.wipeSsss(false);
|
||||||
} else if (bootstrap.state == BootstrapState.askUseExistingSsss) {
|
} else if (bootstrap.state == BootstrapState.askUseExistingSsss) {
|
||||||
|
|
@ -219,10 +210,7 @@ void main() {
|
||||||
client.accountData.clear();
|
client.accountData.clear();
|
||||||
Bootstrap? bootstrap;
|
Bootstrap? bootstrap;
|
||||||
bootstrap = client.encryption!.bootstrap(
|
bootstrap = client.encryption!.bootstrap(
|
||||||
onUpdate: () async {
|
onUpdate: (bootstrap) async {
|
||||||
while (bootstrap == null) {
|
|
||||||
await Future.delayed(Duration(milliseconds: 5));
|
|
||||||
}
|
|
||||||
if (bootstrap.state == BootstrapState.askNewSsss) {
|
if (bootstrap.state == BootstrapState.askNewSsss) {
|
||||||
await bootstrap.newSsss('thenewestfoxies');
|
await bootstrap.newSsss('thenewestfoxies');
|
||||||
} else if (bootstrap.state == BootstrapState.askSetupCrossSigning) {
|
} else if (bootstrap.state == BootstrapState.askSetupCrossSigning) {
|
||||||
|
|
@ -248,10 +236,7 @@ void main() {
|
||||||
var askedBadSsss = false;
|
var askedBadSsss = false;
|
||||||
Bootstrap? bootstrap;
|
Bootstrap? bootstrap;
|
||||||
bootstrap = client.encryption!.bootstrap(
|
bootstrap = client.encryption!.bootstrap(
|
||||||
onUpdate: () async {
|
onUpdate: (bootstrap) async {
|
||||||
while (bootstrap == null) {
|
|
||||||
await Future.delayed(Duration(milliseconds: 5));
|
|
||||||
}
|
|
||||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||||
bootstrap.wipeSsss(false);
|
bootstrap.wipeSsss(false);
|
||||||
} else if (bootstrap.state == BootstrapState.askBadSsss) {
|
} else if (bootstrap.state == BootstrapState.askBadSsss) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue