Skip to content

Commit

Permalink
feat: Simulate a call to hidesplashscreen on the web
Browse files Browse the repository at this point in the history
Like that, no need to be in the flagship env to test the behavior on the
web.
  • Loading branch information
Crash-- committed Jan 15, 2024
1 parent 11a9c12 commit 4cbe2f6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/webpack.config.cozy-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ module.exports = {
/WebVaultClient/, // EEFLongWordList
/cozy-ui\/transpiled\/react\/Portal\/index\.js/ // preact-portal
]
}),

new webpack.DefinePlugin({
__SIMULATE_FLAGSHIP__: true
})
].filter(Boolean)
}
4 changes: 4 additions & 0 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ $ yarn start
```

[setup]: https://docs.cozy.io/en/tutorials/app/#install-the-development-environment "Cozy dev docs: Set up the Development Environment"

### Flagship mode

If you want to simulate flagship environment, you can edit the `__SIMULATE_FLAGSHIP__` var in the `webpack.config.cozy-home.js`. It'll simulate a splashscreen during the loading of the application and simulate a call to `hideSplashscreen`.
4 changes: 4 additions & 0 deletions src/containers/App.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global __SIMULATE_FLAGSHIP__ */
import React, { useEffect, useState } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom'

Expand Down Expand Up @@ -119,6 +120,9 @@ const App = ({ accounts, konnectors, triggers }) => {
webviewIntent.call('setTheme', theme)
webviewIntent.call('hideSplashScreen')
}
if (isReady && !webviewIntent && __SIMULATE_FLAGSHIP__) {
document.getElementById('splashscreen').style.display = 'none'
}
}, [isReady, theme, webviewIntent])

return (
Expand Down
5 changes: 4 additions & 1 deletion src/targets/browser/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
{{.ThemeCSS}}
</head>

<body>
<body style="display: block;margin: 0">
<% if (__SIMULATE_FLAGSHIP__) { %>
<div style="position:absolute; z-index: 1000; height: 100%; width: 100%; background-color: blue; opacity: 0.5;" id="splashscreen">splashscreen</div>
<% }; %>
<div role="application" data-cozy="{{.CozyData}}" data-cozy-token="{{.Token}}" data-cozy-domain="{{.Domain}}"
data-cozy-locale="{{.Locale}}" data-cozy-app-editor="{{.AppEditor}}" data-cozy-app-name="{{.AppName}}"
data-cozy-app-name-prefix="{{.AppNamePrefix}}" data-cozy-app-slug="{{.AppSlug}}" data-cozy-tracking="{{.Tracking}}"
Expand Down

0 comments on commit 4cbe2f6

Please sign in to comment.