Skip to content

Commit 7c962a6

Browse files
committed
better user agent
1 parent cff6b95 commit 7c962a6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/main/utils/user-agent.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ interface UserAgentStore {
99
}
1010
}
1111

12-
const _getUA = (appVersion: string): string => {
12+
const _getUA = (): string => {
1313
const maxIndex = userAgents.length - 1
1414
const index = crypto.randomInt(0, maxIndex)
1515

16-
const userAgent = userAgents[index] + ' DofusTouch Client ' + appVersion
17-
return userAgent
16+
return userAgents[index]
1817
}
1918

2019
export const generateUserArgent = async (appVersion: string) => {
2120
const storage = new ElectronStore<UserAgentStore>()
2221
const now = new Date()
2322

23+
let ua: string
2424
if (!storage.get('userAgent') || new Date(storage.get('userAgent').maxAge) < now) {
25-
const ua = _getUA(appVersion)
25+
ua = _getUA()
2626

2727
const expireDay = crypto.randomInt(10, 360)
2828
const maxAge = new Date(now.setDate(now.getDate() + expireDay)).toString()
@@ -31,9 +31,9 @@ export const generateUserArgent = async (appVersion: string) => {
3131
ua,
3232
maxAge
3333
} as UserAgentStore['userAgent'])
34-
35-
return ua
3634
} else {
37-
return storage.get('userAgent').ua
35+
ua = storage.get('userAgent').ua
3836
}
37+
38+
return ua + ' DofusTouch Client ' + appVersion
3939
}

0 commit comments

Comments
 (0)