import '../../api/apiResponse.dart';
import '../../api/marianumcloud/talk/chat/getChatCache.dart';
import '../../api/marianumcloud/talk/chat/getChatResponse.dart';
import '../dataHolder.dart';

class ChatProps extends DataHolder {
  String _queryToken = "";

  GetChatResponse? _getChatResponse;
  GetChatResponse get getChatResponse => _getChatResponse!;

  @override
  List<ApiResponse?> properties() {
    return [_getChatResponse];
  }

  @override
  void run() {
    notifyListeners();
    GetChatCache(
      chatToken: _queryToken,
      onUpdate: (GetChatResponse data) => {
        _getChatResponse = data,
        notifyListeners(),
      }
    );
  }

  void setQueryToken(String token) {
    _queryToken = token;
    _getChatResponse = null;
    run();
  }

}