fix more bool options (#8809)
* fix more bool options * hide sort ab tags because it's already sorted Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
parent
79a1f888d6
commit
c04f460bbd
@ -425,7 +425,8 @@ class _AddressBookState extends State<AddressBook> {
|
||||
if (canWrite) getEntry(translate("Add ID"), addIdToCurrentAb),
|
||||
if (canWrite) getEntry(translate("Add Tag"), abAddTag),
|
||||
getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags),
|
||||
sortMenuItem(),
|
||||
if (gFFI.abModel.legacyMode.value)
|
||||
sortMenuItem(), // It's already sorted after pulling down
|
||||
if (canWrite) syncMenuItem(),
|
||||
filterMenuItem(),
|
||||
if (!gFFI.abModel.legacyMode.value && canWrite)
|
||||
|
@ -636,8 +636,8 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
|
||||
@protected
|
||||
Future<bool> _isForceAlwaysRelay(String id) async {
|
||||
return (await bind.mainGetPeerOption(id: id, key: kOptionForceAlwaysRelay))
|
||||
.isNotEmpty;
|
||||
return option2bool(kOptionForceAlwaysRelay,
|
||||
(await bind.mainGetPeerOption(id: id, key: kOptionForceAlwaysRelay)));
|
||||
}
|
||||
|
||||
@protected
|
||||
|
@ -17,17 +17,17 @@ import '../common.dart';
|
||||
|
||||
final syncAbOption = 'sync-ab-with-recent-sessions';
|
||||
bool shouldSyncAb() {
|
||||
return bind.mainGetLocalOption(key: syncAbOption).isNotEmpty;
|
||||
return bind.mainGetLocalOption(key: syncAbOption) == 'Y';
|
||||
}
|
||||
|
||||
final sortAbTagsOption = 'sync-ab-tags';
|
||||
bool shouldSortTags() {
|
||||
return bind.mainGetLocalOption(key: sortAbTagsOption).isNotEmpty;
|
||||
return bind.mainGetLocalOption(key: sortAbTagsOption) == 'Y';
|
||||
}
|
||||
|
||||
final filterAbTagOption = 'filter-ab-by-intersection';
|
||||
bool filterAbTagByIntersection() {
|
||||
return bind.mainGetLocalOption(key: filterAbTagOption).isNotEmpty;
|
||||
return bind.mainGetLocalOption(key: filterAbTagOption) == 'Y';
|
||||
}
|
||||
|
||||
const _personalAddressBookName = "My address book";
|
||||
@ -815,8 +815,6 @@ abstract class BaseAb {
|
||||
}
|
||||
|
||||
class LegacyAb extends BaseAb {
|
||||
final sortTags = shouldSortTags().obs;
|
||||
final filterByIntersection = filterAbTagByIntersection().obs;
|
||||
bool get emtpy => peers.isEmpty && tags.isEmpty;
|
||||
// licensedDevices is obtained from personal ab, shared ab restrict it in server
|
||||
var licensedDevices = 0;
|
||||
@ -1209,8 +1207,6 @@ class LegacyAb extends BaseAb {
|
||||
class Ab extends BaseAb {
|
||||
AbProfile profile;
|
||||
late final bool personal;
|
||||
final sortTags = shouldSortTags().obs;
|
||||
final filterByIntersection = filterAbTagByIntersection().obs;
|
||||
bool get emtpy => peers.isEmpty && tags.isEmpty;
|
||||
|
||||
Ab(this.profile, this.personal);
|
||||
|
@ -196,7 +196,7 @@ class ServerModel with ChangeNotifier {
|
||||
bind.mainSetOption(key: kOptionEnableAudio, value: "N");
|
||||
} else {
|
||||
final audioOption = await bind.mainGetOption(key: kOptionEnableAudio);
|
||||
_audioOk = audioOption.isEmpty;
|
||||
_audioOk = audioOption != 'N';
|
||||
}
|
||||
|
||||
// file
|
||||
@ -206,7 +206,7 @@ class ServerModel with ChangeNotifier {
|
||||
} else {
|
||||
final fileOption =
|
||||
await bind.mainGetOption(key: kOptionEnableFileTransfer);
|
||||
_fileOk = fileOption.isEmpty;
|
||||
_fileOk = fileOption != 'N';
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
@ -12,7 +12,10 @@ use uuid::Uuid;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
anyhow::{self, bail},
|
||||
config::{self, Config, CONNECT_TIMEOUT, READ_TIMEOUT, REG_INTERVAL, RENDEZVOUS_PORT},
|
||||
config::{
|
||||
self, keys::*, option2bool, Config, CONNECT_TIMEOUT, READ_TIMEOUT, REG_INTERVAL,
|
||||
RENDEZVOUS_PORT,
|
||||
},
|
||||
futures::future::join_all,
|
||||
log,
|
||||
protobuf::Message as _,
|
||||
@ -637,8 +640,10 @@ async fn direct_server(server: ServerPtr) {
|
||||
let mut listener = None;
|
||||
let mut port = 0;
|
||||
loop {
|
||||
let disabled = Config::get_option("direct-server").is_empty()
|
||||
|| !Config::get_option("stop-service").is_empty();
|
||||
let disabled = !option2bool(
|
||||
OPTION_DIRECT_SERVER,
|
||||
&Config::get_option(OPTION_DIRECT_SERVER),
|
||||
) || option2bool("stop-service", &Config::get_option("stop-service"));
|
||||
if !disabled && listener.is_none() {
|
||||
port = get_direct_port();
|
||||
match hbb_common::tcp::listen_any(port as _).await {
|
||||
|
@ -1149,7 +1149,7 @@ function showSettings() {
|
||||
function checkConnectStatus() {
|
||||
handler.check_mouse_time(); // trigger connection status updater
|
||||
self.timer(1s, function() {
|
||||
var tmp = !!handler.get_option("stop-service");
|
||||
var tmp = handler.get_option("stop-service") == "Y";
|
||||
if (tmp != service_stopped) {
|
||||
service_stopped = tmp;
|
||||
app.update();
|
||||
|
@ -21,7 +21,7 @@ use clipboard::ContextSend;
|
||||
use hbb_common::tokio::sync::mpsc::unbounded_channel;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::Config,
|
||||
config::{keys::*, option2bool, Config},
|
||||
fs::is_write_need_confirmation,
|
||||
fs::{self, get_string, new_send_confirm, DigestCheckResult},
|
||||
log,
|
||||
@ -583,9 +583,10 @@ pub async fn start_ipc<T: InvokeUiCM>(cm: ConnectionManager<T>) {
|
||||
feature = "unix-file-copy-paste"
|
||||
),
|
||||
))]
|
||||
ContextSend::enable(
|
||||
Config::get_option(hbb_common::config::keys::OPTION_ENABLE_FILE_TRANSFER).is_empty(),
|
||||
);
|
||||
ContextSend::enable(option2bool(
|
||||
OPTION_ENABLE_FILE_TRANSFER,
|
||||
&Config::get_option(OPTION_ENABLE_FILE_TRANSFER),
|
||||
));
|
||||
|
||||
match ipc::new_listener("_cm").await {
|
||||
Ok(mut incoming) => {
|
||||
|
@ -3,7 +3,10 @@ use hbb_common::password_security;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
bytes::Bytes,
|
||||
config::{self, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT, RENDEZVOUS_PORT},
|
||||
config::{
|
||||
self, keys::*, option2bool, Config, LocalConfig, PeerConfig, CONNECT_TIMEOUT,
|
||||
RENDEZVOUS_PORT,
|
||||
},
|
||||
directories_next,
|
||||
futures::future::join_all,
|
||||
log,
|
||||
@ -1156,9 +1159,9 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
|
||||
)
|
||||
))]
|
||||
{
|
||||
let b = OPTIONS.lock().unwrap().get(config::keys::OPTION_ENABLE_FILE_TRANSFER).map(|x| x.to_string()).unwrap_or_default();
|
||||
let b = OPTIONS.lock().unwrap().get(OPTION_ENABLE_FILE_TRANSFER).map(|x| x.to_string()).unwrap_or_default();
|
||||
if b != enable_file_transfer {
|
||||
clipboard::ContextSend::enable(b.is_empty());
|
||||
clipboard::ContextSend::enable(option2bool(OPTION_ENABLE_FILE_TRANSFER, &b));
|
||||
enable_file_transfer = b;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user