|
@@ -11,6 +11,7 @@ import 'package:asr_client/models/websocket_message.dart';
|
|
|
import 'package:asr_client/providers/livekit_providers.dart';
|
|
import 'package:asr_client/providers/livekit_providers.dart';
|
|
|
import 'package:asr_client/services/livekit_service.dart';
|
|
import 'package:asr_client/services/livekit_service.dart';
|
|
|
import 'package:asr_client/providers/settings_providers.dart';
|
|
import 'package:asr_client/providers/settings_providers.dart';
|
|
|
|
|
+import 'package:asr_client/services/session_service.dart';
|
|
|
|
|
|
|
|
enum RecordingStatus { idle, recording, paused, ending }
|
|
enum RecordingStatus { idle, recording, paused, ending }
|
|
|
|
|
|
|
@@ -110,6 +111,7 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
StreamSubscription<ServerMessage>? _messageSub;
|
|
StreamSubscription<ServerMessage>? _messageSub;
|
|
|
|
|
|
|
|
LiveKitService get _liveKit => ref.read(liveKitServiceProvider);
|
|
LiveKitService get _liveKit => ref.read(liveKitServiceProvider);
|
|
|
|
|
+ SessionService get _sessionService => ref.read(sessionServiceProvider);
|
|
|
|
|
|
|
|
String? _currentRoom;
|
|
String? _currentRoom;
|
|
|
|
|
|
|
@@ -143,6 +145,7 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
final identity = 'user-${_uuid.v4().substring(0, 6)}';
|
|
final identity = 'user-${_uuid.v4().substring(0, 6)}';
|
|
|
|
|
+ final lastRoom = await _sessionService.getLastRoom();
|
|
|
|
|
|
|
|
final initialState = const RecordingState(
|
|
final initialState = const RecordingState(
|
|
|
projectName: 'G15 沈海高速改扩建 · K1120+300',
|
|
projectName: 'G15 沈海高速改扩建 · K1120+300',
|
|
@@ -150,8 +153,9 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
templateName: '模板 · 普通混凝土坍落度 GB/T 50080',
|
|
templateName: '模板 · 普通混凝土坍落度 GB/T 50080',
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- final info = await _getRoomInfo(identity);
|
|
|
|
|
|
|
+ final info = await _getRoomInfo(identity, resumeRoom: lastRoom);
|
|
|
_currentRoom = info.room;
|
|
_currentRoom = info.room;
|
|
|
|
|
+ await _sessionService.setLastRoom(info.room);
|
|
|
try {
|
|
try {
|
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
|
} on Exception catch (e) {
|
|
} on Exception catch (e) {
|
|
@@ -243,6 +247,7 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
try {
|
|
try {
|
|
|
final identity = 'user-${_uuid.v4().substring(0, 6)}';
|
|
final identity = 'user-${_uuid.v4().substring(0, 6)}';
|
|
|
final info = await _getRoomInfo(identity, resumeRoom: _currentRoom);
|
|
final info = await _getRoomInfo(identity, resumeRoom: _currentRoom);
|
|
|
|
|
+ _currentRoom = info.room;
|
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
await _liveKit.connect(url: info.url, room: info.room, identity: identity, token: info.token);
|
|
|
_updateState((s) => _startedState(s));
|
|
_updateState((s) => _startedState(s));
|
|
|
} on Exception catch (e) {
|
|
} on Exception catch (e) {
|
|
@@ -258,6 +263,8 @@ final class RecordingNotifier extends AutoDisposeAsyncNotifier<RecordingState> {
|
|
|
_timer?.cancel();
|
|
_timer?.cancel();
|
|
|
_messageSub?.cancel();
|
|
_messageSub?.cancel();
|
|
|
await _liveKit.disconnect();
|
|
await _liveKit.disconnect();
|
|
|
|
|
+ await _sessionService.clearLastRoom();
|
|
|
|
|
+ _currentRoom = null;
|
|
|
_updateState((s) => s.copyWith(
|
|
_updateState((s) => s.copyWith(
|
|
|
status: RecordingStatus.idle,
|
|
status: RecordingStatus.idle,
|
|
|
elapsed: Duration.zero,
|
|
elapsed: Duration.zero,
|