Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const notification_message = () => ({
strategy_conversion: localize('Save this strategy as an XML file from Deriv Bot for faster re-imports.'),
google_drive_error: localize('Your session has expired. Please sign in again.'),
xml_import_error: localize('Unsupported file format. Please import a valid XML file.'),
keep_screen_alive: localize('Ensure your screen is active and your connection is stable to avoid interruptions.'),
});

export const notification_style = {
Expand Down
37 changes: 32 additions & 5 deletions src/components/bot-stopped.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ import Dialog from './shared_ui/dialog';
import { standalone_routes } from './shared';

const BotStopped = observer(() => {
const { dashboard, run_panel } = useStore();
const { dashboard, run_panel, client } = useStore();
const { is_web_socket_intialised } = dashboard;

const { is_running } = run_panel;
const isOnline = useNavigatorOnline();

// Get client information for the report URL
const getCurrency = client?.getCurrency;
const currency = getCurrency?.();

// Check if the account is a demo account
// Use the URL parameter to determine if it's a demo account, as this will update when the account changes
const urlParams = new URLSearchParams(window.location.search);
const account_param = urlParams.get('account');
const is_virtual = client?.is_virtual || account_param === 'demo' || false;

// Determine the type of disconnection
const isInternetDisconnection = !isOnline && is_running;
const isInternalIssue = !is_web_socket_intialised && isOnline;
Expand All @@ -31,9 +41,26 @@ const BotStopped = observer(() => {
is_visible={shouldShowPopup}
is_mobile_full_width
className={'dc-dialog bot-stopped-dialog'}
cancel_button_text={!isInternetDisconnection ? localize('Go to Reports') : undefined}
cancel_button_text={!isInternetDisconnection ? localize('View Report') : undefined}
confirm_button_text={!isInternetDisconnection ? localize('Back to Bot') : undefined}
onCancel={!isInternetDisconnection ? () => (window.location.href = standalone_routes.positions) : undefined}
onCancel={
!isInternetDisconnection
? () => {
const url = new URL(standalone_routes.positions);

// Add account parameter based on account type
if (is_virtual) {
// For demo accounts, set the account parameter to 'demo'
url.searchParams.set('account', 'demo');
} else if (currency) {
// For real accounts, set the account parameter to the currency
url.searchParams.set('account', currency);
}

window.location.href = url.toString();
}
: undefined
}
onConfirm={() => location.reload()}
login={() => {}}
>
Expand All @@ -42,7 +69,7 @@ const BotStopped = observer(() => {
{isInternetDisconnection ? (
<Localize i18n_default_text="You're offline" />
) : (
<Localize i18n_default_text='Platform temporarily unavailable' />
<Localize i18n_default_text='Connection Interrupted' />
)}
</Text>
<div
Expand All @@ -62,7 +89,7 @@ const BotStopped = observer(() => {
{isInternetDisconnection ? (
<Localize i18n_default_text='Your bot is paused while you’re offline. Reconnect to continue trading.' />
) : (
<Localize i18n_default_text='The platform connection was terminated, so your bot has stopped. Your trade may still be running. Please check the Reports page to monitor your trade.' />
<Localize i18n_default_text='Your connection to the server was lost, all trades have been settled. Check the Reports page for final results.' />
)}
</Text>
</Dialog>
Expand Down
2 changes: 2 additions & 0 deletions src/stores/run-panel-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ export default class RunPanelStore {

summary_card.clear();
this.setContractStage(contract_stages.STARTING);
// Show notification to keep screen alive after all validations pass
botNotification(notification_message().keep_screen_alive);
this.dbot.runBot();
});
this.setShowBotStopMessage(false);
Expand Down
Loading