Skip to content

Commit

Permalink
Finally fix issues with indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
electrikmilk committed Nov 25, 2023
1 parent 68c8915 commit 8a82cfc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import {parse} from 'plist/dist/plist-parse.js';
let preview: HTMLDivElement | null;
export let container: HTMLElement;

let containers: HTMLElement[] = [];
let containerIndex: number = 0;
export let containers: HTMLElement[] = [];
export let containerIndex: number = 0;

export function resetContainers() {
containers = [];
containers.push(container);
}

export function newContainer() {
const renderContainer = document.createElement('div');
Expand Down
37 changes: 17 additions & 20 deletions src/render.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import {ActionData, container, newContainer, prevContainer, ShortcutData} from "~/main";
import {
ActionData,
container,
containerIndex,
newContainer,
prevContainer,
resetContainers,
ShortcutData
} from "~/main";
import {ActionDefinition, actions, actionText} from "~/actions";
import {renderValue} from "~/value";

Expand All @@ -10,39 +18,28 @@ export const controlFlowStart = 0;
export const controlFlowItem = 1;
export const controlFlowEnd = 2;

let insideGroup = false;

export function renderShortcut(shortcutActions: Array<ActionData>) {
console.group('Render Shortcut');
for (const action of shortcutActions) {
let identifier = action.WFWorkflowActionIdentifier.replace('is.workflow.actions.', '');
let params = action.WFWorkflowActionParameters;

// @ts-ignore
if (params['WFControlFlowMode'] === controlFlowEnd || params['WFControlFlowMode'] === controlFlowItem) {
// @ts-ignore
if (params['WFControlFlowMode'] === controlFlowEnd) {
insideGroup = false;
}
if (!insideGroup) {
prevContainer();
}
const controlFlowMode = params['WFControlFlowMode'];
if (controlFlowMode === controlFlowEnd || controlFlowMode == controlFlowItem) {
prevContainer();
}
if (containerIndex === 0) {
resetContainers();
}

container.appendChild(
renderAction(identifier, action)
);

// @ts-ignore
if (params['WFControlFlowMode'] === controlFlowStart || params['WFControlFlowMode'] === controlFlowItem) {
// @ts-ignore
if (params['WFControlFlowMode'] === controlFlowStart && identifier === 'choosefrommenu') {
if (controlFlowMode === controlFlowStart || controlFlowMode === controlFlowItem) {
if (controlFlowMode === controlFlowStart && identifier === 'choosefrommenu') {
continue;
}
// @ts-ignore
if (params['WFControlFlowMode'] === controlFlowStart) {
insideGroup = true;
}
newContainer();
}
}
Expand Down

0 comments on commit 8a82cfc

Please sign in to comment.