Merge pull request #5259 from 21pages/fix
try fix waiting for image when already shown
This commit is contained in:
commit
21850b4444
@ -689,9 +689,12 @@ class OverlayDialogManager {
|
||||
String showLoading(String text,
|
||||
{bool clickMaskDismiss = false,
|
||||
bool showCancel = true,
|
||||
VoidCallback? onCancel}) {
|
||||
final tag = _tagCount.toString();
|
||||
_tagCount++;
|
||||
VoidCallback? onCancel,
|
||||
String? tag}) {
|
||||
if (tag == null) {
|
||||
tag = _tagCount.toString();
|
||||
_tagCount++;
|
||||
}
|
||||
show((setState, close, context) {
|
||||
cancel() {
|
||||
dismissAll();
|
||||
|
@ -480,9 +480,11 @@ class FfiModel with ChangeNotifier {
|
||||
if (displays.isNotEmpty) {
|
||||
parent.target?.dialogManager.showLoading(
|
||||
translate('Connected, waiting for image...'),
|
||||
onCancel: closeConnection);
|
||||
onCancel: closeConnection,
|
||||
tag: '$peerId-waiting-for-image');
|
||||
_waitForImage[sessionId] = true;
|
||||
_reconnects = 1;
|
||||
bind.sessionOnWaitingForImageDialogShow(sessionId: sessionId);
|
||||
}
|
||||
Map<String, dynamic> features = json.decode(evt['features']);
|
||||
_pi.features.privacyMode = features['privacy_mode'] == 1;
|
||||
@ -636,6 +638,8 @@ class ImageModel with ChangeNotifier {
|
||||
if (waitforImage == true) {
|
||||
_waitForImage[sessionId] = false;
|
||||
parent.target?.dialogManager.dismissAll();
|
||||
clearWaitingForImage(parent.target?.dialogManager, id);
|
||||
|
||||
if (isDesktop) {
|
||||
for (final cb in callbacksOnFirstImage) {
|
||||
cb(id);
|
||||
@ -1681,6 +1685,7 @@ class FFI {
|
||||
}
|
||||
await canvasModel.updateViewStyle();
|
||||
await canvasModel.updateScrollStyle();
|
||||
clearWaitingForImage(dialogManager, id);
|
||||
}
|
||||
} else {
|
||||
// Fetch the image buffer from rust codes.
|
||||
@ -1873,3 +1878,12 @@ Future<void> initializeCursorAndCanvas(FFI ffi) async {
|
||||
ffi.ffiModel.display.x, ffi.ffiModel.display.y, xCursor, yCursor);
|
||||
ffi.canvasModel.update(xCanvas, yCanvas, scale);
|
||||
}
|
||||
|
||||
clearWaitingForImage(OverlayDialogManager? dialogManager, String id) {
|
||||
final durations = [100, 500, 1000, 2000];
|
||||
for (var duration in durations) {
|
||||
Future.delayed(Duration(milliseconds: duration), () {
|
||||
dialogManager?.dismissByTag('$id-waiting-for-image');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +337,14 @@ impl FlutterHandler {
|
||||
*self.notify_rendered.write().unwrap() = false;
|
||||
self.renderer.write().unwrap().set_size(width, height);
|
||||
}
|
||||
|
||||
pub fn on_waiting_for_image_dialog_show(&self) {
|
||||
#[cfg(any(feature = "flutter_texture_render"))]
|
||||
{
|
||||
*self.notify_rendered.write().unwrap() = false;
|
||||
}
|
||||
// rgba array render will notify every frame
|
||||
}
|
||||
}
|
||||
|
||||
impl InvokeUiSession for FlutterHandler {
|
||||
|
@ -1216,6 +1216,12 @@ pub fn session_change_prefer_codec(session_id: SessionID) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_on_waiting_for_image_dialog_show(session_id: SessionID) {
|
||||
if let Some(session) = SESSIONS.read().unwrap().get(&session_id) {
|
||||
session.ui_handler.on_waiting_for_image_dialog_show();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main_set_home_dir(_home: String) {
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user