Skip to content
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

Speed up Home initialization #2259

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"@sentry/react": "7.119.0",
"comlink": "4.4.1",
"cozy-client": "^51.6.0",
"cozy-dataproxy-lib": "^1.9.0",
"cozy-device-helper": "2.7.0",
"cozy-dataproxy-lib": "^2.3.0",
"cozy-device-helper": "3.7.1",
"cozy-devtools": "^1.2.1",
"cozy-doctypes": "1.83.8",
"cozy-flags": "4.0.0",
Expand Down
22 changes: 6 additions & 16 deletions src/components/Applications.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, useEffect, useRef } from 'react'
import React, { memo } from 'react'
import memoize from 'lodash/memoize'
import uniqBy from 'lodash/uniqBy'
import { useQuery } from 'cozy-client'
Expand Down Expand Up @@ -60,42 +60,32 @@ const getApplicationsList = data => {
}
}

export const Applications = ({ onAppsFetched }) => {
export const Applications = () => {
const showLogout = !!flag('home.mainlist.show-logout')
const { t } = useI18n()

const { data } = useQuery(appsConn.query, appsConn)
const { data: apps } = useQuery(appsConn.query, appsConn)

const homeMagicFolderConn = mkHomeMagicFolderConn(t)

const magicHomeFolder = useQuery(
homeMagicFolderConn.query,
homeMagicFolderConn
)

const magicHomeFolderId = magicHomeFolder?.data?.[0]?._id
const homeShortcutsConn = mkHomeShorcutsConn(magicHomeFolderId)
const { data: shortcuts } = useQuery(homeShortcutsConn.query, {
...homeShortcutsConn,
enabled: !!magicHomeFolderId
})

const didLoad = useRef(false)

useEffect(() => {
const isReady =
didLoad.current === false && onAppsFetched && isValidData(data)

if (isReady) {
onAppsFetched(data)
didLoad.current = true
}
}, [data, onAppsFetched])

return (
<div className="app-list-wrapper u-m-auto u-w-100">
<Divider className="u-mv-0" />

<div className="app-list u-w-100 u-mv-3 u-mt-2-t u-mb-1-t u-mh-auto u-flex-justify-center">
{getApplicationsList(data)}
{getApplicationsList(apps)}

{shortcuts &&
shortcuts.map((shortcut, index) => (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Announcements } from 'components/Announcements/Announcements'

import styles from './styles.styl'

const Home = ({ setAppsReady, wrapper }) => {
const Home = ({ wrapper }) => {
const { pathname } = useLocation()
const { isMobile } = useBreakpoints()

Expand All @@ -38,7 +38,7 @@ const Home = ({ setAppsReady, wrapper }) => {
getFlagshipMetadata().immersive
})}
>
<Applications onAppsFetched={setAppsReady} />
<Applications />
<Shortcuts />
{flag('home.detailed-services-dev') ? (
<GroupedServices />
Expand Down
1 change: 0 additions & 1 deletion src/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ const App = ({ accounts, konnectors, triggers }) => {
element={
<Home
wrapper={contentWrapper}
setAppsReady={() => setAppsReady(true)}
shortcutsDirectories={shortcutsDirectories}
/>
}
Expand Down
113 changes: 0 additions & 113 deletions src/dataproxy/DataProxyProvider.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const makeTriggersQuery = {
definition: () => {
return Q('io.cozy.triggers')
.partialIndex({
worker: 'konnector'
worker: { $in: ['client', 'konnector'] } // client is for CLISK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, as you explain in the description of this commit, this request does not fetch jobs. And these jobs are needed to compute the current_state attribute of the trigger which is needed to know if the trigger has any error.

I must admit I have some difficulties to follow the flow of the front code to know where and how it is used but if I try your branch in my local cozy, I don't have any error status displayed on konnector icons in home application.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh looks like I missed this case. I guess we could query the triggers with job info at the moment we click on the konnector "group" as it is at his moment that we display the error icon, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 48e75e1

})
.limitBy(1000)
},
Expand Down
25 changes: 12 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6079,22 +6079,28 @@ cozy-client@^51.6.0:
sift "^6.0.0"
url-search-params-polyfill "^8.0.0"

cozy-dataproxy-lib@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/cozy-dataproxy-lib/-/cozy-dataproxy-lib-1.9.0.tgz#5e43d49f2ac86e5d6a96bb74260e2567392626eb"
integrity sha512-ij9a3x20THxCRjvqcG8yR3hJXZhidDWawaTsfQaCT/eQUS5vwGx4Ob2p6Fur4G8GqayMSmbMsrfkGXv4JlEb/g==
cozy-dataproxy-lib@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/cozy-dataproxy-lib/-/cozy-dataproxy-lib-2.3.0.tgz#c702c36a674c61edffd31e10d3c9e3665f64c4ef"
integrity sha512-rDYd3yOykArExr8Iz/hoP+2jI57NX0Z/LIDsPmH3W9vifXnb1SVBfekxE4vNXj9vJKLSZ8vfKgl3OuqYbOKVow==
dependencies:
classnames "2.5.1"
comlink "4.4.1"
cozy-device-helper "^3.7.1"
cozy-pouch-link "^50.3.1"
flexsearch "0.7.43"
lodash "4.17.21"
mime-types "2.1.35"
react-type-animation "3.2.0"
rooks "7.14.1"

cozy-device-helper@2.7.0, cozy-device-helper@^2.1.0:
cozy-device-helper@3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/cozy-device-helper/-/cozy-device-helper-3.7.1.tgz#59f11ab3ab92335525a767e78f983b07eeaf4eea"
integrity sha512-D0zkEFynUrICNhQixyyYGhRHTwgJL+pf7XtmTwjKePIn2pNHKw5V64IhGg9uLYf6tI9uivkUKvZvFYuKzEvlqA==
dependencies:
lodash "^4.17.19"

cozy-device-helper@^2.1.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/cozy-device-helper/-/cozy-device-helper-2.7.0.tgz#573749997f18e5a1f11f720faec8c9bf2406beeb"
integrity sha512-jMzW7s4IDuMivbsP8fo1IWW1z5l0wJ0u440E0fQmdsi+Zm/L9GXFKthLuuceYqXlH6c/APUCfpozJqjFMMHU1A==
Expand All @@ -6115,13 +6121,6 @@ cozy-device-helper@^3.1.2:
dependencies:
lodash "^4.17.19"

cozy-device-helper@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/cozy-device-helper/-/cozy-device-helper-3.7.1.tgz#59f11ab3ab92335525a767e78f983b07eeaf4eea"
integrity sha512-D0zkEFynUrICNhQixyyYGhRHTwgJL+pf7XtmTwjKePIn2pNHKw5V64IhGg9uLYf6tI9uivkUKvZvFYuKzEvlqA==
dependencies:
lodash "^4.17.19"

cozy-devtools@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/cozy-devtools/-/cozy-devtools-1.2.1.tgz#680976ab69ebdf2d2727cffc07243705794d1a83"
Expand Down