Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(firestore-sheets-sync): initial commit #52

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: don't insert new row if a header exists
  • Loading branch information
pr-Mais committed Feb 27, 2023
commit 2203e5f8cb552065b1fef6db70e0e2246296e5e0
7 changes: 4 additions & 3 deletions extensions/firestore-sheets-sync/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import config from './config';

const sheets = google.sheets('v4');
const authClient = google.auth.getClient({
keyFilename: 'extensions-testing-cae073db7903.json',
scopes: ['https://www.googleapis.com/auth/spreadsheets'],
});

@@ -71,7 +72,7 @@ async function createHeaderRow() {

// Check if the header row is already set up.
if (
headerRow.data.values &&
headerRow.data.values?.length > 0 &&
arrayEqual(headerRow.data.values[0].sort(), [...fields].sort())
)
return;
@@ -81,7 +82,7 @@ async function createHeaderRow() {
spreadsheetId: config.spreadsheetId,
requestBody: {
requests: [
{
headerRow.data.values?.length > 0 && {
insertDimension: {
range: {
dimension: 'ROWS',
@@ -113,7 +114,7 @@ async function createHeaderRow() {
},
},
},
],
].filter(Boolean),
},
});
}