Skip to content

Commit

Permalink
Merge pull request #14 from mitsuharu/develop
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
mitsuharu authored Nov 5, 2022
2 parents 91070fe + 03c42da commit 22999b0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/redux/modules/printer/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function* printSaga({ payload }: ReturnType<typeof print>) {
}
}

const isEmpty = (obj: any) => !Object.keys(obj).length

async function printProfile({
name,
iconBase64,
Expand All @@ -54,7 +56,6 @@ async function printProfile({
qr,
title,
}: Profile) {
console.log('printProfile')
try {
await SPrinter.connect()
await SPrinter.printEmptyLines(1)
Expand All @@ -79,7 +80,7 @@ async function printProfile({
}

// 肩書き
if (title) {
if (title && !isEmpty(title)) {
const { position, company, address } = title
await SPrinter.printText(SEPARATOR)
if (company) {
Expand All @@ -94,7 +95,7 @@ async function printProfile({
}

// SNS情報
if (sns) {
if (sns && !isEmpty(sns)) {
await SPrinter.printText(SEPARATOR)
await SPrinter.setAlign(Constants.Align.LEFT)
const { twitter, facebook, github, website } = sns
Expand All @@ -113,15 +114,17 @@ async function printProfile({
}

// QRコード
if (qr) {
if (qr && !isEmpty(qr)) {
await SPrinter.setAlign(Constants.Align.CENTER)
await SPrinter.printText(SEPARATOR)
await SPrinter.setAlign(Constants.Align.CENTER)
if (qr.description) {
await SPrinter.printText(`${qr.description}\n`)
await SPrinter.printEmptyLines(1)
}
await SPrinter.printQRCode(qr.url, 8, 1)
if (qr.url) {
await SPrinter.printQRCode(qr.url, 8, 1)
}
await SPrinter.printEmptyLines(1)
}

Expand Down

0 comments on commit 22999b0

Please sign in to comment.