Skip to content

Commit

Permalink
fix: make the props posPrintWidth optional
Browse files Browse the repository at this point in the history
  • Loading branch information
AbleKSaju committed Jan 3, 2025
1 parent c318e81 commit fda3718
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main/getPrintTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'fs/promises';
import path from 'path';
import { TemplateFile } from 'utils/types';

export async function getTemplates(posTemplateWidth: number) {
export async function getTemplates(posTemplateWidth?: number) {
const paths = await getPrintTemplatePaths();
if (!paths) {
return [];
Expand All @@ -14,7 +14,7 @@ export async function getTemplates(posTemplateWidth: number) {
const template = await fs.readFile(filePath, 'utf-8');
const { mtime } = await fs.stat(filePath);
const width =
file?.split('-')[1]?.split('.')[0] === 'POS' ? posTemplateWidth : 0;
file?.split('-')[1]?.split('.')[0] === 'POS' ? posTemplateWidth ?? 0 : 0;
const height = file?.split('-')[1]?.split('.')[0] === 'POS' ? 22 : 0;

templates.push({
Expand Down
2 changes: 1 addition & 1 deletion main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ipc = {
};
},

async getTemplates(posTemplateWidth: number): Promise<TemplateFile[]> {
async getTemplates(posTemplateWidth?: number): Promise<TemplateFile[]> {
return (await ipcRenderer.invoke(
IPC_ACTIONS.GET_TEMPLATES,
posTemplateWidth
Expand Down
2 changes: 1 addition & 1 deletion main/registerIpcMainActionListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function registerIpcMainActionListeners(main: Main) {

ipcMain.handle(
IPC_ACTIONS.GET_TEMPLATES,
async (_, posPrintWidth: number) => {
async (_, posPrintWidth?: number) => {
return getTemplates(posPrintWidth);
}
);
Expand Down

0 comments on commit fda3718

Please sign in to comment.