Skip to content

Commit

Permalink
feat: Launch stack request on focus
Browse files Browse the repository at this point in the history
Since we send a (fake) message via postMessage,
Cozy Drive's intent will catch it and
send the _all_docs request. Like that
we warm up the query and the data and
we expect to give a better UX like that.
  • Loading branch information
Crash-- committed Sep 30, 2022
1 parent 2563c82 commit 04197ef
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ class SearchBar extends Component {
}

changeFocusState = focused => {
// hack in order to launch the stack request on drive.
// it'll be solved by using v8 or v9 bar on Drive
const availableSources = this.sources.filter(source => source.ready)
availableSources.forEach(async source => {
await new Promise(resolve => {
const resolverId = new Date().getTime().toString()
source.resolvers[resolverId] = resolve
source.window.postMessage(
{ query: 'fakedata', id: resolverId },
source.origin
)
})
})
this.setState({
focused
})
Expand Down

0 comments on commit 04197ef

Please sign in to comment.