Merge branch 'krille/bootstrap-on-update' into 'main'
refactor: Add reference to itself in bootstrap onUpdate callback Closes #319 See merge request famedly/company/frontend/famedlysdk!1098
This commit is contained in:
commit
f08d38ef6d
|
|
@ -79,7 +79,7 @@ class Encryption {
|
|||
}
|
||||
}
|
||||
|
||||
Bootstrap bootstrap({void Function()? onUpdate}) => Bootstrap(
|
||||
Bootstrap bootstrap({void Function(Bootstrap)? onUpdate}) => Bootstrap(
|
||||
encryption: this,
|
||||
onUpdate: onUpdate,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ enum BootstrapState {
|
|||
class Bootstrap {
|
||||
final Encryption encryption;
|
||||
Client get client => encryption.client;
|
||||
void Function()? onUpdate;
|
||||
void Function(Bootstrap)? onUpdate;
|
||||
BootstrapState get state => _state;
|
||||
BootstrapState _state = BootstrapState.loading;
|
||||
Map<String, OpenSSSS>? oldSsssKeys;
|
||||
|
|
@ -593,7 +593,7 @@ class Bootstrap {
|
|||
_state = newState;
|
||||
}
|
||||
|
||||
onUpdate?.call();
|
||||
onUpdate?.call(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ abstract class NativeImplementations {
|
|||
/// this implementation will catch any non-implemented method
|
||||
dynamic noSuchMethod(Invocation invocation) {
|
||||
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];
|
||||
|
||||
Logs().w(
|
||||
|
|
|
|||
|
|
@ -53,10 +53,7 @@ void main() {
|
|||
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
onUpdate: () async {
|
||||
while (bootstrap == null) {
|
||||
await Future.delayed(Duration(milliseconds: 5));
|
||||
}
|
||||
onUpdate: (bootstrap) async {
|
||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||
bootstrap.wipeSsss(true);
|
||||
} else if (bootstrap.state == BootstrapState.askNewSsss) {
|
||||
|
|
@ -111,10 +108,7 @@ void main() {
|
|||
if (!olmEnabled) return;
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
onUpdate: () async {
|
||||
while (bootstrap == null) {
|
||||
await Future.delayed(Duration(milliseconds: 5));
|
||||
}
|
||||
onUpdate: (bootstrap) async {
|
||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||
bootstrap.wipeSsss(false);
|
||||
} else if (bootstrap.state == BootstrapState.askUseExistingSsss) {
|
||||
|
|
@ -165,10 +159,7 @@ void main() {
|
|||
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
onUpdate: () async {
|
||||
while (bootstrap == null) {
|
||||
await Future.delayed(Duration(milliseconds: 5));
|
||||
}
|
||||
onUpdate: (bootstrap) async {
|
||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||
bootstrap.wipeSsss(false);
|
||||
} else if (bootstrap.state == BootstrapState.askUseExistingSsss) {
|
||||
|
|
@ -219,10 +210,7 @@ void main() {
|
|||
client.accountData.clear();
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
onUpdate: () async {
|
||||
while (bootstrap == null) {
|
||||
await Future.delayed(Duration(milliseconds: 5));
|
||||
}
|
||||
onUpdate: (bootstrap) async {
|
||||
if (bootstrap.state == BootstrapState.askNewSsss) {
|
||||
await bootstrap.newSsss('thenewestfoxies');
|
||||
} else if (bootstrap.state == BootstrapState.askSetupCrossSigning) {
|
||||
|
|
@ -248,10 +236,7 @@ void main() {
|
|||
var askedBadSsss = false;
|
||||
Bootstrap? bootstrap;
|
||||
bootstrap = client.encryption!.bootstrap(
|
||||
onUpdate: () async {
|
||||
while (bootstrap == null) {
|
||||
await Future.delayed(Duration(milliseconds: 5));
|
||||
}
|
||||
onUpdate: (bootstrap) async {
|
||||
if (bootstrap.state == BootstrapState.askWipeSsss) {
|
||||
bootstrap.wipeSsss(false);
|
||||
} else if (bootstrap.state == BootstrapState.askBadSsss) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue