Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Nov 6, 2024
1 parent f9d55f9 commit aaea47f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/components/HistoryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class="q-mr-xs"
size="xs"
/>
{{ formatCurrency(token.amount, token.unit) }}
<span> {{ formatCurrency(token.amount, token.unit) }} </span>
</q-item-label>
</q-item-section>

Expand All @@ -42,7 +42,9 @@
}} -->
Ecash
</q-item-label>
<q-item-label caption>{{ formattedDate(token.date) }}</q-item-label>
<q-item-label caption
>{{ formattedDate(token.date) }} ago</q-item-label
>
</q-item-section>

<q-item-section side top>
Expand Down
6 changes: 3 additions & 3 deletions src/components/InvoicesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
Lightning
<q-tooltip>Click to copy</q-tooltip>
</q-item-label>
<q-item-label caption>{{
formattedDate(invoice.date)
}}</q-item-label>
<q-item-label caption
>{{ formattedDate(invoice.date) }} ago</q-item-label
>
</q-item-section>
<q-item-section side top>
<q-btn
Expand Down
5 changes: 3 additions & 2 deletions src/components/QrcodeReader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ export default {
<q-btn
unelevated
v-if="canPasteFromClipboard"
icon="content_paste"
@click="pasteToParseDialog"
><q-tooltip>Paste</q-tooltip></q-btn
>
<q-icon name="content_paste" class="q-mr-sm" />
Paste</q-btn
>
<q-btn @click="closeCamera" flat color="grey" class="q-ml-auto"
>Close</q-btn
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReceiveTokenDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
@click="receiveIfDecodes"
color="primary"
rounded
class="q-mr-sm"
class="q-ml-xs q-mr-sm"
v-if="tokenDecodesCorrectly"
:disabled="addMintBlocking"
:label="
Expand Down
14 changes: 8 additions & 6 deletions src/stores/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export const useWalletStore = defineStore("wallet", {
// activate the mint and the unit
await mintStore.activateMintUrl(token.getMint(tokenJson), false, false, tokenJson.unit);

const amount = proofs.reduce((s, t) => (s += t.amount), 0);
const inputAmount = proofs.reduce((s, t) => (s += t.amount), 0);
await uIStore.lockMutex();
try {
// redeem
Expand All @@ -375,27 +375,29 @@ export const useWalletStore = defineStore("wallet", {
mintStore.removeProofs(proofs);
mintStore.addProofs(proofs);

const receivedAdmount = proofs.reduce((s, t) => (s += t.amount), 0);
const outputAmount = proofs.reduce((s, t) => (s += t.amount), 0);

// if token is already in history, set to paid, else add to history
if (tokenStore.historyTokens.find((t) => t.token === receiveStore.receiveData.tokensBase64 && t.amount == receivedAdmount)) {
if (tokenStore.historyTokens.find((t) => t.token === receiveStore.receiveData.tokensBase64 && t.amount > 0)) {
tokenStore.setTokenPaid(receiveStore.receiveData.tokensBase64);
} else {
// if this is a self-sent token, we will find an outgoing token with the inverse amount
if (tokenStore.historyTokens.find((t) => t.token === receiveStore.receiveData.tokensBase64 && t.amount == -receivedAdmount)) {
if (tokenStore.historyTokens.find((t) => t.token === receiveStore.receiveData.tokensBase64 && t.amount < 0)) {
tokenStore.setTokenPaid(receiveStore.receiveData.tokensBase64);
}
const fee = inputAmount - outputAmount;
tokenStore.addPaidToken({
amount: receivedAdmount,
amount: outputAmount,
serializedProofs: receiveStore.receiveData.tokensBase64,
unit: mintStore.activeUnit,
mint: mintStore.activeMintUrl,
fee: fee
});
}


if (!!window.navigator.vibrate) navigator.vibrate(200);
notifySuccess("Received " + uIStore.formatCurrency(receivedAdmount, mintStore.activeUnit));
notifySuccess("Received " + uIStore.formatCurrency(outputAmount, mintStore.activeUnit));
} catch (error: any) {
console.error(error);
notifyApiError(error);
Expand Down

0 comments on commit aaea47f

Please sign in to comment.