Skip to content

Commit

Permalink
Merge pull request #140 from DFXswiss/develop
Browse files Browse the repository at this point in the history
Minor fixes + translations
  • Loading branch information
davidleomay authored Nov 15, 2024
2 parents 710bd8f + 3216a88 commit 4f4ee91
Show file tree
Hide file tree
Showing 21 changed files with 861 additions and 465 deletions.
2 changes: 1 addition & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ const App = () => {
},
buttonIndex => {
if (buttonIndex === 1) {
handleOpenURL({ url: clipboard });
setTimeout(() => handleOpenURL({ url: clipboard }), 100);
}
},
);
Expand Down
4 changes: 1 addition & 3 deletions BlueApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ class AppStorage {
*/
async saveToDisk() {
if (savingInProgress) {
console.warn('saveToDisk is in progress');
if (++savingInProgress > 10) alert('Critical error. Last actions were not saved'); // should never happen
await new Promise(resolve => setTimeout(resolve, 1000 * savingInProgress)); // sleep
return this.saveToDisk();
Expand All @@ -596,7 +595,7 @@ class AppStorage {
try {
realm = await this.getRealm();
} catch (error) {
alert(error.message);
console.error(`saveToDisk: getRealm: ${error.message}`);
}
for (const key of this.wallets) {
if (typeof key === 'boolean') continue;
Expand Down Expand Up @@ -670,7 +669,6 @@ class AppStorage {
realmkeyValue.close();
} catch (error) {
console.error('save to disk exception:', error.message);
alert('save to disk exception: ' + error.message);
if (error.message.includes('Realm file decryption failed')) {
console.warn('purging realm key-value database file');
this.purgeRealmKeyValueFile();
Expand Down
37 changes: 31 additions & 6 deletions BlueComponents.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint react/prop-types: "off", react-native/no-inline-styles: "off" */
import React, { Component, forwardRef } from 'react';
import React, { Component, forwardRef, useState } from 'react';
import PropTypes from 'prop-types';
import { Icon, Text, Header, ListItem, Avatar } from 'react-native-elements';
import {
Expand Down Expand Up @@ -949,7 +949,7 @@ export const BlueTabs = ({ active, onSwitch, tabs }) => (

const useSelectorStyles = () => {
const { colors } = useTheme();

const pickerStyles = StyleSheet.create({
// eslint-disable-next-line react-native/no-unused-styles
inputIOS: {
Expand Down Expand Up @@ -981,11 +981,35 @@ const useSelectorStyles = () => {
justifyContent: 'center',
},
});

return pickerStyles
}

export const BlueWalletSelect = ({ wallets, value, onChange }) => {
return pickerStyles;
};

export const BlueWalletSelect = ({ wallets, value, onChange, on }) => {
return Platform.OS === 'ios' ? (
<BlueWalletSelectIOS wallets={wallets} value={value} onChange={onChange} />
) : (
<BlueWalletSelectBase wallets={wallets} value={value} onChange={onChange} />
);
};

export const BlueWalletSelectIOS = ({ wallets, value, onChange }) => {
const [internalValue, setInternalValue] = useState(value);

const handleDone = () => onChange(internalValue);

return (
<BlueWalletSelectBase
wallets={wallets}
value={internalValue}
onChange={setInternalValue}
onDonePress={handleDone}
onClose={handleDone}
/>
);
};

export const BlueWalletSelectBase = ({ wallets, value, onChange, ...props }) => {
const { colors } = useTheme();
const pickerStyles = useSelectorStyles();

Expand All @@ -999,6 +1023,7 @@ export const BlueWalletSelect = ({ wallets, value, onChange }) => {
useNativeAndroidPickerStyle={false}
fixAndroidTouchableBug
Icon={() => <Icon size={18} name="sync-alt" type="material-icons" color={colors.foregroundColor} />}
{...props}
/>
);
};
Expand Down
6 changes: 1 addition & 5 deletions api/dfx/contexts/session.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export function DfxSessionContextProvider(props: PropsWithChildren<any>): JSX.El
const [isAvailable, setIsAvailable] = useState(false);
const [isInitialized, setIsInitialized] = useState(false);

useEffect(() => {
dfxSession.get().then(setSessions);
}, [dfxSession]);

function isExpired(token?: string): boolean {
if (!token) return true;

Expand Down Expand Up @@ -111,7 +107,7 @@ export function DfxSessionContextProvider(props: PropsWithChildren<any>): JSX.El
async function createAccessToken(walletId: string): Promise<string> {
if (walletId === mainWalletId) {
if (!mainAddress) throw new Error('Address is not defined');
const signature = await getOwnershipProof();
const signature = await getOwnershipProof();
return await createSession(mainAddress, signature);
} else {
const wallet = wallets.find((w: any) => w.getID?.() === walletId);
Expand Down
Loading

0 comments on commit 4f4ee91

Please sign in to comment.