Skip to content

Commit

Permalink
Ensure updating function doesn't reset other params
Browse files Browse the repository at this point in the history
For any optional param not sent to the API, the values are reset to the
default value. This update ensures we pass the existing values so that
they aren't reset.
  • Loading branch information
stnguyen90 committed Nov 23, 2022
1 parent e554b5f commit 95e5d10
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@
async function updateName() {
try {
await sdkForProject.functions.update(functionId, functionName, $func.execute);
await sdkForProject.functions.update(
functionId,
functionName,
$func.execute,
$func.events,
$func.schedule,
$func.timeout,
$func.enabled
);
invalidate(Dependencies.FUNCTION);
addNotification({
message: 'Name has been updated',
Expand All @@ -79,7 +87,15 @@
async function updatePermissions() {
try {
await sdkForProject.functions.update(functionId, $func.name, permissions);
await sdkForProject.functions.update(
functionId,
$func.name,
permissions,
$func.events,
$func.schedule,
$func.timeout,
$func.enabled
);
invalidate(Dependencies.FUNCTION);
addNotification({
message: 'Permissions have been updated',
Expand All @@ -100,7 +116,10 @@
functionId,
$func.name,
$func.execute,
Array.from($eventSet)
Array.from($eventSet),
$func.schedule,
$func.timeout,
$func.enabled
);
invalidate(Dependencies.FUNCTION);
addNotification({
Expand All @@ -124,7 +143,8 @@
$func.execute,
$func.events,
functionSchedule,
timeout
$func.timeout,
$func.enabled
);
invalidate(Dependencies.FUNCTION);
Expand All @@ -149,9 +169,11 @@
$func.execute,
$func.events,
$func.schedule,
timeout
timeout,
$func.enabled
);
invalidate(Dependencies.FUNCTION);
addNotification({
type: 'success',
message: 'Timeout has been updated'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { page } from '$app/stores';
import { derived, writable, type Writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';

export const func = derived(page, ($page) => $page.data.function);
export const func = derived(page, ($page) => $page.data.function as Models.Function);
export const execute: Writable<Models.Function> = writable();

0 comments on commit 95e5d10

Please sign in to comment.