fix: sections change instead of deleteing

typescript_changes
flop 3 weeks ago
parent a20213b6e8
commit 7316a9d3a8
  1. 7
      ts/src/browser.ts

@ -218,14 +218,17 @@ function setSectionField(si: number, key: string, val: any) {
function setSectionType(si: number, sectionType: string) {
const sec = getSectionByIndex(si);
if (!sec) return;
const wasElementsSection = sec.sectionType !== MonoDisplay.SectionType.CustomFont;
(sec as any).sectionType = MonoDisplay.StringToSectionType[sectionType as MonoDisplay.SectionTypeName];
if ((sec as any).sectionType === MonoDisplay.SectionType.CustomFont) {
(sec as any).fontData = new Uint8Array();
delete (sec as any).elements;
delete (sec as any).flags;
} else {
(sec as any).elements = [];
(sec as any).flags = {};
if (!wasElementsSection) {
(sec as any).elements = [];
(sec as any).flags = {};
}
delete (sec as any).fontData;
if ((sec as any).sectionType === MonoDisplay.SectionType.ElementsTimespan) {
const now = BigInt(Math.floor(Date.now() / 1000));

Loading…
Cancel
Save