mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
prevent failed document update from returning error
This commit is contained in:
@@ -78,27 +78,40 @@ export const actionScript = functions.https.onCall(
|
||||
action === "undo" ? config["undo.script"] : script
|
||||
}}`
|
||||
)({ row, db, auth, utilFns, ref, actionParams, context });
|
||||
if (result.success){
|
||||
const cellValue = {
|
||||
redo: config["redo.enabled"],
|
||||
status: result.status,
|
||||
completedAt: serverTimestamp(),
|
||||
ranBy: context.auth!.token.email,
|
||||
undo: config["undo.enabled"],
|
||||
}
|
||||
const userDoc = await db.collection("_FT_USERS").doc(context.auth!.uid).get()
|
||||
const user = userDoc?.get('user')
|
||||
await db.doc(ref.path).update({[column.key]:cellValue, _ft_updatedBy:user? {
|
||||
...user,
|
||||
...context.auth!,
|
||||
timestamp: new Date(),
|
||||
}:null })
|
||||
return {
|
||||
...result,
|
||||
cellValue,
|
||||
}
|
||||
}
|
||||
else return {
|
||||
if (result.success) {
|
||||
const cellValue = {
|
||||
redo: config["redo.enabled"],
|
||||
status: result.status,
|
||||
completedAt: serverTimestamp(),
|
||||
ranBy: context.auth!.token.email,
|
||||
undo: config["undo.enabled"],
|
||||
};
|
||||
try {
|
||||
const userDoc = await db
|
||||
.collection("_FT_USERS")
|
||||
.doc(context.auth!.uid)
|
||||
.get();
|
||||
const user = userDoc?.get("user");
|
||||
await db.doc(ref.path).update({
|
||||
[column.key]: cellValue,
|
||||
_ft_updatedBy: user
|
||||
? {
|
||||
...user,
|
||||
...context.auth!,
|
||||
timestamp: new Date(),
|
||||
}
|
||||
: null,
|
||||
});
|
||||
} catch (error) {
|
||||
// handle failed edit log update
|
||||
}
|
||||
|
||||
return {
|
||||
...result,
|
||||
cellValue,
|
||||
};
|
||||
} else
|
||||
return {
|
||||
success: false,
|
||||
message: result.message,
|
||||
};
|
||||
|
||||
@@ -65,10 +65,6 @@ export default function ActionFab({
|
||||
const callableName: string =
|
||||
(column as any).callableName ?? config.callableName ?? "actionScript";
|
||||
const handleRun = (actionParams = null) => {
|
||||
if (!ref.path || !ref.id) {
|
||||
snack.open({ message: "no ref set", variant: "error" });
|
||||
return;
|
||||
}
|
||||
setIsRunning(true);
|
||||
const data = {
|
||||
ref: { path: ref.path, id: ref.id, tablePath: window.location.pathname },
|
||||
|
||||
Reference in New Issue
Block a user