Login zeigt Warteanimation
NullPointerException beim Senden einer Nachricht in einen leeren Chat (AddSeparators) behoben; die previousMessage war null. Download von Dokumenten und Audio-Dateien geht jetzt neben den Bildern Cache der Profilbilder optimiert Beim Klick auf Senden wird die Warteanimation angezeigt
This commit is contained in:
@@ -383,87 +383,79 @@ namespace ChatController
|
||||
// ToDo: Hier kommt es immer wieder zu einer NullPointerException
|
||||
private void SelectContact(Contact contact)
|
||||
{
|
||||
try
|
||||
if(contact is null)
|
||||
{
|
||||
if(contact is null)
|
||||
return;
|
||||
}
|
||||
|
||||
ChatMessageFileWrapper = null;
|
||||
|
||||
ShouldInterruptContactsThread = true;
|
||||
|
||||
StartWaitingImmediately();
|
||||
|
||||
_ScrollPrueferAktivieren = false;
|
||||
|
||||
if(contact.HasUnreadMessages)
|
||||
{
|
||||
contact.HasUnreadMessages = false;
|
||||
|
||||
Clientlist?.Items.Refresh();
|
||||
OnPropertyChanged(nameof(ContactList));
|
||||
}
|
||||
|
||||
var currentContact = contact;
|
||||
|
||||
contact.IsNewMessage = false;
|
||||
|
||||
var shouldChangeIcon = _ContactList.Any(contactDependencyObject => contactDependencyObject.Contact?.IsNewMessage ?? false);
|
||||
if(shouldChangeIcon)
|
||||
{
|
||||
ContainingWindow.Icon = Utils.ConvertIconToImageSource(Resource.ownchat_favicon);
|
||||
}
|
||||
|
||||
CurrentContact = currentContact;
|
||||
|
||||
OnPropertyChanged(nameof(IsSendButtonEnabled));
|
||||
|
||||
if(!(Clientlist is null))
|
||||
{
|
||||
foreach(var obj in Clientlist.Items)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChatMessageFileWrapper = null;
|
||||
|
||||
ShouldInterruptContactsThread = true;
|
||||
|
||||
// Zeigt die Warteanimation (das Rädchen)
|
||||
StartWaitingImmediately();
|
||||
|
||||
_ScrollPrueferAktivieren = false;
|
||||
|
||||
if(contact.HasUnreadMessages)
|
||||
{
|
||||
contact.HasUnreadMessages = false;
|
||||
|
||||
Clientlist?.Items.Refresh();
|
||||
OnPropertyChanged(nameof(ContactList));
|
||||
}
|
||||
|
||||
var currentContact = contact;
|
||||
|
||||
contact.IsNewMessage = false;
|
||||
|
||||
var shouldChangeIcon = _ContactList.Any(contactDependencyObject => contactDependencyObject.Contact?.IsNewMessage ?? false);
|
||||
if(shouldChangeIcon)
|
||||
{
|
||||
ContainingWindow.Icon = Utils.ConvertIconToImageSource(Resource.ownchat_favicon);
|
||||
}
|
||||
|
||||
CurrentContact = currentContact;
|
||||
|
||||
OnPropertyChanged(nameof(IsSendButtonEnabled));
|
||||
|
||||
if(!(Clientlist is null))
|
||||
{
|
||||
foreach(var obj in Clientlist.Items)
|
||||
if(obj is ContactDependencyObject contactDependencyObject && Equals(contactDependencyObject.Contact, contact))
|
||||
{
|
||||
if(obj is ContactDependencyObject contactDependencyObject && Equals(contactDependencyObject.Contact, contact))
|
||||
{
|
||||
Clientlist.SelectedItem = obj;
|
||||
}
|
||||
Clientlist.SelectedItem = obj;
|
||||
}
|
||||
}
|
||||
|
||||
_ChatMessages.Clear();
|
||||
OnPropertyChanged(nameof(_ChatMessages));
|
||||
|
||||
Chat.LoadChatMessagesForContactAsync(currentContact, GetFirstMessage(), chatMessages =>
|
||||
{
|
||||
this.Dispatch(() =>
|
||||
{
|
||||
_ChatMessages.Clear();
|
||||
_ChatMessages.AddRangeIfElementsNotIn(chatMessages);
|
||||
OnPropertyChanged(nameof(_ChatMessages));
|
||||
|
||||
WpfUtils.ScrollToBottomOfListBox(ChatListBox);
|
||||
|
||||
ChatListBox.ContextMenu = Chat.ErstelleKontextMenue();
|
||||
SetContextHandler();
|
||||
_ScrollPrueferAktivieren = true;
|
||||
|
||||
ListenForMessages();
|
||||
Cursor = Cursors.Arrow;
|
||||
|
||||
WriteToNewSyncFile();
|
||||
|
||||
ShouldInterruptContactsThread = false;
|
||||
|
||||
EndWaiting();
|
||||
});
|
||||
});
|
||||
}
|
||||
catch(Exception exception)
|
||||
|
||||
_ChatMessages.Clear();
|
||||
OnPropertyChanged(nameof(_ChatMessages));
|
||||
|
||||
Chat.LoadChatMessagesForContactAsync(currentContact, GetFirstMessage(), chatMessages =>
|
||||
{
|
||||
throw;
|
||||
}
|
||||
this.Dispatch(() =>
|
||||
{
|
||||
_ChatMessages.Clear();
|
||||
_ChatMessages.AddRangeIfElementsNotIn(chatMessages);
|
||||
OnPropertyChanged(nameof(_ChatMessages));
|
||||
|
||||
WpfUtils.ScrollToBottomOfListBox(ChatListBox);
|
||||
|
||||
ChatListBox.ContextMenu = Chat.ErstelleKontextMenue();
|
||||
SetContextHandler();
|
||||
_ScrollPrueferAktivieren = true;
|
||||
|
||||
ListenForMessages();
|
||||
Cursor = Cursors.Arrow;
|
||||
|
||||
WriteToNewSyncFile();
|
||||
|
||||
ShouldInterruptContactsThread = false;
|
||||
|
||||
EndWaiting();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void SetContextHandler()
|
||||
@@ -515,11 +507,19 @@ namespace ChatController
|
||||
|
||||
private void SaveAsOnClick(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
foreach(var items in ChatListBox.SelectedItems)
|
||||
{
|
||||
var chatMessage = (ChatMessage) items;
|
||||
var selectedChatMessages = new List<ChatMessage>();
|
||||
|
||||
Chat.SaveFileAs(chatMessage);
|
||||
foreach(var selectedItem in ChatListBox.SelectedItems)
|
||||
{
|
||||
if(selectedItem is ChatMessage message)
|
||||
{
|
||||
selectedChatMessages.AddIfNotIn(message);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var message in selectedChatMessages)
|
||||
{
|
||||
Chat.SaveFileAs(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,8 +730,6 @@ namespace ChatController
|
||||
|
||||
ChatMessageFileWrapper = null;
|
||||
Chatbox.Text = string.Empty;
|
||||
|
||||
//DoSynchro();
|
||||
}
|
||||
|
||||
public Visibility ChatListBoxVisibility => (Chat?.IsInBroadcastMode ?? false) || !(ChatMessageFileWrapper is null) ? Visibility.Collapsed : Visibility.Visible;
|
||||
@@ -761,7 +759,12 @@ namespace ChatController
|
||||
return;
|
||||
}
|
||||
|
||||
StartWaitingImmediately();
|
||||
await SendMessage();
|
||||
EndWaiting();
|
||||
|
||||
CheckForNewMessagesForContact(CurrentContact);
|
||||
ListenGloballyForMessages();
|
||||
}
|
||||
|
||||
private void Chatbox_OnGotFocus(object sender, RoutedEventArgs e)
|
||||
@@ -988,25 +991,30 @@ namespace ChatController
|
||||
{
|
||||
if(!ShouldInterruptContactsThread && !(CurrentContact is null))
|
||||
{
|
||||
Chat.CheckIfNewMessagesExistAsync(CurrentContact.GroupId, hasNewMessages =>
|
||||
CheckForNewMessagesForContact(pCurrentContact);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForNewMessagesForContact(Contact contact)
|
||||
{
|
||||
Chat.CheckIfNewMessagesExistAsync(CurrentContact.GroupId, hasNewMessages =>
|
||||
{
|
||||
if(!hasNewMessages)
|
||||
{
|
||||
if(!hasNewMessages)
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Chat.LoadChatMessagesForContactAsync(pCurrentContact, GetFirstMessage(), chatMessages =>
|
||||
Chat.LoadChatMessagesForContactAsync(contact, GetFirstMessage(), chatMessages =>
|
||||
{
|
||||
this.Dispatch(() =>
|
||||
{
|
||||
this.Dispatch(() =>
|
||||
{
|
||||
_ChatMessages.Clear();
|
||||
_ChatMessages.AddRangeIfElementsNotIn(chatMessages);
|
||||
_ChatMessages.Clear();
|
||||
_ChatMessages.AddRangeIfElementsNotIn(chatMessages);
|
||||
|
||||
WpfUtils.ScrollToBottomOfListBox(ChatListBox);
|
||||
});
|
||||
WpfUtils.ScrollToBottomOfListBox(ChatListBox);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Suche_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
@@ -1115,11 +1123,6 @@ namespace ChatController
|
||||
|
||||
private ChatControlWaitLayer _WaitLayer;
|
||||
|
||||
public void StartWaiting()
|
||||
{
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action<string>) StartWaitingImmediately);
|
||||
}
|
||||
|
||||
public void StartWaitingImmediately(string dialogText = null)
|
||||
{
|
||||
if(!(_WaitLayer is null))
|
||||
@@ -1137,7 +1140,7 @@ namespace ChatController
|
||||
public void EndWaiting()
|
||||
{
|
||||
Dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Background,
|
||||
DispatcherPriority.Normal,
|
||||
(Action) delegate
|
||||
{
|
||||
if(_WaitLayer is null)
|
||||
|
||||
Reference in New Issue
Block a user