diff --git a/client/lib/models/app_state.dart b/client/lib/models/app_state.dart index 7562c51e4..6df49fc82 100644 --- a/client/lib/models/app_state.dart +++ b/client/lib/models/app_state.dart @@ -13,6 +13,7 @@ class AppState extends Equatable { final Uri? pageUri; final String sessionId; final bool isLoading; + final int reconnectingTimeout; final String error; final Size size; final String sizeBreakpoint; @@ -23,6 +24,7 @@ class AppState extends Equatable { {required this.pageUri, required this.sessionId, required this.isLoading, + required this.reconnectingTimeout, required this.error, required this.size, required this.sizeBreakpoint, @@ -33,6 +35,7 @@ class AppState extends Equatable { pageUri: null, sessionId: "", isLoading: true, + reconnectingTimeout: 0, error: "", size: Size(0, 0), sizeBreakpoint: "", @@ -50,6 +53,7 @@ class AppState extends Equatable { {Uri? pageUri, String? sessionId, bool? isLoading, + int? reconnectingTimeout, String? error, Size? size, String? sizeBreakpoint, @@ -59,6 +63,7 @@ class AppState extends Equatable { pageUri: pageUri ?? this.pageUri, sessionId: sessionId ?? this.sessionId, isLoading: isLoading ?? this.isLoading, + reconnectingTimeout: reconnectingTimeout ?? this.reconnectingTimeout, error: error ?? this.error, size: size ?? this.size, sizeBreakpoint: sizeBreakpoint ?? this.sizeBreakpoint, diff --git a/client/lib/reducers.dart b/client/lib/reducers.dart index 3a54aedcc..25229d280 100644 --- a/client/lib/reducers.dart +++ b/client/lib/reducers.dart @@ -64,7 +64,10 @@ AppState appReducer(AppState state, dynamic action) { // if (action.payload.error != null && action.payload.error!.isNotEmpty) { // error - return state.copyWith(isLoading: false, error: action.payload.error); + return state.copyWith( + isLoading: false, + reconnectingTimeout: 0, + error: action.payload.error); } else { final sessionId = action.payload.session!.id; @@ -74,6 +77,7 @@ AppState appReducer(AppState state, dynamic action) { // connected to the session return state.copyWith( isLoading: false, + reconnectingTimeout: 0, sessionId: sessionId, controls: action.payload.session!.controls); } @@ -81,7 +85,10 @@ AppState appReducer(AppState state, dynamic action) { // // reconnecting WebSocket // - return state.copyWith(isLoading: true); + return state.copyWith( + isLoading: true, + reconnectingTimeout: + state.reconnectingTimeout == 0 ? 1 : state.reconnectingTimeout * 2); } else if (action is AppBecomeInactiveAction) { // // app become inactive diff --git a/client/lib/web_socket_client.dart b/client/lib/web_socket_client.dart index f331b88e5..b466bba47 100644 --- a/client/lib/web_socket_client.dart +++ b/client/lib/web_socket_client.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:flet_view/models/app_state.dart'; import 'package:flet_view/protocol/add_page_controls_payload.dart'; import 'package:flet_view/protocol/app_become_inactive_payload.dart'; import 'package:flet_view/protocol/append_control_props_request.dart'; @@ -22,12 +23,11 @@ import 'protocol/register_webclient_request.dart'; import 'protocol/register_webclient_response.dart'; WebSocketClient ws = WebSocketClient(); -int reconnectionTimeoutSeconds = 5; class WebSocketClient { WebSocketChannel? _channel; String _serverUrl = ""; - Store? _store; + Store? _store; bool _connected = false; String _pageName = ""; String _pageHash = ""; @@ -35,7 +35,7 @@ class WebSocketClient { String _winHeight = ""; String? _sessionId; - set store(Store store) { + set store(Store store) { _store = store; } @@ -49,7 +49,8 @@ class WebSocketClient { _channel!.stream.listen(_onMessage, onDone: () async { debugPrint("WS stream closed"); _store!.dispatch(PageReconnectingAction()); - Future.delayed(Duration(seconds: reconnectionTimeoutSeconds)) + debugPrint("Reconnect in ${_store!.state.reconnectingTimeout} seconds"); + Future.delayed(Duration(seconds: _store!.state.reconnectingTimeout)) .then((value) { connect(serverUrl: _serverUrl); _registerWebClient(); diff --git a/client/web/icons/Icon-192.png b/client/web/icons/Icon-192.png index 07f9ac603..c342695bb 100644 Binary files a/client/web/icons/Icon-192.png and b/client/web/icons/Icon-192.png differ diff --git a/client/web/icons/Icon-512.png b/client/web/icons/Icon-512.png index aa29fc543..6c2b22bf0 100644 Binary files a/client/web/icons/Icon-512.png and b/client/web/icons/Icon-512.png differ diff --git a/client/web/icons/Icon-maskable-192.png b/client/web/icons/Icon-maskable-192.png index 5bfe768cf..00c9a473f 100644 Binary files a/client/web/icons/Icon-maskable-192.png and b/client/web/icons/Icon-maskable-192.png differ diff --git a/client/web/icons/Icon-maskable-512.png b/client/web/icons/Icon-maskable-512.png index 1888c2018..f37ae2790 100644 Binary files a/client/web/icons/Icon-maskable-512.png and b/client/web/icons/Icon-maskable-512.png differ diff --git a/sdk/python/playground/icons-browser.py b/sdk/python/playground/icons-browser.py index 153680722..cb10729f0 100644 --- a/sdk/python/playground/icons-browser.py +++ b/sdk/python/playground/icons-browser.py @@ -125,4 +125,4 @@ def search_click(e): ) -flet.app(name="test1", port=8550, target=main, view=flet.WEB_BROWSER) +flet.app(name="test1", port=8550, target=main, view=flet.FLET_APP) diff --git a/sdk/python/playground/textfield-test.py b/sdk/python/playground/textfield-test.py index 5b1f90a95..3ea4ec076 100644 --- a/sdk/python/playground/textfield-test.py +++ b/sdk/python/playground/textfield-test.py @@ -1,8 +1,6 @@ import logging -from cmath import exp from datetime import datetime from time import sleep -from tkinter import W import flet from flet import ( @@ -14,13 +12,11 @@ Row, Text, Theme, - border, border_radius, dropdown, icons, padding, ) -from flet.border_radius import BorderRadius from flet.checkbox import Checkbox from flet.container import Container from flet.icon import Icon