Skip to content

Commit 8d1a997

Browse files
committed
fix review comments
1 parent 6ec8dca commit 8d1a997

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

templates/react-native/src/client.ts.twig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,6 @@ class Client {
338338
credentials: 'include'
339339
};
340340

341-
if (typeof window !== 'undefined' && window.localStorage) {
342-
headers['X-Fallback-Cookies'] = window.localStorage.getItem('cookieFallback') ?? '';
343-
}
344-
345341
if (method === 'GET') {
346342
for (const [key, value] of Object.entries(Service.flatten(params))) {
347343
url.searchParams.append(key, value);

templates/react-native/src/id.ts.twig

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
export class ID {
2+
// Generate an hex ID based on timestamp
3+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
4+
static #hexTimestamp(): string {
5+
const now = new Date();
6+
const sec = Math.floor(now.getTime() / 1000);
7+
const msec = now.getMilliseconds();
8+
9+
// Convert to hexadecimal
10+
const hexTimestamp = sec.toString(16) + msec.toString(16).padStart(5, '0');
11+
return hexTimestamp;
12+
}
13+
214
public static custom(id: string): string {
315
return id
416
}
5-
6-
public static unique(): string {
7-
return 'unique()'
17+
18+
public static unique(padding: number = 7): string {
19+
// Generate a unique ID with padding to have a longer ID
20+
const baseId = ID.#hexTimestamp();
21+
let randomPadding = '';
22+
for (let i = 0; i < padding; i++) {
23+
const randomHexDigit = Math.floor(Math.random() * 16).toString(16);
24+
randomPadding += randomHexDigit;
25+
}
26+
return baseId + randomPadding;
827
}
9-
}
28+
}

templates/react-native/src/services/template.ts.twig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ export class {{ service.name | caseUcfirst }} extends Service {
8484
}
8585
{% endif %}
8686
{% if method.type == 'webAuth' %}
87-
if (typeof window !== 'undefined' && window?.location) {
88-
window.location.href = uri.toString();
89-
} else {
90-
return uri;
91-
}
87+
throw new {{ spec.title | caseUcfirst}}Exception('Not yet supported');
9288
{% elseif method.type == 'location' %}
9389
return uri;
9490
{% else %}

0 commit comments

Comments
 (0)