forked from cwtch.im/cwtch-ui
Clarify Offline Mode Behaviour
This commit is contained in:
parent
51f07cffd5
commit
69b7ddb2c1
|
@ -36,6 +36,7 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
bool _autostart = true;
|
||||
bool _enabled = false;
|
||||
bool _appearOffline = false;
|
||||
bool _appearOfflineAtStartup = false;
|
||||
|
||||
ProfileInfoState({
|
||||
required this.onion,
|
||||
|
@ -62,6 +63,7 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
this._enabled = true;
|
||||
}
|
||||
this._appearOffline = appearOffline;
|
||||
this._appearOfflineAtStartup = appearOffline;
|
||||
this._encrypted = encrypted;
|
||||
|
||||
_contacts.connectServers(this._servers);
|
||||
|
@ -185,6 +187,12 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get appearOfflineAtStartup => this._appearOfflineAtStartup;
|
||||
set appearOfflineAtStartup(bool newVal) {
|
||||
this._appearOfflineAtStartup = newVal;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get appearOffline => this._appearOffline;
|
||||
set appearOffline(bool newVal) {
|
||||
this._appearOffline = newVal;
|
||||
|
|
|
@ -276,19 +276,12 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
|
|||
child: SwitchListTile(
|
||||
title: Text(AppLocalizations.of(context)!.profileOfflineAtStart, style: TextStyle(color: Provider.of<Settings>(context).current().mainTextColor)),
|
||||
subtitle: Text(AppLocalizations.of(context)!.profileAppearOfflineDescription),
|
||||
value: Provider.of<ProfileInfoState>(context).appearOffline,
|
||||
value: Provider.of<ProfileInfoState>(context).appearOfflineAtStartup,
|
||||
onChanged: (bool value) {
|
||||
Provider.of<ProfileInfoState>(context, listen: false).appearOffline = value;
|
||||
Provider.of<ProfileInfoState>(context, listen: false).appearOfflineAtStartup = value;
|
||||
var onion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||
if (!onion.isEmpty) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(onion, "profile.appear-offline", value ? "true" : "false");
|
||||
// if the profile is already enabled, then cycle the peer engine...
|
||||
if (value == true && Provider.of<ProfileInfoState>(context, listen: false).enabled) {
|
||||
Provider.of<ProfileInfoState>(context, listen: false).deactivatePeerEngine(context);
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.ConfigureConnections(onion, false, false, false);
|
||||
} else {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.ConfigureConnections(onion, true, true, true);
|
||||
}
|
||||
}
|
||||
},
|
||||
activeTrackColor: Provider.of<Settings>(context).theme.defaultButtonColor,
|
||||
|
|
Loading…
Reference in New Issue