Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/madfish-solutions/te…
Browse files Browse the repository at this point in the history
…mplewallet-extension into TW-1180-replace-existing-ads-to-slise-xyz
  • Loading branch information
keshan3262 committed Dec 7, 2023
2 parents 96dfae2 + 40072b8 commit 3761aaa
Show file tree
Hide file tree
Showing 23 changed files with 495 additions and 87 deletions.
4 changes: 4 additions & 0 deletions public/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@
"message": "Tezos Mainnet",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold Mainnet",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple Wallet | Optionen"
},
Expand Down
31 changes: 22 additions & 9 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,20 @@
"tryAgain": {
"message": "Try again"
},
"errorGettingBakerAddressMessageOnline": {
"message": "Failed to get baker's address. Please, reload the page and try again."
},
"errorGettingBakerAddressMessage": {
"message": "Failed to get baker's address. Please, check your internet connection and try again."
},
"tezosMainnet": {
"message": "Tezos Mainnet",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold Mainnet",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple Wallet | Options"
},
Expand Down Expand Up @@ -1975,7 +1985,7 @@
"message": "Confirm the action"
},
"closePartnersPromotion": {
"message": "Are you sure you want to turn off all ads?"
"message": "Are you sure you want to disable all ads?"
},
"domainDoesntResolveToAddress": {
"message": "Domain \"$value$\" doesn't resolve to an address",
Expand Down Expand Up @@ -2421,7 +2431,7 @@
"message": "Are you sure you want to delete this contact?"
},
"closePartnersPromoConfirm": {
"message": "Pay attention: you can receive cashback in USDt tokens for enabling advertisement in our wallet. If you turned off ADS, you can always activate it in the settings."
"message": "Pay attention: you can receive rewards in TKEY tokens for viewing ads in our wallet. If you disabled Ads, you can always activate it in the settings."
},
"enablePartnersPromotionConfirm": {
"message": "Support the development team and earn tokens by viewing ads inside the wallet."
Expand Down Expand Up @@ -2614,14 +2624,17 @@
"partnersPromoSettings": {
"message": "Advertising"
},
"cashBack": {
"message": "cash back"
},
"partnersPromoDescriptionP1": {
"message": "Here you can configure displaying of ads in Temple wallet. Remember, you get"
"rewards": {
"message": "rewards",
"description": "Part of partnersPromoDescription phrase"
},
"partnersPromoDescriptionP2": {
"message": "at Temple Keys for viewing ads"
"partnersPromoDescription": {
"message": "Here you can configure displaying of ads in Temple wallet. Remember, you get $rewards$ at TKEY tokens for viewing ads.",
"placeholders": {
"rewards": {
"content": "$1"
}
}
},
"totalEquityValue": {
"message": "Total Equity Value"
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@
"message": "Tezos Mainnet",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold Mainnet",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple Wallet | Options"
},
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@
"message": "Mainnet Tezos",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Mainnet Marigold",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Portefeuille Temple | Options"
},
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/pt/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@
"message": "Tezos Mainnet",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold Mainnet",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Carteira Temple | Opções"
},
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/tr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@
"message": "Tezos Mainnet",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold Mainnet",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple Wallet | Seçenekler"
},
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@
"message": "Tezos Mainnet",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold Mainnet",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple Wallet | Налаштування"
},
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@
"message": "Tezos主网",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold主网",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple钱包 | 选项"
},
Expand Down
4 changes: 4 additions & 0 deletions public/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@
"message": "Tezos 主網路",
"description": "Mainnet = main network"
},
"marigoldMainnet": {
"message": "Marigold 主網路",
"description": "Mainnet = main network"
},
"templeWalletOptions": {
"message": "Temple 錢包 | 選項"
},
Expand Down
52 changes: 27 additions & 25 deletions src/app/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ import React, { Component, ErrorInfo } from 'react';
import classNames from 'clsx';

import { ReactComponent as DangerIcon } from 'app/icons/danger.svg';
import { T } from 'lib/i18n';
import { t, T } from 'lib/i18n';
import { getOnlineStatus } from 'lib/temple/front';

