Skip to content

Commit

Permalink
Merge branch 'master' into testlink_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadtaimoor-deriv authored Feb 5, 2024
2 parents dc5f13f + 72cd7c3 commit f1c0912
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# More info: https://help.github.com/articles/about-codeowners/
#

* @binary-com/write-admin-smartcharts
* @binary-com/write-admin-smartcharts
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ updates:
directory: "/"
schedule:
interval: daily
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
31 changes: 15 additions & 16 deletions .github/workflows/generate_preview_link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ on:
pull_request_target:
types: [opened, synchronize]

env:
HEAD_REF: ${{ github.head_ref }}

concurrency:
group: cloudflare-pages-build-"$HEAD_REF"
group: cloudflare-pages-build-${{ github.head_ref }}
cancel-in-progress: true

jobs:
build_and_deploy_preview_link:
if: github.event.pull_request.user.login == 'ahmadtaimoor-deriv'
runs-on: Ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
# - name: Verify user
# uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1"
# with:
# username: ${{github.event.pull_request.user.login}}
# token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Verify user
uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1"
with:
username: ${{github.event.pull_request.user.login}}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Post preview build comment
id: post_preview_build_comment
uses: 'deriv-com/shared-actions/.github/actions/post_preview_build_comment@v1'
Expand All @@ -32,7 +29,7 @@ jobs:
head_sha: ${{github.event.pull_request.head.sha}}

- name: Checkout SmartCharts
uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master'
uses: 'binary-com/SmartCharts/.github/actions/checkout@master'
with:
repository: ${{github.event.pull_request.user.login}}/SmartCharts
path: SmartCharts
Expand All @@ -41,7 +38,8 @@ jobs:
alternate_ref: master

- name: Checkout deriv-app
uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master'
id: deriv_app
uses: 'binary-com/SmartCharts/.github/actions/checkout@master'
with:
repository: ${{github.event.pull_request.user.login}}/deriv-app
path: deriv-app
Expand All @@ -50,9 +48,10 @@ jobs:
alternate_ref: master

- name: Custom flutter-chart
uses: 'ahmadtaimoor-deriv/SmartCharts/.github/actions/checkout@master'
id: flutter_chart
uses: 'binary-com/SmartCharts/.github/actions/checkout@master'
with:
repository: ${{github.event.pull_request.user.login}}/flutter-chartz
repository: ${{github.event.pull_request.user.login}}/flutter-chart
path: flutter-chart
ref: ${{github.head_ref}}
alternate_repository: 'regentmarkets/flutter-chart'
Expand Down Expand Up @@ -116,7 +115,7 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TEST_LINKS_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_TEST_LINKS_ACCOUNT_ID }}
project_name: 'smartcharts-preview'
branch_name: 'pr-${{github.event.number}}'
branch_name: pr-${{github.event.number}}${{ steps.deriv_app.outputs.ref_exists == true && '-dtra' || ''}}${{ steps.flutter_chart.outputs.ref_exists == true && '-flutt' || ''}}
output_dir: deriv-app/packages/core/dist

