Skip to content

Commit

Permalink
Merge pull request #1044 from appwrite/fix-async-calls
Browse files Browse the repository at this point in the history
chore: remove unnecessary async and spacing
  • Loading branch information
christyjacob4 authored Mar 10, 2025
2 parents 56f0948 + 5a14b7a commit 6a10a65
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/SDK/Language/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function getGenerics(string $model, array $spec, bool $skipFirst = false)
public function getReturn(array $method, array $spec): string
{
if ($method['type'] === 'webAuth') {
return 'Promise<void | string>';
return 'void | string';
}

if ($method['type'] === 'location') {
Expand Down
2 changes: 1 addition & 1 deletion templates/node/src/services/template.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class {{ service.name | caseUcfirst }} {
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
* @returns {{ '{' }}{{ method | getReturn(spec) | raw }}{{ '}' }}
*/
{{ 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 }} {
{{ 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 }} {
{%~ for parameter in method.parameters.all %}
{%~ if parameter.required %}
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {
Expand Down
8 changes: 5 additions & 3 deletions templates/web/src/services/template.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class {{ service.name | caseUcfirst }} {
* @throws {{ '{' }}{{ spec.title | caseUcfirst}}Exception}
* @returns {{ '{' }}{{ method | getReturn(spec) | raw }}{{ '}' }}
*/
{% 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 }} {
{{ 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 }} {
{%~ for parameter in method.parameters.all %}
{%~ if parameter.required %}
if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') {
Expand Down Expand Up @@ -68,18 +68,20 @@ export class {{ service.name | caseUcfirst }} {
{%~ endfor %}
}

{%~ if method.type == 'location' or method.type == 'webAuth' %}
{%~ if method.auth|length > 0 %}
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
payload['{{header|caseLower}}'] = this.client.config.{{header|caseLower}};
{%~ endfor %}
{%~ endfor %}
{%~ endif %}

{%~ if method.type == 'location' or method.type == 'webAuth' %}
for (const [key, value] of Object.entries(Service.flatten(payload))) {
uri.searchParams.append(key, value);
}

{%~ endif %}

{%~ if method.type == 'webAuth' %}
if (typeof window !== 'undefined' && window?.location) {
window.location.href = uri.toString();
Expand Down

0 comments on commit 6a10a65

Please sign in to comment.