Skip to content

Commit

Permalink
feat: 鎖定槓桿的功能,就算用戶點擊內建 etoro 槓桿也會有效記錄
Browse files Browse the repository at this point in the history
  • Loading branch information
aqzhyi committed Jun 19, 2020
1 parent 2d01f89 commit 2c44ccd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/etoro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { initializeIcons } from '@fluentui/react'
import { renderFooterUnitValues } from '@/components/Footer/FooterUnitValues'
import { PortfolioHistoryHeaderExtraButtons } from '@/components/Portfolio/PortfolioHistoryHeaderExtraButtons'
import { fetchExtraCurrency } from '@/actions/fetchExtraCurrency'
import { setBetterEtoroUIConfig } from '@/actions/setBetterEtoroUIConfig'

type $ = JQueryStatic
globalThis.localStorage.setItem('debug', `${debugAPI.log.namespace}:*`)
Expand Down Expand Up @@ -114,6 +115,32 @@ const unbindConstructTriggerDelegate = emitter.on(
},
)

/**
* 這使用戶不需要按巨集,直接按內建槓桿時,也會記憶
*/
const rememberRiskItemlevelAsLastUnbind = emitter.on(
Events.ready,
function rememberRiskItemlevelAsLast() {
$('body').delegate('.risk-itemlevel', 'click', (index, element) => {
const leverText = (index.target as HTMLAnchorElement).innerText
.trim()
.replace(/x/i, '')

const state = store.getState()

if (state.settings.betterEtoroUIConfig.executionUseApplyLast) {
store.dispatch(
setBetterEtoroUIConfig({
executionLeverLast: Number(leverText),
}),
)
}
})

rememberRiskItemlevelAsLastUnbind()
},
)

/**
* 查看更多按鈕
*/
Expand Down
Loading

0 comments on commit 2c44ccd

Please sign in to comment.