Preserve QPowerPoint slide backgrounds
This commit is contained in:
+15
@@ -13,6 +13,7 @@ const STORAGE_KEY = "qoffice-state-v1";
|
||||
function migrateQOfficeState(state: QOfficeState): QOfficeState {
|
||||
const launchChecklistAttachments = initialState.mail.messages.find((message) => message.id === "mail-1")?.attachments;
|
||||
const sampleSheet = initialState.workbook.sheets.find((sheet) => sheet.id === "sheet-1");
|
||||
const sampleSlidesById = Object.fromEntries(initialState.deck.slides.map((slide) => [slide.id, slide]));
|
||||
const sampleWordHtml = initialState.word.html;
|
||||
const needsSampleWordColor =
|
||||
state.word.id === initialState.word.id &&
|
||||
@@ -64,11 +65,25 @@ function migrateQOfficeState(state: QOfficeState): QOfficeState {
|
||||
})
|
||||
: state.workbook.sheets;
|
||||
|
||||
const slides =
|
||||
state.deck.id === initialState.deck.id
|
||||
? state.deck.slides.map((slide) => {
|
||||
const sampleSlide = sampleSlidesById[slide.id];
|
||||
if (!sampleSlide?.backgroundColor || slide.backgroundColor) {
|
||||
return slide;
|
||||
}
|
||||
|
||||
changed = true;
|
||||
return { ...slide, backgroundColor: sampleSlide.backgroundColor };
|
||||
})
|
||||
: state.deck.slides;
|
||||
|
||||
return changed
|
||||
? {
|
||||
...state,
|
||||
word: needsSampleWordColor ? { ...state.word, html: sampleWordHtml } : state.word,
|
||||
workbook: { ...state.workbook, sheets },
|
||||
deck: { ...state.deck, slides },
|
||||
mail: { ...state.mail, messages }
|
||||
}
|
||||
: state;
|
||||
|
||||
Reference in New Issue
Block a user