Skip to content

Commit

Permalink
only update exhibition values when changed (fixes focus issues)
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95 committed Nov 26, 2023
1 parent 4fab159 commit e628203
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,14 @@ export const ExhibitionStateChanger = ({
};

const setSectionText = (sectionId: string, text: string) => {
databaseSaver.setSectionText(sectionId, text);
setSections(
sections.map(section => (section.id === sectionId ? { ...section, text: text } : section))
);
setSections(sections => {
// if unchanged, just return the identical value
if (sections.some(section => section.id === sectionId && section.text === text))
return sections;

databaseSaver.setSectionText(sectionId, text);
return sections.map(section => (section.id === sectionId ? { ...section, text } : section));
});
};

const setSectionTitle = (sectionId: string, title: string) => {
Expand All @@ -378,8 +382,12 @@ export const ExhibitionStateChanger = ({
};

const setIntroduction = (introduction: string) => {
databaseSaver.setIntroduction(exhibitionId, introduction);
setExhibitionText({ ...exhibitionText, introduction: introduction });
setExhibitionText(e => {
if (e.introduction !== introduction) {
databaseSaver.setIntroduction(exhibitionId, introduction);
return { ...exhibitionText, introduction };
} else return e;
});
};

const toggleIsPublished = () => {
Expand Down
6 changes: 6 additions & 0 deletions projects/bp-gallery/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export default defineConfig({
envDir: 'environments',
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://127.0.0.1:9000',
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
optimizeDeps: {
esbuildOptions: { plugins: [splitPackagesPlugin] },
Expand Down

0 comments on commit e628203

Please sign in to comment.