Skip to content

Commit 2b92e64

Browse files
acezardCrash--
authored andcommitted
fix: Reapply home cookie on focus
1 parent 6701fbe commit 2b92e64

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/libs/httpserver/httpCookieManager.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const parseCookie = cookieString => {
5757
}
5858
}
5959

60+
export let setHomeCookie
61+
6062
/**
6163
* Set the cookie into the device by using CookieManager
6264
*
@@ -72,7 +74,7 @@ const parseCookie = cookieString => {
7274
* @param {CozyClient} client - CozyClient instance
7375
* @returns {Promise<boolean>}
7476
*/
75-
export const setCookie = async (cookieString, client) => {
77+
export const setCookie = async (cookieString, client, slug) => {
7678
const cookie = parseCookie(cookieString)
7779

7880
const appUrl = client.getStackClient().uri
@@ -89,5 +91,9 @@ export const setCookie = async (cookieString, client) => {
8991
sameSite: 'None' // This must be force to 'None' so iOS accepts to send it through "html injected" webview
9092
}
9193

94+
if (slug === 'home') {
95+
setHomeCookie = () => CookieManager.set(appUrl, stackCookie, true)
96+
}
97+
9298
return CookieManager.set(appUrl, stackCookie, true)
9399
}

src/libs/httpserver/httpServerProvider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const HttpServerProvider = props => {
7777

7878
const { cookie, templateValues } = await fetchAppDataForSlug(slug, client)
7979

80-
await setCookie(cookie, client)
80+
await setCookie(cookie, client, slug)
8181
const rawHtml = await getIndexForFqdnAndSlug(fqdn, slug)
8282

8383
if (!rawHtml) {

src/screens/home/components/HomeView.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { consumeRouteParameter } from '/libs/functions/routeHelpers'
99
import { resetUIState } from '/libs/intents/setFlagshipUI'
1010
import { statusBarHeight, getNavbarHeight } from '/libs/dimensions'
1111
import { useSession } from '/hooks/useSession'
12+
import { setHomeCookie } from '/libs/httpserver/httpCookieManager'
1213

1314
const injectedJavaScriptBeforeContentLoaded = () => `
1415
window.addEventListener('load', (event) => {
@@ -36,6 +37,8 @@ const HomeView = ({ route, navigation, setLauncherContext }) => {
3637
const unsubscribe = navigation.addListener('focus', () => {
3738
nativeIntent?.call(uri, 'closeApp')
3839

40+
setHomeCookie?.()
41+
3942
if (uri) {
4043
const konnectorParam = consumeRouteParameter(
4144
'konnector',

0 commit comments

Comments
 (0)