- name: 'Generate preview link comment'
Expand All @@ -126,4 +125,4 @@ jobs:
issue_number: ${{github.event.number}}
check_run_id: ${{steps.post_preview_build_comment.outputs.check_run_id}}
preview_url: ${{steps.publish_to_pages_branch.outputs.cf_pages_url}}
status: ${{job.status}}
status: ${{job.status}}
26 changes: 19 additions & 7 deletions chart_app/lib/src/models/indicators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class IndicatorsModel {
values: values,
));
} else if (item is AlligatorSeries) {
//TODO : enable offset after fixing in the flutter charts
//TO DO : enable offset after fixing in the flutter charts
tooltipContent.add(JsIndicatorTooltip(
name: AlligatorIndicatorConfig.name,
values: <String?>[
Expand Down Expand Up @@ -368,6 +368,16 @@ class IndicatorsModel {
double y,
int bottomIndicatorIndex,
) {
/// Called to get epoch from x position
int? _getClosestEpoch(int? x, int granularity) {
try {
return getClosestEpoch?.call(x, granularity);
// ignore: avoid_catches_without_on_clauses
} catch (_) {
return null;
}
}

int configIndex = 0;
Series? bottomItemIndicator;
final List<Series> sortedSeriesList = <Series>[...seriesList];
Expand All @@ -388,9 +398,11 @@ class IndicatorsModel {

final Offset target = Offset(x, y);
final int? epoch =
getClosestEpoch?.call(controller.getEpochFromX(x), granularity);
_getClosestEpoch(controller.getEpochFromX(x), granularity);

if (bottomItemIndicator != null && bottomIndicatorIndex != null) {
if (bottomItemIndicator != null &&
bottomIndicatorIndex > -1 &&
epoch != null) {
if (bottomItemIndicator is AwesomeOscillatorSeries) {
final List<Tick> aoEntries = bottomItemIndicator.entries ?? <Tick>[];

Expand Down Expand Up @@ -816,11 +828,11 @@ class IndicatorsModel {
}
}
} else if (item is AlligatorSeries) {
final List<Tick> teethEntries = item.teethSeries!.entries ?? <Tick>[];
final List<Tick> teethEntries = item.teethSeries?.entries ?? <Tick>[];

final List<Tick> jawEntries = item.jawSeries!.entries ?? <Tick>[];
final List<Tick> jawEntries = item.jawSeries?.entries ?? <Tick>[];

final List<Tick> lipEntries = item.lipsSeries!.entries ?? <Tick>[];
final List<Tick> lipEntries = item.lipsSeries?.entries ?? <Tick>[];

if (isPointOnIndicator(
teethEntries,
Expand Down Expand Up @@ -864,7 +876,7 @@ class IndicatorsModel {
if (index != null) {
final int quoteIndex = index - offset;

if (quoteIndex <= entries.length - 1) {
if (quoteIndex <= entries.length - 1 && quoteIndex > 0) {
final Tick prevIndex = entries[quoteIndex - 1];
final Tick currIndex = entries[quoteIndex];

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deriv/deriv-charts",
"version": "2.0.2",
"version": "2.0.3",
"main": "dist/smartcharts.js",
"author": "[email protected]",
"contributors": [
Expand Down
1 change: 0 additions & 1 deletion sass/components/_barrier.scss
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@
right: 0;
height: 120px !important;
opacity: 0.3;
transition: all 0.1s ease-out;
}

/* css gradients are only partially supported in Safari, but will work here since colors are not premultiplied */
Expand Down
10 changes: 10 additions & 0 deletions src/feed/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ class Feed {
end: number,
callback: TPaginationCallback
) {
if (this._mainStore.state.hasReachedEndOfData) {
return;
}

const isMainChart = true;
// TODO There is no need to get historical data before startTime
if (this.startEpoch /* && start < this.startEpoch */ || (this.endEpoch && end > this.endEpoch)) {
Expand Down Expand Up @@ -407,6 +411,12 @@ class Feed {
callback({ moreAvailable: false, quotes: [] });
this.setHasReachedEndOfData(true);
}

if (result.quotes?.length && result.quotes.length < count) {
callback({ moreAvailable: false, quotes: result.quotes });
this.setHasReachedEndOfData(true);
return;
}
} catch (err) {
console.error(err);
result = { error: err };
Expand Down
15 changes: 15 additions & 0 deletions src/flutter-chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const createChartElement = ({ onChartLoad }: TCreateChartElementProps) =>
return;
}

setupListeners();

const flutterChartElement = document.createElement('div');
flutterChartElement.classList.add('flutter-chart');

Expand Down Expand Up @@ -42,6 +44,19 @@ export const createChartElement = ({ onChartLoad }: TCreateChartElementProps) =>
return flutterChartElement;
};

const setupListeners = () => {
const listener = (ev: KeyboardEvent) => {
// To fix a trackjs issue caused by some keyboard events that don't contain `key` or `code` props.
// https://github.com/flutter/engine/blob/f20657354d8b53baafcec55650830ead89adf3e9/lib/web_ui/lib/src/engine/keyboard_binding.dart#L386
if (!ev.key || !ev.code) {
ev.stopImmediatePropagation();
}
};

window.addEventListener('keydown', listener, true);
window.addEventListener('keyup', listener, true);
};

export const runChartApp = () => {
if (window._flutter.initState.isMounted) {
window._flutter.appRunner?.runApp();
Expand Down
5 changes: 5 additions & 0 deletions src/store/BarrierStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export default class BarrierStore {
() => [this.mainStore.chartAdapter.epochBounds, this.mainStore.chartAdapter.quoteBounds],
this._drawShadedArea
);

this.mainStore.chartAdapter.painter.registerCallback(this._drawShadedArea);
};

init(): void {
Expand Down Expand Up @@ -195,6 +197,9 @@ export default class BarrierStore {

this.disposeDrawReaction?.();

this.mainStore.chartAdapter.painter.unregisterCallback(this._drawShadedArea);


const i = this.mainStore.chart._barriers.findIndex((b: BarrierStore) => b === this);
if (i !== -1) {
this.mainStore.chart._barriers.splice(i, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/store/TimeperiodStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default class TimeperiodStore {
if (dataSegmentClose && dataSegmentClose.length) {
const currentQuote = dataSegmentClose[dataSegmentClose.length - 1];
if (currentQuote.DT) {
const now = this._serverTime.getLocalDate().getTime();
const now = this._serverTime?.getLocalDate()?.getTime();
const diff = now - currentQuote.DT.getTime();

const granularity = this.mainStore.chart.granularity;
Expand Down
3 changes: 1 addition & 2 deletions src/utils/ServerTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class ServerTime {
if (this.serverTimeAtResponse) {
return this.serverTimeAtResponse;
}

throw new Error('Server time is undefined!');
return getUTCEpoch(new Date());
}

getLocalDate() {
Expand Down

0 comments on commit f1c0912

Please sign in to comment.