fix(ui): remove duplicate success toast when saving trader (#969)
📝 Description | 描述
English:
Fixes duplicate success toast notifications when saving a trader configuration. Users were seeing two identical "保存成功" toasts due to nested toast.promise() calls in the component hierarchy.
中文:
修復保存交易員配置時出現重複的成功提示。由於組件層次結構中的嵌套 toast.promise() 調用,用戶會看到兩個相同的「保存成功」提示。
🎯 Type of Change | 變更類型
- [x] 🐛 Bug fix | 修復 Bug
- [ ] ✨ New feature | 新功能
- [ ] 💥 Breaking change | 破壞性變更
- [ ] 🎨 Code style update | 代碼樣式更新
- [ ] ♻️ Refactoring | 重構
- [ ] ⚡ Performance improvement | 性能優化
🔗 Related Issues | 相關 Issue
- Closes #969 | 關閉 #969
📋 Changes Made | 具體變更
English:
- Removed
toast.promise()wrapper fromTraderConfigModal.tsx(line 257-260) - Let parent component (
AITradersPage.tsx) handle all toast notifications - Applied
npm run lint --fixto auto-format other files
中文:
- 從
TraderConfigModal.tsx移除toast.promise()包裝(第 257-260 行) - 讓父組件(
AITradersPage.tsx)處理所有 toast 通知 - 運行
npm run lint --fix自動格式化其他文件
Root Cause | 根本原因
TraderConfigModal: toast.promise(onSave(...)) ← Toast #1
└─ handleSaveEditTrader: toast.promise(api.updateTrader(...)) ← Toast #2
Solution | 解決方案
- await toast.promise(onSave(saveData), {
- loading: '正在保存…',
- success: '保存成功',
- error: '保存失败',
- })
+ // 直接调用 onSave,让父组件处理 toast 通知
+ // 避免重复弹窗(父组件 AITradersPage 已有 toast.promise)
+ await onSave(saveData)
Principle | 原則: UI notification responsibility belongs to business logic layer (parent), not presentation layer (modal).
🧪 Testing | 測試
Test Environment | 測試環境
- OS | 操作系統: macOS
- Node Version | Node 版本: 20.x
- Browser(s) | 瀏覽器: Chrome, Safari
Manual Testing | 手動測試
- [x] Tested in development mode | 開發模式測試通過
- [x] Tested production build | 生產構建測試通過 (
npm run build) - [x] Verified no existing functionality broke | 確認沒有破壞現有功能
- [x] Create new trader → Only 1 success toast ✅
- [x] Edit existing trader → Only 1 success toast ✅
🌐 Internationalization | 國際化
- [x] N/A | 不適用(純邏輯修復,無 UI 文本變更)
✅ Checklist | 檢查清單
Code Quality | 代碼質量
- [x] Code follows project style | 代碼遵循項目風格
- [x] Self-review completed | 已完成代碼自查
- [x] Comments added for complex logic | 已添加必要註釋
- [x] Code builds successfully | 代碼構建成功 (
npm run build) - [x] Ran
npm run lint| 已運行npm run lint - [x] No console errors or warnings | 無控制台錯誤或警告
Testing | 測試
- [x] Tests pass locally | 測試在本地通過(手動測試)
- [ ] Component tests added/updated | 已添加/更新組件測試(N/A - 純邏輯修復)
Documentation | 文檔
- [x] Updated relevant documentation | 已更新相關文檔(N/A)
- [x] Updated type definitions (TypeScript) | 已更新類型定義(N/A)
- [x] Added JSDoc comments where necessary | 已添加 JSDoc 註釋
Git
- [x] Commits follow conventional format | 提交遵循 Conventional Commits 格式
- [x] Rebased on latest
devbranch | 已 rebase 到最新dev分支 - [x] No merge conflicts | 無合併衝突
📚 Additional Notes | 補充說明
English: This is a minimal, focused bug fix that addresses the duplicate toast issue without introducing any new features or breaking changes. The same fix has been tested and deployed on the z-dev-v2 branch.
中文: 這是一個最小化、專注的 bug 修復,解決了重複提示問題,沒有引入任何新功能或破壞性變更。相同的修復已在 z-dev-v2 分支測試並部署。
By submitting this PR, I confirm | 提交此 PR,我確認:
- [x] I have read the Contributing Guidelines | 已閱讀貢獻指南
- [x] I agree to the Code of Conduct | 同意行為準則
- [x] My contribution is licensed under AGPL-3.0 | 貢獻遵循 AGPL-3.0 許可證
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]
🤖 Advisory Check Results
These are advisory checks to help improve code quality. They won't block your PR from being merged.
📋 PR Information
Title Format: ✅ Good - Follows Conventional Commits PR Size: 🟢 Small (31 lines: +19 -12)
🔧 Backend Checks
Go Formatting: ⚠️ Needs formatting
Files needing formatting
market/combined_streams.go
Go Vet: ✅ Good Tests: ✅ Passed
Fix locally:
go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests
⚛️ Frontend Checks
Build & Type Check: ✅ Success
Fix locally:
cd web
npm run build # Test build (includes type checking)
📖 Resources
Questions? Feel free to ask in the comments! 🙏
These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.
Seems there are pretty many only format and indent changes
Could you please help to remove those ?
Thanks. @the-dev-z
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 14 committers have signed the CLA.
:white_check_mark: tinkle-community
:x: xqliu
:x: wquguru
:x: the-dev-z
:x: CoderMageFox
:x: deloz
:x: Im-Sue
:x: ljh740
:x: tangmengqiu
:x: zpng
:x: 0xEmberZz
:x: tinkle
:x: hzb1115
:x: MarsDoge
tinkle seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.