Skip to content

Commit 6a10a65

Browse files
Merge pull request #1044 from appwrite/fix-async-calls
chore: remove unnecessary async and spacing
2 parents 56f0948 + 5a14b7a commit 6a10a65

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/SDK/Language/Web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function getGenerics(string $model, array $spec, bool $skipFirst = false)
269269
public function getReturn(array $method, array $spec): string
270270
{
271271
if ($method['type'] === 'webAuth') {
272-
return 'Promise<void | string>';
272+
return 'void | string';
273273
}
274274

275275
if ($method['type'] === 'location') {

templates/node/src/services/template.ts.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class {{ service.name | caseUcfirst }} {
3636
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
3737
* @returns {{ '{' }}{{ method | getReturn(spec) | raw }}{{ '}' }}
3838
*/
39-
{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required or parameter.nullable %}?{% endif %}: {{ parameter | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
39+
{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required or parameter.nullable %}?{% endif %}: {{ parameter | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
4040
{%~ for parameter in method.parameters.all %}
4141
{%~ if parameter.required %}
4242
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {

templates/web/src/services/template.ts.twig

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class {{ service.name | caseUcfirst }} {
3737
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
3838
* @returns {{ '{' }}{{ method | getReturn(spec) | raw }}{{ '}' }}
3939
*/
40-
{% if method.type != 'location' %}async {% endif %}{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required or parameter.nullable %}?{% endif %}: {{ parameter | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
40+
{{ method.name | caseCamel }}{{ method.responseModel | getGenerics(spec) | raw }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required or parameter.nullable %}?{% endif %}: {{ parameter | getPropertyType(method) | raw }}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, onProgress = (progress: UploadProgress) => {}{% endif %}): {{ method | getReturn(spec) | raw }} {
4141
{%~ for parameter in method.parameters.all %}
4242
{%~ if parameter.required %}
4343
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {
@@ -68,18 +68,20 @@ export class {{ service.name | caseUcfirst }} {
6868
{%~ endfor %}
6969
}
7070

71+
{%~ if method.type == 'location' or method.type == 'webAuth' %}
72+
{%~ if method.auth|length > 0 %}
7173
{%~ for node in method.auth %}
7274
{%~ for key,header in node|keys %}
7375
payload['{{header|caseLower}}'] = this.client.config.{{header|caseLower}};
7476
{%~ endfor %}
7577
{%~ endfor %}
78+
{%~ endif %}
7679

77-
{%~ if method.type == 'location' or method.type == 'webAuth' %}
7880
for (const [key, value] of Object.entries(Service.flatten(payload))) {
7981
uri.searchParams.append(key, value);
8082
}
83+
8184
{%~ endif %}
82-
8385
{%~ if method.type == 'webAuth' %}
8486
if (typeof window !== 'undefined' && window?.location) {
8587
window.location.href = uri.toString();

0 commit comments

Comments
 (0)