-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
PMs from new sources not immediately displayed in PMs list #3654
Comments
Yikes, that's a pretty bad symptom! Would definitely be good to fix. The bug will very probably be in one of the "reducer" files maintaining the data structures that PM conversation list relies on. |
Aha! The 'narrows' state is not being updated to reflect the new messages, when it should. Here's why: When a PM arrives and an EVENT_NEW_MESSAGE action is dispatched, (src/chat/narrowsReducer.js, in eventNewMessage)
But Further investigation will almost certainly involve #3133 (currently open as P1 from November 2018); I just wanted to jot this finding down before I forget. |
Thanks @chrisbobbe for the investigation and that writeup!
Yeah, this sounds like a point where something's already gone wrong, then. The code that makes that request (fetchPrivateMessages which is dispatched during doInitialFetch in src/message/fetchActions.js, as you said) looks like this: const fetchPrivateMessages = () => async (dispatch: Dispatch, getState: GetState) => {
const auth = getAuth(getState());
const { messages, found_newest, found_oldest } = await tryUntilSuccessful(() =>
api.getMessages(auth, ALL_PRIVATE_NARROW, LAST_MESSAGE_ANCHOR, 100, 0), where export const LAST_MESSAGE_ANCHOR = Number.MAX_SAFE_INTEGER; and that export default async (
auth: Auth,
narrow: Narrow,
anchor: number,
numBefore: number,
numAfter: number,
useFirstUnread: boolean = false,
): Promise<ApiResponseMessages> => {
const response: ServerApiResponseMessages = await apiGet(auth, 'messages', {
narrow: JSON.stringify(narrow),
anchor,
num_before: numBefore,
num_after: numAfter,
apply_markdown: true,
use_first_unread_anchor: useFirstUnread,
}); It sure looks to me like that ought to result in |
This may be due to our use of stringified JSON objects as keys in |
I'd certainly expect that the result for any query of that form to have |
Interesting! I think what's going on is a consequence of your requesting 0 messages as Writing more details now. |
For now, I think against legacy Zulip servers with the current behavior, while the mobile app is using the specific type of query it's using, it should assume Here's the relevant code:
The logic is as follows, roughly:
I haven't had time to think through this deeply but here are a few thoughts:
|
Thanks for the writeup and suggestions, @timabbott! I haven't forgotten about this, but I'd like to check in with @gnprice about it next week when he's in the office. |
Thanks @timabbott for the investigation!
This sounds like a good client-side fix. I think what this comes out to is that whenever we use (And when further we're passing ... Oh aha, but:
That sounds like a simpler workaround 🙂 We'd coax the server into giving the right answer in the first place, rather than fix up the answer with our own logic. I think this'd be just a one-line change to the For the server-side fix:
|
Yeah, |
A wart that has long been present inin Zulip's get_messages API is how to request "the latest messages" in the API. Previously, the recommendation was basically to pass anchor=10000000000000000 (for an appropriately huge number). An accident of the server's implementation meant that specific number of 0s was actually important to avoid a buggy (or at least wasteful) value of found_newest=False if the query had specified num_after=0 (since we didn't check). This was the cause of the mobile issue zulip/zulip-mobile#3654. The solution is to allow passing a special value of anchor='newest', basically a special string-type value that the server can interpret as meaning the user precisely just wants the most recent messages. We also add an analogous anchor='oldest' or similar to avoid folks needing to write a somewhat ugly anchor=0 for fetching the very first messages. We may want to also replace the use_first_unread_anchor argument to be a "first_unread" value for the anchor parameter. While it's not always ideal to make a value have a variable type like this, in this case it seems like a really clean way to express the idea of what the user is asking for in the API.
A wart that has long been present inin Zulip's get_messages API is how to request "the latest messages" in the API. Previously, the recommendation was basically to pass anchor=10000000000000000 (for an appropriately huge number). An accident of the server's implementation meant that specific number of 0s was actually important to avoid a buggy (or at least wasteful) value of found_newest=False if the query had specified num_after=0 (since we didn't check). This was the cause of the mobile issue zulip/zulip-mobile#3654. The solution is to allow passing a special value of anchor='newest', basically a special string-type value that the server can interpret as meaning the user precisely just wants the most recent messages. We also add an analogous anchor='oldest' or similar to avoid folks needing to write a somewhat ugly anchor=0 for fetching the very first messages. We may want to also replace the use_first_unread_anchor argument to be a "first_unread" value for the anchor parameter. While it's not always ideal to make a value have a variable type like this, in this case it seems like a really clean way to express the idea of what the user is asking for in the API.
A wart that has long been present inin Zulip's get_messages API is how to request "the latest messages" in the API. Previously, the recommendation was basically to pass anchor=10000000000000000 (for an appropriately huge number). An accident of the server's implementation meant that specific number of 0s was actually important to avoid a buggy (or at least wasteful) value of found_newest=False if the query had specified num_after=0 (since we didn't check). This was the cause of the mobile issue zulip/zulip-mobile#3654. The solution is to allow passing a special value of anchor='newest', basically a special string-type value that the server can interpret as meaning the user precisely just wants the most recent messages. We also add an analogous anchor='oldest' or similar to avoid folks needing to write a somewhat ugly anchor=0 for fetching the very first messages. We may want to also replace the use_first_unread_anchor argument to be a "first_unread" value for the anchor parameter. While it's not always ideal to make a value have a variable type like this, in this case it seems like a really clean way to express the idea of what the user is asking for in the API.
A wart that has long been present inin Zulip's get_messages API is how to request "the latest messages" in the API. Previously, the recommendation was basically to pass anchor=10000000000000000 (for an appropriately huge number). An accident of the server's implementation meant that specific number of 0s was actually important to avoid a buggy (or at least wasteful) value of found_newest=False if the query had specified num_after=0 (since we didn't check). This was the cause of the mobile issue zulip/zulip-mobile#3654. The solution is to allow passing a special value of anchor='newest', basically a special string-type value that the server can interpret as meaning the user precisely just wants the most recent messages. We also add an analogous anchor='oldest' or similar to avoid folks needing to write a somewhat ugly anchor=0 for fetching the very first messages. We may want to also replace the use_first_unread_anchor argument to be a "first_unread" value for the anchor parameter. While it's not always ideal to make a value have a variable type like this, in this case it seems like a really clean way to express the idea of what the user is asking for in the API.
The server-side change, zulip/zulip/#13747 is merged and deployed on chat.zulip.org. We went with Thanks for all the design work on this; that "giant message ID" business has since we first designed the As we discussed, to handle backwards-compatibility on mobile, you'll just want to use that special number for older servers, and then add a conditional for Zulip 2.2.x to use the new interface. |
Great! 🙂
We'll store the server version number on login and update it from a /server_settings request done along with every /register request, following #3839 (or something to that effect). 🙂 |
I think in fact the fix is simpler even than that: we should just start passing that special number, 10000000000000000 (that's 16 zeroes) when we want the latest, instead of the other giant number we use today. Optionally in the future we can add a conditional to do something else for newer server versions. But the fix for this bug should not block on that. (See also zulip/zulip#13747 (comment) where I said this earlier.) |
Fixes: zulip#3654. The server correctly interprets this special number as indicating that we want the latest messages (0 is used to request the oldest messages). Later, we can conditionalize on the server version to support the updated API merged in zulip/zulip#13747, that use the strings 'oldest' and 'newest' instead of 0 and 10000000000000000.
Fixes: zulip#3654. The server correctly interprets this special number as indicating that we want the latest messages (0 is used to request the oldest unread messages). Later, we can conditionalize on the server version to support the updated API merged in zulip/zulip#13747, that use the strings 'oldest' and 'newest' instead of 0 and 10000000000000000.
Fixes: zulip#3654. The server correctly interprets this special number as indicating that we want the latest messages. The larger value we had been using will certainly get the latest messages, because it's larger than any possible message ID, but the server won't make that inference and can incorrectly report `found_newest: false`. Later, we can conditionalize on the server version to use the updated API merged in zulip/zulip#13747, which uses the string 'newest' instead of a special number. [greg: revised commit message]
A wart that has long been present inin Zulip's get_messages API is how to request "the latest messages" in the API. Previously, the recommendation was basically to pass anchor=10000000000000000 (for an appropriately huge number). An accident of the server's implementation meant that specific number of 0s was actually important to avoid a buggy (or at least wasteful) value of found_newest=False if the query had specified num_after=0 (since we didn't check). This was the cause of the mobile issue zulip/zulip-mobile#3654. The solution is to allow passing a special value of anchor='newest', basically a special string-type value that the server can interpret as meaning the user precisely just wants the most recent messages. We also add an analogous anchor='oldest' or similar to avoid folks needing to write a somewhat ugly anchor=0 for fetching the very first messages. We may want to also replace the use_first_unread_anchor argument to be a "first_unread" value for the anchor parameter. While it's not always ideal to make a value have a variable type like this, in this case it seems like a really clean way to express the idea of what the user is asking for in the API.
When a user receives a PM from a new source (i.e., one that had not previously sent them a PM), the center icon will correctly display a notification for a new message... but when tapped, that conversation-source does not appear in the PMs list; it remains unrefreshed.
(Force-stopping and reentering the app will also force a refresh.)
The text was updated successfully, but these errors were encountered: