Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: optimize bulk chat item deletion #1168

Merged
merged 4 commits into from
Oct 3, 2022
Merged

Conversation

spaced4ndy
Copy link
Contributor

No description provided.

@spaced4ndy spaced4ndy marked this pull request as ready for review October 3, 2022 17:26
withStore' $ \db -> updateContactTs db user ct lastItemTs
pure (ct :: Contact) {updatedAt = lastItemTs}
filesInfo <- withStore' $ \db -> getContactFileInfo db user ct
maxItemTs_ <- withStore' $ \db -> getContactMaxItemTs db user ct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be better to choose ID for contacts - for example the one that all chat items before this ID are older than specified. This way we will be deleting in the order of the chat, but some older chat items may remain.

withStore' $ \db -> updateGroupTs db user gInfo lastItemTs
pure (gInfo :: GroupInfo) {updatedAt = lastItemTs}
filesInfo <- withStore' $ \db -> getGroupFileInfo db user gInfo
maxItemTs_ <- withStore' $ \db -> getGroupMaxItemTs db user gInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For groups it probably should be a pair of timestamp and chat item ID.

SMDRcv -> do
ft@RcvFileTransfer {cancelled} <- withStore (\db -> getRcvFileTransfer db user fileId)
unless cancelled $ cancelRcvFileTransfer user ft
deleteFile :: forall m. ChatMonad m => User -> CIFileInfo -> m ()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still delete the connection somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@epoberezkin epoberezkin merged commit cd6cad9 into master Oct 3, 2022
@epoberezkin epoberezkin deleted the f/optimize-delete branch October 3, 2022 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants