Fix. Text clipboard is not working correctly (#7226)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-02-22 13:44:44 +08:00 committed by GitHub
parent d7d7be9366
commit 09325fadaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 13 deletions

View File

@ -702,12 +702,9 @@ impl Client {
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn try_stop_clipboard(_self_id: &str) {
fn try_stop_clipboard() {
#[cfg(feature = "flutter")]
if crate::flutter::sessions::other_sessions_running(
_self_id.to_string(),
ConnType::DEFAULT_CONN,
) {
if crate::flutter::sessions::has_sessions_running(ConnType::DEFAULT_CONN) {
return;
}
TEXT_CLIPBOARD_STATE.lock().unwrap().running = false;

View File

@ -286,7 +286,7 @@ impl<T: InvokeUiSession> Remote<T> {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
if _set_disconnected_ok {
Client::try_stop_clipboard(&self.handler.get_id());
Client::try_stop_clipboard();
}
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]

View File

@ -1790,13 +1790,10 @@ pub mod sessions {
#[inline]
#[cfg(not(any(target_os = "android", target_os = "ios")))]
pub fn other_sessions_running(peer_id: String, conn_type: ConnType) -> bool {
SESSIONS
.read()
.unwrap()
.get(&(peer_id, conn_type))
.map(|s| s.session_handlers.read().unwrap().len() != 0)
.unwrap_or(false)
pub fn has_sessions_running(conn_type: ConnType) -> bool {
SESSIONS.read().unwrap().iter().any(|((_, r#type), s)| {
*r#type == conn_type && s.session_handlers.read().unwrap().len() != 0
})
}
}