Skip to content

Commit

Permalink
Merge pull request #20 from Beldex-Coin/bns_name_integrated_in_new_co…
Browse files Browse the repository at this point in the history
…ntact
  • Loading branch information
codeman-crypto authored Mar 21, 2024
2 parents 1af7f03 + 2537796 commit 1ebec39
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 37 deletions.
13 changes: 1 addition & 12 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,7 @@ if (window.networkType == 'mainnet') {
];

const remotes = [
{
host: 'mainnet.beldex.io',
port: '29095',
active: 0,
type: 'Remote',
},

{
host: 'publicnode1.rpcnode.stream',
port: '29095',
Expand Down Expand Up @@ -292,12 +287,6 @@ if (window.networkType == 'mainnet') {
active: 0,
type: 'Remote',
},
{
host: 'explorer.beldex.io',
port: '19091',
active: 0,
type: 'Remote',
},
];
window.currentDaemon = remotes[Math.floor(Math.random() * remotes.length)];
window.deamon_list = remotes;
Expand Down
7 changes: 7 additions & 0 deletions stylesheets/_bchat_left_pane.scss
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ $bchat-compose-margin: 20px;
overflow-y: auto;
overflow-x: hidden;

&-loadingWrapper {
position: absolute;
width: 100%;
height: 91%;
background-color:rgba(0, 0, 0, 0.6);
display: flex;
}
&-closed {
&--header {
font-family: $bchat-font-poppins-bold;
Expand Down
13 changes: 7 additions & 6 deletions ts/components/leftpane/overlay/OverlayMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export const OverlayMessage = () => {
resolvedBchatID,
ConversationTypeEnum.PRIVATE
);

await openConversationWithMessages({ conversationKey: resolvedBchatID, messageId: null });
await openConversationWithMessages({ conversationKey: resolvedBchatID, messageId: null, bns:pubkeyorOnsTrimmed });

closeOverlay();
} catch (e) {
Expand All @@ -94,10 +93,12 @@ export const OverlayMessage = () => {
dataTestId="new-bchat-conversation"
// onPressEnter={handleMessageButtonClick}
/>

<BchatSpinner loading={loading} />


{loading && (
<div className="module-left-pane-overlay-loadingWrapper">
<BchatSpinner loading={true} />
</div>
)}

<p className="module-left-pane__subHeader" style={{marginBottom:"10px"}}>Your BChat ID</p>
<div className="bchat-description-long">Share your BChat ID with your friends. You can find your BChat ID below</div>
<BchatIdEditable
Expand Down
23 changes: 17 additions & 6 deletions ts/components/wallet/BchatWalletTransactionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const TransactionSection = (props: any) => {
break;
case 'bns':
(item.iconType = 'bnsTransaction'),
(item.iconColor = "var(--color-bns-transaction)"),
(item.iconColor = 'var(--color-bns-transaction)'),
(item.type = window.i18n('bns'));
break;
case 'failed':
Expand Down Expand Up @@ -136,10 +136,10 @@ export const TransactionSection = (props: any) => {
let data =
filteredTransaction.length > 0
? filteredTransaction.filter(
(item: any) =>
String(item.amount / 1e9).includes(searchText.toLowerCase()) ||
item.txid.toLowerCase().includes(searchText.toLowerCase())
)
(item: any) =>
String(item.amount / 1e9).includes(searchText.toLowerCase()) ||
item.txid.toLowerCase().includes(searchText.toLowerCase())
)
: [];
setData(data);
}
Expand Down Expand Up @@ -375,7 +375,7 @@ export const TransactionSection = (props: any) => {
></article>
{recip.address && (
<div
style={{ marginLeft: '20px', width: zoomLevel > 100 ? '44%' : '57%' }}
style={{ marginLeft: '20px', width: zoomLevel > 100 ? '44%' : '49%' }}
className="wallet-Transaction-recipitentBox-adddressBox"
>
<div className="">{window.i18n('recipientAddress')}</div>
Expand All @@ -393,6 +393,17 @@ export const TransactionSection = (props: any) => {
{item.fee / 1e9} BDX
</article>
</section>

{item.payment_id != '0000000000000000' && (
<section style={{ marginLeft: '20px' }}>
<article className="wallet-Transaction-recipitentBox-transactionFee-header">
{window.i18n('paymentID')}
</article>
<article className="wallet-Transaction-recipitentBox-transactionFee-text">
{item.payment_id}
</article>
</section>
)}
</Flex>

<section
Expand Down
25 changes: 23 additions & 2 deletions ts/state/ducks/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,16 @@ export const {
export async function openConversationWithMessages(args: {
conversationKey: string;
messageId: string | null;
bns?: string | undefined | null;
}) {
const { conversationKey, messageId } = args;
//
const { conversationKey, messageId, bns } = args;
const firstUnreadIdOnOpen = await getFirstUnreadMessageIdInConversation(conversationKey);
const mostRecentMessageIdOnOpen = await getLastMessageIdInConversation(conversationKey);

if(bns)
{
savebnsname(conversationKey,bns)
}
const initialMessages = await getMessages({
conversationKey,
messageId: messageId || null,
Expand All @@ -1012,6 +1017,22 @@ export async function openConversationWithMessages(args: {
);
}

/**
* Saves the currently entered nickname.
*/
const savebnsname = async ( conversationKey: string,displayName: any) => {
if (!conversationKey) {
throw new Error('Cant save without conversation id');
}
const conversation = await getConversationController().get(conversationKey);
if(conversation.getBchatProfile()?.displayName)
{
return ;
}
await conversation.setBchatProfile({ displayName });

};

export async function openConversationToSpecificMessage(args: {
conversationKey: string;
messageIdToNavigateTo: string;
Expand Down
1 change: 1 addition & 0 deletions ts/types/LocalizerKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type LocalizerKeys =
| 'blocksRemaining'
| 'recipientAddress'
| 'transactionFee'
| 'paymentID'
| 'dateTime'
| 'remoteDaemonOnly'
| 'localDaemonOnly'
Expand Down
11 changes: 0 additions & 11 deletions ts/util/accountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,22 @@ async function registrationDone(ourPubkey: string, displayName: string, deamonHe
window?.log?.info('registration done');

await Storage.put('primaryDevicePubKey', ourPubkey);
window?.log?.info('registration done 0 ::', ourPubkey);
// let userDetails= await getConversationById(ourPubkey)
// Ensure that we always have a conversation for ourself
const conversation = await getConversationController().getOrCreateAndWait(
ourPubkey,
ConversationTypeEnum.PRIVATE
);
window?.log?.info('registration done 1 ::', conversation);

window?.log?.info('registration done 2 ::', displayName);

await conversation.setBchatProfile({ displayName });
window?.log?.info('registration done 3 ::', ourPubkey);

await conversation.setIsApproved(true);
window?.log?.info('registration done 4 ::', ourPubkey);
await conversation.setDidApproveMe(true);
window?.log?.info('registration done 5 ::', ourPubkey);
await conversation.setwalletCreatedDaemonHeight(deamonHeight);

await conversation.commit();
const user = {
ourNumber: getOurPubKeyStrFromCache(),
ourPrimary: ourPubkey,
};
window?.log?.info('registration done 5 ::', user);

window.inboxStore?.dispatch(userActions.userChanged(user));
await Registration.markDone();
window?.log?.info('dispatching registration event');
Expand Down

0 comments on commit 1ebec39

Please sign in to comment.