Skip to content

Commit

Permalink
fix(ssr): use ssrKey in firestore
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 22, 2022
1 parent c4c815c commit 25d86ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/firestore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ export function _useFirestoreRef(
// only add the first promise to the pending ones
// TODO: can we make this tree shakeable?
if (initialSourceValue) {
removePendingPromise = addPendingPromise(promise.value, initialSourceValue)
removePendingPromise = addPendingPromise(
promise.value,
initialSourceValue,
options.ssrKey
)
}

// TODO: SSR serialize the values for Nuxt to expose them later and use them
Expand Down
2 changes: 1 addition & 1 deletion src/ssr/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function addPendingPromise(
} else {
// TODO: warn if in SSR context in other contexts than vite
if (process.env.NODE_ENV !== 'production' /* && import.meta.env?.SSR */) {
console.warn('[VueFire]: Could not get the path of the data source')
console.warn('[VueFire SSR]: Could not get the path of the data source')
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/firestore/collection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,12 @@ describe(
}

it('can be bound to a ref of a query', async () => {
const { showFinished, listToDisplay } = await createFilteredLists()
const { showFinished, listToDisplay, listRef } =
await createFilteredLists()

const { wrapper, data, promise } = factoryQuery({
ref: listToDisplay,
options: { ssrKey: 'list' },
})

await promise.value
Expand Down

0 comments on commit 25d86ca

Please sign in to comment.