Beispiel #1
0
        /// <summary> Обработчик изменения подписки контактов внутри логики C++ </summary>
        private void ChangedListModelContactSubscription(List <PackageModelContactSubscription> listPackageModelContactSubscriptions)
        {
            if (ListModelConctactChatMembers == null)
            {
                return;
            }

            //var dictionary = _dataSourceContact.GetDictionaryModelContactSubscriptionByArrayXmppId(arrayXmppId);

            foreach (var i in listPackageModelContactSubscriptions)
            {
                var modelContact = ListModelConctactChatMembers.FirstOrDefault(obj => obj.XmppId == i.XmppId);

                if (modelContact != null)
                {
                    Action action = () => { modelContact.ModelContactSubscriptionObj = i.ModelContactSubscriptionObj.GetDeepCopy(); };

                    CurrentDispatcher.BeginInvoke(action);

                    //modelContact.ModelContactSubscriptionObj = i.Value;
                }
            }

            DataSourceContact.RefreshModelContactStatus(ListModelConctactChatMembers.Where(obj => listPackageModelContactSubscriptions.Any(o => o.XmppId == obj.XmppId)).ToList());
        }
Beispiel #2
0
        /// <summary> Инициализация конструкторов </summary>
        private void InitializatiOnoverallConstructors(ModelChat modelChat)
        {
            if (modelChat != null)
            {
                var modelChatFromList = ViewModelChat.CurrentViewModelChat.CurrentListModelChat.FirstOrDefault(obj => obj.Id == modelChat.Id);

                if (modelChatFromList == null)
                {
                    ViewModelChat.CurrentViewModelChat.CurrentListModelChat.Add(modelChat);
                    CurrentModelChat = modelChat;
                }
                else
                {
                    CurrentModelChat = modelChatFromList;
                }
            }

            _listModelChatMessage = DataSourceChat.GetPagedModelChatMessageByIdChat(CurrentModelChat);

            foreach (var i in ListModelChatMessage)
            {
                var modelContact = ListModelConctactChatMembers.FirstOrDefault(obj => obj?.DodicallId == i?.Sender?.DodicallId);
                if (modelContact == null)
                {
                    ListModelConctactChatMembers.Add(i.Sender);
                }
            }

            foreach (var i in _listModelChatMessage)
            {
                // Сделать отдельный список с собеседниками+теми кто когда-то был в чате
                // Брать ссылку на объект из этого списка, тогда все будет работать
                //var modelContactFromModelChat = CurrentModelChat.ListModelContact.FirstOrDefault(obj => obj.Id == i?.Sender?.Id);
                var modelContactFromChatMessageSenders = ListModelConctactChatMembers.FirstOrDefault(obj => obj?.DodicallId == i?.Sender?.DodicallId);
                if (modelContactFromChatMessageSenders != null)
                {
                    i.Sender = modelContactFromChatMessageSenders;
                }
                //if (modelContactFromModelChat != null) i.Sender = modelContactFromModelChat;
            }

            SortCurrentListModelChatMessage();

            if (!CurrentModelChat.IsP2P)
            {
                CurrentModelChat.ListModelContact = ListModelContactSort(CurrentModelChat.ListModelContact);
                //_dataSourceContact.RefreshModelContactStatus(_listModelChatMessage.Select(obj => obj?.Sender).ToList());
                DataSourceContact.RefreshModelContactStatus(GetAllSendersAndUserFromChat());
                //_dataSourceContact.RefreshModelContactStatus(CurrentModelChat.ListModelContact);
            }

            CommandSendModelMessage = new Command(obj => SendModelMessage());

            CommandRenameChatModel = new Command(obj => RenameChatModel());

            CommandRemoveFromChat = new Command(obj => RemoveFromChatContactModel((ModelContact)obj));

            //CommandInviteAndRevokeChatMembers = new Command(obj => InviteAndRevokeChatMembers());

            if (CurrentModelChat.HaveDraft)
            {
                CurrentModelChatMessage = CurrentModelChat.DraftMessage;
            }

            CallbackRouter.Instance.ListModelChatMessageChanged         += OnListModelChatMessageChanged;
            CallbackRouter.Instance.ListModelContactStatusChanged       += OnListModelContactStatusChanged;
            CallbackRouter.Instance.ListModelContactSubscriptionChanged += OnListModelContactSubscriptionChanged;
            CallbackRouter.Instance.ModelUserSettingsChanged            += OnModelUserSettingsChanged;
        }