Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.0.2 bug fixes #27

Merged
merged 5 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions stores/InvoicesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class InvoicesStore {
@observable payment_request: string | null;
@observable creatingInvoice: boolean = false;
@observable creatingInvoiceError: boolean = false;
@observable invoicesCount: number;
settingsStore: SettingsStore

constructor(settingsStore: SettingsStore) {
Expand All @@ -30,14 +31,15 @@ export default class InvoicesStore {
this.loading = true;
axios.request({
method: 'get',
url: `https://${host}${port ? ':' + port : ''}/v1/invoices`,
url: `https://${host}${port ? ':' + port : ''}/v1/invoices?reversed=true&num_max_invoices=100`,
headers: {
'Grpc-Metadata-macaroon': macaroonHex
}
}).then((response: any) => {
// handle success
const data = response.data;
this.invoices = data.invoices.reverse();
this.invoicesCount = data.last_index_offset;
this.loading = false;
})
.catch(() => {
Expand All @@ -62,11 +64,6 @@ export default class InvoicesStore {
// handle success
const data = response.data;
this.invoice = data;
})
.catch((error: any) => {
// handle error
console.log('errrrrr -getInvoice');
console.log(error);
});
}

Expand Down
22 changes: 0 additions & 22 deletions stores/TransactionsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,6 @@ export default class TransactionsStore {
);
}

getNewAddress = () => {
const { settings } = this.settingsStore;
const { host, port, macaroonHex } = settings;

axios.request({
method: 'get',
url: `https://${host}${port ? ':' + port : ''}/v1/newaddress`,
headers: {
'Grpc-Metadata-macaroon': macaroonHex
}
}).then((response: any) => {
// handle success
const data = response.data;
this.onchain_address = data.address;
})
.catch((error: Error) => {
// handle error
console.log('errrrrr -getNewAddress');
console.log(error);
});
}

@action
public getTransactions = () => {
const { settings } = this.settingsStore;
Expand Down
2 changes: 1 addition & 1 deletion stores/UnitsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class UnitsStore {
public getAmount = (value: string | number) => {
if (this.units === 'btc') {
// handle negative values
const valueToProcess = value.toString();
const valueToProcess = value && value.toString() || "0";
if (valueToProcess.includes('-')) {
let processedValue = valueToProcess.split('-')[1];
return `- ₿ ${Number(processedValue) / satoshisPerBTC}`;
Expand Down
2 changes: 2 additions & 0 deletions views/Receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default class Receive extends React.Component<ReceiveProps, ReceiveState>
</View>}
<Text>Memo</Text>
<TextInput
placeholder="Sent a few satoshis"
value={memo}
onChangeText={(text: string) => this.setState({ memo: text })}
numberOfLines={1}
Expand All @@ -136,6 +137,7 @@ export default class Receive extends React.Component<ReceiveProps, ReceiveState>

<Text>Amount (in Satoshis)</Text>
<TextInput
placeholder={"100"}
value={value}
onChangeText={(text: string) => this.setState({ value: text })}
numberOfLines={1}
Expand Down
2 changes: 1 addition & 1 deletion views/Wallet/Invoices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class InvoicesView extends React.Component<InvoicesProps, {}> {
return (
<ListItem
key={item.r_hash}
title={item.memo}
title={item.memo || "No memo"}
subtitle={`${settled ? 'Paid' : 'Unpaid'}: ${units && getAmount(item.value)} | ${settled ? settleDate : creationDate}`}
containerStyle={{ borderBottomWidth: 0 }}
avatar={item.settled ? AddBalance : AddBalancePending}
Expand Down
3 changes: 1 addition & 2 deletions views/Wallet/Transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default class Transactions extends React.Component<TransactionsProps> {
const subtitle = item.block_height ? `${item.block_height} | ${date}` : date.toString();
return (
<ListItem
key={item.tx_hash}
title={units && getAmount(item.amount)}
subtitle={subtitle}
containerStyle={{ borderBottomWidth: 0 }}
Expand All @@ -71,7 +70,7 @@ export default class Transactions extends React.Component<TransactionsProps> {
/>
);
}}
keyExtractor={item => item.tx_hash}
keyExtractor={(item, index) => `${item.tx_hash}-${index}`}
ItemSeparatorComponent={this.renderSeparator}
onEndReachedThreshold={50}
refreshing={loading}
Expand Down
4 changes: 2 additions & 2 deletions views/Wallet/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class Wallet extends React.Component<WalletProps, WalletState> {

const { transactions } = TransactionsStore;
const { payments } = PaymentsStore;
const { invoices } = InvoicesStore;
const { invoices, invoicesCount } = InvoicesStore;
const { channels } = ChannelsStore;

const transactionsButton = () => (
Expand All @@ -131,7 +131,7 @@ export default class Wallet extends React.Component<WalletProps, WalletState> {

const invoicesButton = () => (
<React.Fragment>
<Text>{invoices && invoices.length || 0}</Text>
<Text>{invoicesCount || 0}</Text>
<Text>Invoices</Text>
</React.Fragment>
);
Expand Down