0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-09 22:22:41 +00:00

Change the ID used for User Brews to the shareId for future-proofing.

This commit is contained in:
David Bolack
2024-05-17 20:53:06 -05:00
parent 69f01b282a
commit c6f62142e1

View File

@@ -72,7 +72,7 @@ const api = {
const fields = [ const fields = [
'title', 'title',
'tags', 'tags',
'editId', 'shareId',
'thumbnail', 'thumbnail',
'textBin', 'textBin',
'text', 'text',
@@ -85,17 +85,17 @@ const api = {
} }
}; };
const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['meta:theme', 'meta:Theme'] }, editId: { $ne: id }, renderer: { $ne: 'Legacy' } }); const brews = await HomebrewModel.getByUser(username, true, fields, { tags: { $in: ['meta:theme', 'meta:Theme'] }, shareId: { $ne: id }, renderer: { $ne: 'Legacy' } });
if(brews) { if(brews) {
for await (const brew of brews) { for await (const brew of brews) {
userThemes.Brew[`#${brew.editId}`] = { userThemes.Brew[`#${brew.shareId}`] = {
name : brew.title, name : brew.title,
renderer : 'V3', renderer : 'V3',
baseTheme : '', baseTheme : '',
baseSnippets : false, baseSnippets : false,
author : brew.authors[0], author : brew.authors[0],
path : `#${brew.editId}`, path : `#${brew.shareId}`,
thumbnail : brew.thumbnail.length > 0 ? brew.thumbnail : '/assets/naturalCritLogoWhite.svg' thumbnail : brew.thumbnail.length > 0 ? brew.thumbnail : '/assets/naturalCritLogoWhite.svg'
}; };
} }
@@ -111,7 +111,7 @@ const api = {
const { id, googleId } = api.getId(req); const { id, googleId } = api.getId(req);
// Try to find the document in the Homebrewery database -- if it doesn't exist, that's fine. // Try to find the document in the Homebrewery database -- if it doesn't exist, that's fine.
let stub = await HomebrewModel.get((accessType === 'edit') || (accessType === 'theme') ? { editId: id } : { shareId: id }) let stub = await HomebrewModel.get((accessType === 'edit') ? { editId: id } : { shareId: id })
.catch((err)=>{ .catch((err)=>{
if(googleId) { if(googleId) {
console.warn(`Unable to find document stub for ${accessType}Id ${id}`); console.warn(`Unable to find document stub for ${accessType}Id ${id}`);