-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implemented draft feature, including attatchments #225
implemented draft feature, including attatchments #225
Conversation
2767ef7
to
c00dba4
Compare
c00dba4
to
9189943
Compare
Signal-Windows.Lib/Storage/DB.cs
Outdated
} | ||
} | ||
|
||
public static void InsertOrUpdateConversationsLocked(IEnumerable<SignalConversation> conversations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this function to improve the performance when saving all conversations on suspending.
* because on mobile app gets supended during file picking and | ||
* the new conversation does not have the DraftFileTokens | ||
*/ | ||
if (conversationThreadIdChanged) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the best approach to solve this issue is to just keep the current draft if its the same thread id and set the kept draft in the new conversation.
Task.Run(() => | ||
{ | ||
SignalDBContext.InsertOrUpdateConversationLocked(SignalConversation); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the token is not saved in the database right away it could happen, that StorageApplicationPermissions and database get out of sync when the app crashes or gets in other way suspended without saving.
Signal-Windows/App.xaml.cs
Outdated
await Task.Run(() => | ||
{ | ||
SignalDBContext.InsertOrUpdateConversationsLocked(Views.Values.SelectMany(view => view.Locator.MainPageInstance.Conversations)); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is the best position to save the current state of all conversations. Maybe within Handle.Release()? But I think in Handle.Release() is no nice way to access the conversations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question I have is what in the conversation state isn't saved when the app shuts down. You're already saving the attachment state in the DB immediately after selection. The draft text may be a little harder as we wouldn't want to save to the DB on every keystroke. I could see that being saved in App_Suspending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this code in App.xaml.cs everything is saved in the conversation state on App_Suspending
. In Conversation.xaml.cs the state is only saved, so that no files are saved in the FutureAccessList, which then might not be saved in the state or database, because the app crashes or similar.
I think I have better idea now. We could save the selected file in FutureAccessList
and the state of the current conversation in the database on SaveDraftInCurrentConversation()
. With this approch saving the state of all conversations in App_Suspending
is not needed, because the only conversation that has to be saved is the current and this gets done by Handle.Release()
.
If you used the Add-Migration command in the Package Manager Console in Visual Studio you did the migration correctly. I should add documentation to the repo on doing DB migrations. |
I tried the Add-Migration command ( |
I think I found the problem. I nedded to select the project I updated/fixed the migration of this PR. |
Signal-Windows/App.xaml.cs
Outdated
await Task.Run(() => | ||
{ | ||
SignalDBContext.InsertOrUpdateConversationsLocked(Views.Values.SelectMany(view => view.Locator.MainPageInstance.Conversations)); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question I have is what in the conversation state isn't saved when the app shuts down. You're already saving the attachment state in the DB immediately after selection. The draft text may be a little harder as we wouldn't want to save to the DB on every keystroke. I could see that being saved in App_Suspending
} | ||
catch (Exception e) | ||
{ | ||
Logger.LogError("SetSelectedFile() failed: {0}\n{1}", e.Message, e.StackTrace); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this fail for you while testing? Does it make sense to fail to save the selected file in the StorageApplicationPermissions
and the DB but still show it in the UI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no, I just like to put everything that has to do with IO in a try catch. I change it.
if (SelectedFile == null) | ||
{ | ||
AddedAttachmentDisplay.HideAttachment(); | ||
} | ||
else | ||
{ | ||
AddedAttachmentDisplay.ShowAttachment(SelectedFile.Name); | ||
} | ||
UpdateSendButtonIcon(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be split out into a separate method called SetSelectedFileInUI
. Then the only two places where the argument save
is set to false could just directly call the new method and the save
argument could be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed when the conversations and it's draft get saved. It's now saved in SaveCurrentConversationInDatabase()
, which is call on change of conversation and shutdown of app. SelectedFile
gets save in FutureAccessList
there aswell.
Obviously the draft of the current conversation is not saved when the app crashes but I think this is acceptable, as long as the DraftFileTokens in the database don't get out of sync with FutureAccessList
, which is case.
Signal-Windows/App.xaml.cs
Outdated
await Task.Run(() => | ||
{ | ||
SignalDBContext.InsertOrUpdateConversationsLocked(Views.Values.SelectMany(view => view.Locator.MainPageInstance.Conversations)); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this code in App.xaml.cs everything is saved in the conversation state on App_Suspending
. In Conversation.xaml.cs the state is only saved, so that no files are saved in the FutureAccessList, which then might not be saved in the state or database, because the app crashes or similar.
I think I have better idea now. We could save the selected file in FutureAccessList
and the state of the current conversation in the database on SaveDraftInCurrentConversation()
. With this approch saving the state of all conversations in App_Suspending
is not needed, because the only conversation that has to be saved is the current and this gets done by Handle.Release()
.
Implemented the saving and loading of drafts including the attatchemnt file.
Fixed the saving of color from conversation.
I'm not sure if my migration is correct, because I just copied m6 by hand and renamed it to m7 and added the new property DraftFileTokens.