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