Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Closed #13
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed Feb 15, 2018
1 parent 8f41caa commit ada2e7f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Data_Manager2/Classes/ConnectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public void connectAll()
case ConnectionState.DISCONNECTED:
case ConnectionState.DISCONNECTING:
case ConnectionState.ERROR:
Task t = Task.Factory.StartNew(async () =>
Task t = Task.Run(async () =>
{
await c.connectAsync();
}, TaskCreationOptions.None).ContinueWith((Task prev) =>
}).ContinueWith((Task prev) =>
{
if (prev.Exception != null)
{
Expand Down
13 changes: 13 additions & 0 deletions Data_Manager2/Classes/DBTables/ChatTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ public ChatTable clone()
};
}

public bool equalsExceptPresence(ChatTable chat)
{
return Equals(id, chat.id)
&& Equals(lastActive, chat.lastActive)
&& muted == chat.muted
&& Equals(subscription, chat.subscription)
&& inRoster == chat.inRoster
&& Equals(ask, chat.ask)
&& Equals(status, chat.status)
&& chatState == chat.chatState
&& chatType == chat.chatType;
}

#endregion

#region --Misc Methods (Private)--
Expand Down
59 changes: 33 additions & 26 deletions UWP XMPP Client/Controls/ChatMasterControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public XMPPClient Client
ChatDBManager.INSTANCE.NewChatMessage -= INSTANCE_NewChatMessage;
ChatDBManager.INSTANCE.NewChatMessage += INSTANCE_NewChatMessage;
}
showChat();
showClient(Client);
}
}
public static readonly DependencyProperty ClientProperty = DependencyProperty.Register("Client", typeof(XMPPClient), typeof(ChatMasterControl), null);
Expand All @@ -48,7 +48,7 @@ public ChatTable Chat
set
{
SetValue(ChatProperty, value);
showChat();
showChat(Chat);
}
}
public static readonly DependencyProperty ChatProperty = DependencyProperty.Register("Chat", typeof(ChatTable), typeof(ChatMasterControl), null);
Expand Down Expand Up @@ -132,14 +132,14 @@ private void showMUCInfo()
}
}

private void showChat()
private void showChat(ChatTable chat)
{
if (Chat != null && Client != null)
if (chat != null)
{
if (Chat.chatType != ChatType.MUC)
if (chat.chatType != ChatType.MUC)
{
// Chat jabber id:
name_tblck.Text = Chat.chatJabberId;
name_tblck.Text = chat.chatJabberId;

// Subscription state:
accountAction_grid.Visibility = Visibility.Collapsed;
Expand All @@ -148,7 +148,7 @@ private void showChat()
rejectPresenceSubscription_mfo.Visibility = Visibility.Collapsed;
cancelPresenceSubscriptionRequest.Visibility = Visibility.Collapsed;

switch (Chat.subscription)
switch (chat.subscription)
{
case "to":
cancelPresenceSubscription_mfo.Visibility = Visibility.Visible;
Expand Down Expand Up @@ -178,16 +178,16 @@ private void showChat()
}

// Menu flyout:
mute_tmfo.Text = Chat.muted ? "Unmute" : "Mute";
mute_tmfo.IsChecked = Chat.muted;
removeFromRoster_mfo.Text = Chat.inRoster ? "Remove from roster" : "Add to roster";
mute_tmfo.Text = chat.muted ? "Unmute" : "Mute";
mute_tmfo.IsChecked = chat.muted;
removeFromRoster_mfo.Text = chat.inRoster ? "Remove from roster" : "Add to roster";

//Slide list item:
slideListItem_sli.LeftLabel = removeFromRoster_mfo.Text;
}

// Subscription pending:
if (Chat.ask != null && Chat.ask.Equals("subscribe"))
if (chat.ask != null && chat.ask.Equals("subscribe"))
{
presence_tblck.Visibility = Visibility.Visible;
cancelPresenceSubscription_mfo.Visibility = Visibility.Visible;
Expand All @@ -199,9 +199,9 @@ private void showChat()
}

// Last action date:
if (Chat.lastActive != null)
if (chat.lastActive != null)
{
DateTime lastActiveLocal = Chat.lastActive.ToLocalTime();
DateTime lastActiveLocal = chat.lastActive.ToLocalTime();
if (lastActiveLocal.Date.CompareTo(DateTime.Now.Date) == 0)
{
lastAction_tblck.Text = lastActiveLocal.ToString("HH:mm");
Expand All @@ -216,22 +216,29 @@ private void showChat()
lastAction_tblck.Text = "";
}

// Chat color:
if (UiUtils.isHexColor(Client.getXMPPAccount().color))
{
color_rcta.Fill = UiUtils.convertHexColorToBrush(Client.getXMPPAccount().color);
}
else
{
color_rcta.Fill = new SolidColorBrush(Colors.Transparent);
}

// Last chat message:
showLastChatMessage(ChatDBManager.INSTANCE.getLastChatMessageForChat(Chat.id));
Task.Run(async () =>
{
ChatMessageTable lastMsg = ChatDBManager.INSTANCE.getLastChatMessageForChat(chat.id);
await Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => showLastChatMessage(lastMsg));
});

// Status icons:
muted_tbck.Visibility = Chat.muted ? Visibility.Visible : Visibility.Collapsed;
inRooster_tbck.Visibility = Chat.inRoster ? Visibility.Visible : Visibility.Collapsed;
muted_tbck.Visibility = chat.muted ? Visibility.Visible : Visibility.Collapsed;
inRooster_tbck.Visibility = chat.inRoster ? Visibility.Visible : Visibility.Collapsed;
}
}

private void showClient(XMPPClient client)
{
// Chat color:
if (UiUtils.isHexColor(client.getXMPPAccount().color))
{
color_rcta.Fill = UiUtils.convertHexColorToBrush(client.getXMPPAccount().color);
}
else
{
color_rcta.Fill = new SolidColorBrush(Colors.Transparent);
}
}

Expand Down

0 comments on commit ada2e7f

Please sign in to comment.