fix saving peer window pos

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-08-10 19:48:26 +08:00
parent a1095b8844
commit 7921be45f5
4 changed files with 23 additions and 13 deletions

View File

@ -1436,7 +1436,7 @@ Future _saveSessionWindowPosition(
windowId, kWindowEventGetRemoteList, null);
if (remoteList != null) {
for (final peerId in remoteList.split(',')) {
bind.sessionSetFlutterConfigByPeerId(
bind.mainSetPeerFlutterConfigSync(
id: peerId, k: kWindowPrefix + windowType.name, v: pos.toString());
}
}

View File

@ -1214,7 +1214,11 @@ impl LoginConfigHandler {
/// * `v` - value of option
pub fn save_ui_flutter(&mut self, k: String, v: String) {
let mut config = self.load_config();
if v.is_empty() {
config.ui_flutter.remove(&k);
} else {
config.ui_flutter.insert(k, v);
}
self.save_config(config);
}

View File

@ -219,17 +219,6 @@ pub fn session_get_flutter_config_by_peer_id(id: String, k: String) -> Option<St
}
}
pub fn session_set_flutter_config_by_peer_id(id: String, k: String, v: String) {
if let Some((_, session)) = SESSIONS
.write()
.unwrap()
.iter_mut()
.find(|(_, s)| s.id == id)
{
session.save_flutter_config(k, v);
}
}
pub fn get_next_texture_key() -> SyncReturn<i32> {
let k = TEXTURE_RENDER_KEY.fetch_add(1, Ordering::SeqCst) + 1;
SyncReturn(k)
@ -812,6 +801,11 @@ pub fn main_get_peer_flutter_config_sync(id: String, k: String) -> SyncReturn<St
SyncReturn(get_peer_flutter_config(id, k))
}
pub fn main_set_peer_flutter_config_sync(id: String, k: String, v: String) -> SyncReturn<()> {
set_peer_flutter_config(id, k, v);
SyncReturn(())
}
pub fn main_set_peer_option(id: String, key: String, value: String) {
set_peer_option(id, key, value)
}

View File

@ -215,6 +215,18 @@ pub fn get_peer_flutter_config(id: String, name: String) -> String {
c.ui_flutter.get(&name).unwrap_or(&"".to_owned()).to_owned()
}
#[inline]
#[cfg(feature = "flutter")]
pub fn set_peer_flutter_config(id: String, name: String, value: String) {
let mut c = PeerConfig::load(&id);
if value.is_empty() {
c.ui_flutter.remove(&name);
} else {
c.ui_flutter.insert(name, value);
}
c.store(&id);
}
#[inline]
pub fn set_peer_option(id: String, name: String, value: String) {
let mut c = PeerConfig::load(&id);