-
-
Notifications
You must be signed in to change notification settings - Fork 673
outbox: Fix some bugs from Narrow confusion; remove Narrow #4299
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4801c89
outbox [nfc]: Move narrow parsing next to narrow case-breakdown.
gnprice afb9462
outbox [nfc]: Parse narrow in a structured way.
gnprice aff51f5
outbox: Properly get user data on sending to cross-realm bots, too.
gnprice c369d4e
outbox: Cut NULL_USER fallback on PM recipients.
gnprice 90d530e
outbox [nfc]: Swap `getOwnUser` for NULL_USER-using variant.
gnprice 5b52614
outbox: Stop duplicating self as PM recipient; sort all recipients.
gnprice eab2db0
example data: Fix outbox message to have a plausible narrow.
gnprice 7d9ecbb
narrowsSelectors tests: Use more-plausible outbox data.
gnprice 4ec75cf
narrow [nfc]: Push `flags` messiness up from isMessageInNarrow.
gnprice 1faf26b
outbox: Replace narrowContains with something more solid.
gnprice 58dbec1
outbox [nfc]: Confirm a conjecture, to use `narrow` a bit less.
gnprice 2691ed6
outbox [nfc]: Send based on `display_recipient`, not `narrow`.
gnprice 17b29ec
outbox [nfc]: And cut the Narrow property entirely!
gnprice e47aa00
outbox [nfc]: Add a TODO to switch to numeric IDs when sending.
gnprice 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,7 @@ describe('getMessagesForNarrow', () => { | |
// them to be numbers. | ||
[123]: message /* eslint-disable-line no-useless-computed-key */, | ||
}; | ||
const outboxMessage = eg.makeOutboxMessage({ | ||
narrow: HOME_NARROW, | ||
}); | ||
const outboxMessage = eg.makeOutboxMessage({}); | ||
|
||
test('if no outbox messages returns messages with no change', () => { | ||
const state = eg.reduxState({ | ||
|
@@ -36,6 +34,7 @@ describe('getMessagesForNarrow', () => { | |
}, | ||
messages, | ||
outbox: [], | ||
realm: eg.realmState({ email: eg.selfUser.email }), | ||
}); | ||
|
||
const result = getMessagesForNarrow(state, HOME_NARROW); | ||
|
@@ -53,6 +52,7 @@ describe('getMessagesForNarrow', () => { | |
caughtUp: { | ||
[HOME_NARROW_STR]: { older: false, newer: true }, | ||
}, | ||
realm: eg.realmState({ email: eg.selfUser.email }), | ||
}); | ||
|
||
const result = getMessagesForNarrow(state, HOME_NARROW); | ||
|
@@ -67,6 +67,7 @@ describe('getMessagesForNarrow', () => { | |
}, | ||
messages, | ||
outbox: [outboxMessage], | ||
realm: eg.realmState({ email: eg.selfUser.email }), | ||
}); | ||
|
||
const result = getMessagesForNarrow(state, HOME_NARROW); | ||
|
@@ -80,7 +81,8 @@ describe('getMessagesForNarrow', () => { | |
[JSON.stringify(privateNarrow('[email protected]'))]: [123], | ||
}, | ||
messages, | ||
outbox: [{ ...outboxMessage, narrow: streamNarrow('denmark') }], | ||
outbox: [outboxMessage], | ||
realm: eg.realmState({ email: eg.selfUser.email }), | ||
}); | ||
|
||
const result = getMessagesForNarrow(state, privateNarrow('[email protected]')); | ||
|
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
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.
It looks like this is setting
realm.email
in the state because that value gets passed directly asownEmail
toisMessageInNarrow
, having been selected bygetOwnEmail
(thatgetOwnEmail
use having been added in this same commit).I do notice that
getOwnEmail
has this in its JSDoc:(#3764)
It looks like
getOwnUser
itself usesgetOwnEmail
, so it's not obviously better, I guess.But I could imagine that being changed someday; I could see
getOwnUser
instead using, e.g.,getOwnUserId
(there's even a comment ongetOwnUserId
suggesting to do so) andgetUserForId
.If such a change were made, it would no longer be useful to just set
state.realm.email
; we'd want to setstate.realm.user_id
. Possibly that's totally fine, and a bridge we'll happily cross when we get to it. But I wondered if we might like to consider providing a simple way to grabstate.realm
from the example data such that it contains all the stuff that's specific to the self-user: there'semail
,user_id
, probably 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.
Yeah, I agree -- that would be useful, and we'll want to add something like that. A more "batteries included" example Redux state, one might call it.
The reason I haven't yet gone and done that is that there are some API choices to be made about it:
eg.selfUser
, instate.realm
.eg.selfUser
instate.users
, and a corresponding account (witheg.realm
) instate.accounts
.eg.otherUser
instate.users
? Alsoeg.thirdUser
?eg.crossRealmBot
?eg.stream
andeg.subscription
. Does it include those instate.streams
andstate.subscriptions
?eg.reduxState
.thirdUser
?eg.makeStream()
call, it can assume that stream isn't in the example state; but it can't make an assumption like "there's only one stream in the state".This diff (as you saw, there are a good handful of lines like this one) definitely made me think about adding this. 🙂 Not enough that I felt I wanted to do it before shipping this branch, but it moved that feeling closer.
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.
Makes sense, that's fine! So I'd say you can merge this branch at will.