|
|
|
@ -2,17 +2,15 @@ import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
|
|
|
import 'package:logger/logger.dart' as L;
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/api/api_client.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/consts.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/consts.dart';
|
|
|
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
|
|
|
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_Model.dart';
|
|
|
|
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_Model.dart';
|
|
|
|
import 'package:signalr_netcore/hub_connection.dart';
|
|
|
|
import 'package:signalr_netcore/hub_connection.dart';
|
|
|
|
import 'package:signalr_netcore/signalr_client.dart';
|
|
|
|
import 'package:signalr_netcore/signalr_client.dart';
|
|
|
|
import 'package:logger/logger.dart' as L;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
List<SingleUserChatModel> userChatHistory = [];
|
|
|
|
List<SingleUserChatModel> userChatHistory = [];
|
|
|
|
@ -29,19 +27,13 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
|
|
|
|
void getChatMemberFromSearch(String sName, int cUserId) async {
|
|
|
|
void getChatMemberFromSearch(String sName, int cUserId) async {
|
|
|
|
isLoading = true;
|
|
|
|
isLoading = true;
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
Response response = await ApiClient().getJsonForResponse(
|
|
|
|
Response response = await ApiClient().getJsonForResponse("${ApiConsts.chatSearchMember}$sName/$cUserId", token: token);
|
|
|
|
"${ApiConsts.chatSearchMember}$sName/$cUserId",
|
|
|
|
|
|
|
|
token: token,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
isLoading = false;
|
|
|
|
isLoading = false;
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void getUserRecentChats() async {
|
|
|
|
void getUserRecentChats() async {
|
|
|
|
Response response = await ApiClient().getJsonForResponse(
|
|
|
|
Response response = await ApiClient().getJsonForResponse("${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}", token: token);
|
|
|
|
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}",
|
|
|
|
|
|
|
|
token: token,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
ChatUserModel recentChat = userToList(response.body);
|
|
|
|
ChatUserModel recentChat = userToList(response.body);
|
|
|
|
pChatHistory = recentChat.response;
|
|
|
|
pChatHistory = recentChat.response;
|
|
|
|
searchedChats = pChatHistory;
|
|
|
|
searchedChats = pChatHistory;
|
|
|
|
|