auto timestamp lyricks when song selected
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const { onDocumentWritten } = require("firebase-functions/firestore");
|
||||
const { getSunoTimestamps } = require("./lyrics");
|
||||
|
||||
exports.onProjectUpdate = onDocumentWritten(
|
||||
"projects/{projectId}",
|
||||
async (projectSnap) => {
|
||||
try {
|
||||
const { projectId } = projectSnap.params;
|
||||
|
||||
const currentData = projectSnap?.data?.after?.data() || null;
|
||||
const previousData = projectSnap?.data?.before?.data() || null;
|
||||
|
||||
if (!previousData?.songUrl && currentData?.songUrl) {
|
||||
await getSunoTimestamps(projectId);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user