-
Notifications
You must be signed in to change notification settings - Fork 270
feat: Allow user to control message view mode #10945
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
Open
SebastianKrupinski
wants to merge
5
commits into
main
Choose a base branch
from
enh/issue-5913-diable-mail-threading
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2c6772c
feat: Allow disabling of threaded view
SebastianKrupinski 3d6cd5e
fixup! feat: Allow disabling of threaded view
SebastianKrupinski 8498a7a
fixup! feat: Allow disabling of threaded view
SebastianKrupinski 0e91868
fixup! feat: Allow disabling of threaded view
SebastianKrupinski 63b7546
fixup! feat: Allow disabling of threaded view
SebastianKrupinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,8 @@ | |
* @param int $cursor | ||
* @param string $filter | ||
* @param int|null $limit | ||
* @param string $sort returns messages in requested order ('newest' or 'oldest') | ||
* @param string $view returns messages in requested view ('singleton' or 'threaded') | ||
* | ||
* @return JSONResponse | ||
* | ||
|
@@ -134,7 +136,9 @@ | |
public function index(int $mailboxId, | ||
?int $cursor = null, | ||
?string $filter = null, | ||
?int $limit = null): JSONResponse { | ||
?int $limit = null, | ||
?string $sort = null, | ||
?string $view = null): JSONResponse { | ||
try { | ||
$mailbox = $this->mailManager->getMailbox($this->currentUserId, $mailboxId); | ||
$account = $this->accountService->find($this->currentUserId, $mailbox->getAccountId()); | ||
|
@@ -143,17 +147,25 @@ | |
} | ||
|
||
$this->logger->debug("loading messages of mailbox <$mailboxId>"); | ||
|
||
$order = $this->preferences->getPreference($this->currentUserId, 'sort-order', 'newest') === 'newest' ? 'DESC': 'ASC'; | ||
if ($sort === null) { | ||
$sort = $this->preferences->getPreference($this->currentUserId, 'sort-order', 'newest') === 'newest' ? IMailSearch::ORDER_NEWEST_FIRST: IMailSearch::ORDER_OLDEST_FIRST; | ||
} else { | ||
$sort = $sort === 'newest' ? IMailSearch::ORDER_NEWEST_FIRST: IMailSearch::ORDER_OLDEST_FIRST; | ||
} | ||
if ($view !== null) { | ||
$view = $view === 'singleton' ? IMailSearch::VIEW_SINGLETON : IMailSearch::VIEW_THREADED; | ||
} | ||
$messages = $this->mailSearch->findMessages( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inline the var and you have a smaller diff ✨ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, Hopefully this is what you ment |
||
$account, | ||
$mailbox, | ||
$sort, | ||
$filter === '' ? null : $filter, | ||
$cursor, | ||
$limit, | ||
$view | ||
); | ||
return new JSONResponse( | ||
$this->mailSearch->findMessages( | ||
$account, | ||
$mailbox, | ||
$order, | ||
$filter === '' ? null : $filter, | ||
$cursor, | ||
$limit | ||
) | ||
$messages | ||
); | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
We can't use IMailSearcH::sort_* here the UI sends 'newest' or 'oldest' and the value of IMailSearch::ORDER_* is 'DESC' and 'ASC'
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.
And this can't be streamlined?
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.
This was existing code for the most part, the only change to the sort was that the UI now sends the sort order vs the controller pulling the value from the database every time.
I didn't want to refactor sort as it was out of scope for this PR and would make the review more difficult.
I can address this in a follow-up if you want, or do you want it as part of this PR?
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.
Do a follow-up
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.
Done, removed the sort code changes.