Skip to content

Commit

Permalink
Only open ws connection when syncing sdcard, instead of device connec…
Browse files Browse the repository at this point in the history
…ted (#1109)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Improved handling of SD card storage operations through enhanced
websocket management.
- **Bug Fixes**
- Refined logic for reconnecting to the SD card socket to ensure
consistent data retrieval.
- **Documentation**
- Updated method signatures to include new parameters for better clarity
on websocket connections.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
beastoin authored Oct 18, 2024
2 parents 5d3703a + 96b70cd commit bb1e1bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
10 changes: 10 additions & 0 deletions app/lib/pages/apps/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ class _AppsPageState extends State<AppsPage> with AutomaticKeepAliveClientMixin
),
);
}),
const SliverToBoxAdapter(
child: SizedBox(
height: 120,
),
),
],
),
CustomScrollView(
Expand All @@ -129,6 +134,11 @@ class _AppsPageState extends State<AppsPage> with AutomaticKeepAliveClientMixin
),
);
}),
const SliverToBoxAdapter(
child: SizedBox(
height: 120,
),
),
],
),
]),
Expand Down
22 changes: 11 additions & 11 deletions app/lib/providers/capture_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,6 @@ class CaptureProvider extends ChangeNotifier
debugPrint(
'previousStorageBytes in initiateStorageBytesStreaming: ${SharedPreferencesUtil().previousStorageBytes}');
btConnectedTime = DateTime.now().toUtc().toString();
sdCardSocket.setupSdCardWebSocket(
//replace
onMessageReceived: () {
debugPrint('onMessageReceived');
memoryProvider?.getMemoriesFromServer();
notifyListeners();
_notifySdCardComplete();
return;
},
btConnectedTime: btConnectedTime,
);

if (totalStorageFileBytes > 100) {
sdCardReady = true;
Expand All @@ -595,6 +584,17 @@ class CaptureProvider extends ChangeNotifier
if (totalStorageFileBytes == 0) {
return;
}
await sdCardSocket.setupSdCardWebSocket(
//replace
onMessageReceived: () {
debugPrint('onMessageReceived');
memoryProvider?.getMemoriesFromServer();
notifyListeners();
_notifySdCardComplete();
return;
},
btConnectedTime: btConnectedTime,
);
if (sdCardSocket.sdCardConnectionState != WebsocketConnectionStatus.connected) {
sdCardSocket.sdCardChannel?.sink.close();
await sdCardSocket.setupSdCardWebSocket(
Expand Down

0 comments on commit bb1e1bc

Please sign in to comment.