fix: in web implementation session token is never used during the place autocomplete#45
Conversation
ad382e0 to
ad81622
Compare
| } | ||
|
|
||
| AutocompleteSessionToken _getSessionToken({required bool force}) { | ||
| final localToken = _lastSessionToken; |
There was a problem hiding this comment.
Could you please elaborate on it a bit?
I need to understand how this code is supposed to work.
According to code, _lastSessionToken is always null just because it's never assigned.
Shouldn't it be something like
return force || _lastSessionToken == null ? (_lastSessionToken = AutocompleteSessionToken()) : _lastSessionToken!;There was a problem hiding this comment.
@AndreiMisiukevich ther last session token should be set from the response - not from us.
There was a problem hiding this comment.
@AndreiMisiukevich Before, the _lastSessionToken was always null, now on each request we check if the session token is valid and set a new session token if needed: _lastSessionToken is null on first request.
| // https://issuetracker.google.com/issues/36219203 | ||
| log("locationRestriction is not supported: https://issuetracker.google.com/issues/36219203"); | ||
| } | ||
| final sessionToken = _getSessionToken(force: newSessionToken == true); |
There was a problem hiding this comment.
| final sessionToken = _getSessionToken(force: newSessionToken == true); | |
| final sessionToken = _getSessionToken(force: newSessionToken ?? false); |
There was a problem hiding this comment.
@AndreiMisiukevich it has the same meaning, and == true is what we do in the mobile implementation
There was a problem hiding this comment.
@matanshukry Yeah, I got it.
Just think it doesn't look good. But yeah, it's a personal preference, I think. Not a clean code rule :)
matanshukry
left a comment
There was a problem hiding this comment.
I also mentioned that in the comments - but the last session token should be set based on the response -which is missing here.
Also see this: #31 fro the corect usage of the tokens, which it doesn't do.
- If you match the web package to the mobile (missing setting the value from the response) - we'll merge.
- If you prefer to go ahead and impleemnt the correct behavior based on the issue - we can merge that too.
| // https://issuetracker.google.com/issues/36219203 | ||
| log("locationRestriction is not supported: https://issuetracker.google.com/issues/36219203"); | ||
| } | ||
| final sessionToken = _getSessionToken(force: newSessionToken == true); |
There was a problem hiding this comment.
@AndreiMisiukevich it has the same meaning, and == true is what we do in the mobile implementation
| } | ||
|
|
||
| AutocompleteSessionToken _getSessionToken({required bool force}) { | ||
| final localToken = _lastSessionToken; |
There was a problem hiding this comment.
@AndreiMisiukevich ther last session token should be set from the response - not from us.
|
@AndreiMisiukevich why the install dependencies failed? Which version of flutter is needed? |
|
@mrcsilverfox it's because of the flutter version the CI is using; you can ignore that. |
Do you think that is enough? Or we have to use the completer as used in Although I didn't understand why the session token should be set based on the response. Why can't the session token be set in the |
b7fecf5 to
3dc608f
Compare
3dc608f to
2630d5a
Compare
|
@matanshukry Any updates on this PR? |
|
Any updates? |
In web implementation session token is never used during the place autocomplete