Merge pull request #5425 from 21pages/ab
fix searching alias doesn't take effect in address book
This commit is contained in:
commit
81bf4bc028
@ -1352,7 +1352,7 @@ Future<bool> matchPeer(String searchText, Peer peer) async {
|
||||
peer.username.toLowerCase().contains(searchText)) {
|
||||
return true;
|
||||
}
|
||||
final alias = await bind.mainGetPeerOption(id: peer.id, key: 'alias');
|
||||
final alias = peer.alias;
|
||||
if (alias.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
@ -659,6 +659,7 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
if (newName != oldName) {
|
||||
if (tab == PeerTabIndex.ab) {
|
||||
gFFI.abModel.changeAlias(id: id, alias: newName);
|
||||
await bind.mainSetPeerAlias(id: id, alias: newName);
|
||||
gFFI.abModel.pushAb();
|
||||
} else {
|
||||
await bind.mainSetPeerAlias(id: id, alias: newName);
|
||||
@ -713,16 +714,8 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
case PeerTabIndex.ab:
|
||||
gFFI.abModel.deletePeer(id);
|
||||
final future = gFFI.abModel.pushAb();
|
||||
if (shouldSyncAb() && await bind.mainPeerExists(id: peer.id)) {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
final succ = await future;
|
||||
if (succ) {
|
||||
await Future.delayed(Duration(seconds: 2)); // success msg
|
||||
BotToast.showText(
|
||||
contentColor: Colors.lightBlue,
|
||||
text: translate('synced_peer_readded_tip'));
|
||||
}
|
||||
});
|
||||
if (await bind.mainPeerExists(id: peer.id)) {
|
||||
gFFI.abModel.reSyncToast(future);
|
||||
}
|
||||
break;
|
||||
case PeerTabIndex.group:
|
||||
@ -748,9 +741,15 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
translate('Unremember Password'),
|
||||
style: style,
|
||||
),
|
||||
proc: () {
|
||||
bind.mainForgetPassword(id: id);
|
||||
showToast(translate('Successful'));
|
||||
proc: () async {
|
||||
if (tab == PeerTabIndex.ab) {
|
||||
gFFI.abModel.unrememberPassword(id);
|
||||
await bind.mainForgetPassword(id: id);
|
||||
gFFI.abModel.pushAb();
|
||||
} else {
|
||||
bind.mainForgetPassword(id: id);
|
||||
showToast(translate('Successful'));
|
||||
}
|
||||
},
|
||||
padding: menuPadding,
|
||||
dismissOnClicked: true,
|
||||
@ -1046,7 +1045,7 @@ class AddressBookPeerCard extends BasePeerCard {
|
||||
}
|
||||
menuItems.add(MenuEntryDivider());
|
||||
menuItems.add(_renameAction(peer.id));
|
||||
if (await bind.mainPeerHasPassword(id: peer.id)) {
|
||||
if (peer.hash.isNotEmpty) {
|
||||
menuItems.add(_unrememberPasswordAction(peer.id));
|
||||
}
|
||||
if (gFFI.abModel.tags.isNotEmpty) {
|
||||
|
@ -345,16 +345,7 @@ class _PeerTabPageState extends State<PeerTabPage>
|
||||
gFFI.abModel.deletePeers(peers.map((p) => p.id).toList());
|
||||
final future = gFFI.abModel.pushAb();
|
||||
if (hasSynced) {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
final succ = await future;
|
||||
if (succ) {
|
||||
await Future.delayed(
|
||||
Duration(seconds: 2)); // success msg
|
||||
BotToast.showText(
|
||||
contentColor: Colors.lightBlue,
|
||||
text: translate('synced_peer_readded_tip'));
|
||||
}
|
||||
});
|
||||
gFFI.abModel.reSyncToast(future);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -212,6 +212,14 @@ class AbModel {
|
||||
it.first.alias = alias;
|
||||
}
|
||||
|
||||
void unrememberPassword(String id) {
|
||||
final it = peers.where((element) => element.id == id);
|
||||
if (it.isEmpty) {
|
||||
return;
|
||||
}
|
||||
it.first.hash = '';
|
||||
}
|
||||
|
||||
Future<bool> pushAb(
|
||||
{bool toastIfFail = true,
|
||||
bool toastIfSucc = true,
|
||||
@ -508,4 +516,17 @@ class AbModel {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
reSyncToast(Future<bool> future) {
|
||||
if (!shouldSyncAb()) return;
|
||||
Future.delayed(Duration.zero, () async {
|
||||
final succ = await future;
|
||||
if (succ) {
|
||||
await Future.delayed(Duration(seconds: 2)); // success msg
|
||||
BotToast.showText(
|
||||
contentColor: Colors.lightBlue,
|
||||
text: translate('synced_peer_readded_tip'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -197,17 +197,18 @@ class ServerModel with ChangeNotifier {
|
||||
_approveMode = approveMode;
|
||||
update = true;
|
||||
}
|
||||
final oldPwdText = _serverPasswd.text;
|
||||
if (_serverPasswd.text != temporaryPassword &&
|
||||
temporaryPassword.isNotEmpty) {
|
||||
_serverPasswd.text = temporaryPassword;
|
||||
}
|
||||
var stopped = option2bool(
|
||||
"stop-service", await bind.mainGetOption(key: "stop-service"));
|
||||
final oldPwdText = _serverPasswd.text;
|
||||
if (stopped ||
|
||||
verificationMethod == kUsePermanentPassword ||
|
||||
_approveMode == 'click') {
|
||||
_serverPasswd.text = '-';
|
||||
} else {
|
||||
if (_serverPasswd.text != temporaryPassword &&
|
||||
temporaryPassword.isNotEmpty) {
|
||||
_serverPasswd.text = temporaryPassword;
|
||||
}
|
||||
}
|
||||
if (oldPwdText != _serverPasswd.text) {
|
||||
update = true;
|
||||
|
Loading…
Reference in New Issue
Block a user