interface ErrorBoundaryProps extends React.PropsWithChildren {
className?: string;
whileMessage?: string;
}

export class BoundaryError extends Error {
constructor(public readonly message: string, public readonly beforeTryAgain: EmptyFn) {
super(message);
}
}

type ErrorBoundaryState = {
error: Error | null;
};
Expand All @@ -33,37 +40,36 @@ export default class ErrorBoundary extends Component<ErrorBoundaryProps> {
});
}

tryAgain() {
async tryAgain() {
const { error } = this.state;
if (error instanceof BoundaryError) {
error.beforeTryAgain();
}
this.setState({ error: null });
}

getDefaultErrorMessage() {
const { whileMessage } = this.props;
const online = getOnlineStatus();
const firstPart = whileMessage ? t('smthWentWrongWhile', [whileMessage]) : t('smthWentWrong');

return online ? firstPart : [firstPart, t('mayHappenBecauseYouAreOffline')].join('. ');
}

render() {
if (this.state.error) {
const online = getOnlineStatus();
const { className, children } = this.props;
const { error } = this.state;

if (error) {
return (
<div className={classNames('w-full', 'flex items-center justify-center', this.props.className)}>
<div className={classNames('w-full', 'flex items-center justify-center', className)}>
<div className={classNames('max-w-xs', 'p-4', 'flex flex-col items-center', 'text-red-600')}>
<DangerIcon className="h-16 w-auto stroke-current" />

<T id="oops">{message => <h2 className="mb-1 text-2xl">{message}</h2>}</T>

<p className="mb-4 text-sm opacity-90 text-center font-light">
{this.props.whileMessage ? (
<T id="smthWentWrongWhile" substitutions={this.props.whileMessage} />
) : (
<T id="smthWentWrong" />
)}
{!online && (
<T id="mayHappenBecauseYouAreOffline">
{message => (
<>
{'. '}
{message}
</>
)}
</T>
)}
{error instanceof BoundaryError ? error.message : this.getDefaultErrorMessage()}
</p>

<T id="tryAgain">
Expand Down Expand Up @@ -92,10 +98,6 @@ export default class ErrorBoundary extends Component<ErrorBoundaryProps> {
);
}

return this.props.children;
return children;
}
}

function getOnlineStatus() {
return typeof navigator !== 'undefined' && typeof navigator.onLine === 'boolean' ? navigator.onLine : true;
}
28 changes: 16 additions & 12 deletions src/app/pages/Home/ContentSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, ReactNode, Suspense, useCallback, useMemo, useRef } from 'react';
import React, { FC, memo, Suspense, useCallback, useMemo, useRef } from 'react';

import clsx from 'clsx';

Expand Down Expand Up @@ -33,7 +33,7 @@ interface TabData {
whileMessageI18nKey?: TID;
}

export const ContentSection: FC<Props> = ({ assetSlug, className }) => {
export const ContentSection = memo<Props>(({ assetSlug, className }) => {
const { fullPage } = useAppEnv();
const tabSlug = useTabSlug();

Expand Down Expand Up @@ -115,25 +115,29 @@ export const ContentSection: FC<Props> = ({ assetSlug, className }) => {
<div className={clsx('-mx-4 shadow-top-light', fullPage && 'rounded-t-md', className)}>
<TabsBar ref={tabBarElemRef} tabs={tabs} activeTabName={name} />

<SuspenseContainer whileMessage={whileMessageI18nKey ? t(whileMessageI18nKey) : 'displaying tab'}>
{Component && <Component />}
</SuspenseContainer>
<ContentContainer
key={tabSlug ?? 'tokens'}
ContentComponent={Component}
whileMessage={whileMessageI18nKey ? t(whileMessageI18nKey) : 'displaying tab'}
/>
</div>
);
};
});

interface SuspenseContainerProps extends PropsWithChildren {
interface ContentContainerProps {
whileMessage: string;
fallback?: ReactNode;
ContentComponent: React.FC | React.ExoticComponent;
}

const SuspenseContainer: FC<SuspenseContainerProps> = ({ whileMessage, fallback = <SpinnerSection />, children }) => (
const ContentContainer = memo<ContentContainerProps>(({ whileMessage, ContentComponent }) => (
<ErrorBoundary whileMessage={whileMessage}>
<Suspense fallback={fallback}>{children}</Suspense>
<Suspense fallback={<SpinnerSection />}>
<ContentComponent />
</Suspense>
</ErrorBoundary>
);
));

const SpinnerSection: FC = () => (
const SpinnerSection = () => (
<div className="flex justify-center my-12">
<Spinner theme="gray" className="w-20" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/Home/OtherComponents/BakingSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const links = [

const BakingSection = memo(() => {
const acc = useAccount();
const { data: myBakerPkh } = useDelegate(acc.publicKeyHash);
const { data: myBakerPkh } = useDelegate(acc.publicKeyHash, true, false);
const canDelegate = acc.type !== TempleAccountType.WatchOnly;
const chainId = useChainId(true);
const { isDcpNetwork } = useGasToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { useDispatch } from 'react-redux';
import { FormCheckbox } from 'app/atoms';
import { togglePartnersPromotionAction } from 'app/store/partners-promotion/actions';
import { useShouldShowPartnersPromoSelector } from 'app/store/partners-promotion/selectors';
import { setAdsBannerVisibilityAction } from 'app/store/settings/actions';
import { useIsEnabledAdsBannerSelector } from 'app/store/settings/selectors';
import { T, t } from 'lib/i18n';
import { useConfirm } from 'lib/ui/dialog';

import { setAdsBannerVisibilityAction } from '../../../store/settings/actions';
import { useIsEnabledAdsBannerSelector } from '../../../store/settings/selectors';
import { SettingsGeneralSelectors } from '../selectors';

export const PartnersPromotionSettings: FC = () => {
Expand Down Expand Up @@ -63,15 +63,14 @@ export const PartnersPromotionSettings: FC = () => {
</span>

<span className="mt-1 text-xs font-light text-gray-600" style={{ maxWidth: '90%' }}>
<span>
<T id="partnersPromoDescriptionP1" />
</span>
<span className="mx-1 font-semibold">
<T id="cashBack" />
</span>
<span>
<T id="partnersPromoDescriptionP2" />
</span>
<T
id="partnersPromoDescription"
substitutions={[
<span className="font-semibold">
<T id="rewards" />
</span>
]}
/>
</span>
</label>

Expand Down
17 changes: 16 additions & 1 deletion src/app/templates/activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ export const ActivityComponent: React.FC<Props> = ({ assetSlug }) => {

if (activities.length === 0 && !loading && reachedTheEnd) {
return (
<div className={classNames('mt-4 mb-12', 'flex flex-col items-center justify-center', 'text-gray-500')}>
<div
className={classNames(
'mt-3 mb-12 w-full max-w-sm mx-auto',
'flex flex-col items-center justify-center',
'text-gray-500'
)}
>
<div className="w-full flex justify-center mb-6">
<PartnersPromotion variant={PartnersPromotionVariant.Image} />
</div>

<LayersIcon className="w-16 h-auto mb-2 stroke-current" />

<h3 className="text-sm font-light text-center" style={{ maxWidth: '20rem' }}>
Expand All @@ -52,6 +62,11 @@ export const ActivityComponent: React.FC<Props> = ({ assetSlug }) => {
return (
<div className="w-full max-w-sm mx-auto">
<div className={classNames('my-3 flex flex-col', popup && 'mx-4')}>
{loading && activities.length === 0 && (
<div className="w-full mb-4 flex justify-center">
<PartnersPromotion variant={PartnersPromotionVariant.Image} />
</div>
)}
<InfiniteScroll
dataLength={activities.length}
hasMore={reachedTheEnd === false}
Expand Down
Loading

0 comments on commit 3761aaa

Please sign in to comment.