Skip to content

Commit

Permalink
Fix favorite app delete (#536)
Browse files Browse the repository at this point in the history
* fix: init request url parse

* fix: init request url parse

* feat: exclusions noise reduce

* feat: diff denoise check all

* fix: favorate app delete

---------

Co-authored-by: onePone <[email protected]>
  • Loading branch information
1pone and Xremn authored Nov 10, 2023
1 parent f5fec72 commit 8c700e7
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions packages/arex/src/menus/Replay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,17 @@ const ReplayMenu: ArexMenuFC = (props) => {
[activePane?.type, props.value],
);

const {
data: favoriteApps,
loading: loadingFavoriteApp,
run: getFavoriteApps,
} = useRequest(() => UserService.getFavoriteApp(email), {
onSuccess(favoriteApps) {
if (!favoriteAppsInitialized) {
favoriteApps.length && disableFavoriteFilter();
setFavoriteAppsInitialized(true);
}
const { data: favoriteApps, run: getFavoriteApps } = useRequest(
() => UserService.getFavoriteApp(email),
{
onSuccess(favoriteApps) {
if (!favoriteAppsInitialized) {
favoriteApps.length && disableFavoriteFilter();
setFavoriteAppsInitialized(true);
}
},
},
});
);

const filter = useCallback(
(keyword: string, app: ApplicationDataType) => {
Expand All @@ -121,21 +120,6 @@ const ReplayMenu: ArexMenuFC = (props) => {
[favoriteFilter, favoriteApps],
);

/**
* 无效的 FavoriteApp 回收策略
* 1. 当 regressionList 接口响应慢于 getFavoriteApp 接口: 概率触发
* 2. 当手动刷新 regressionList 接口: 稳定触发
* @param apps
*/
const recycleDiscard = (apps: ApplicationDataType[]) => {
const discard = favoriteApps?.filter((id) => apps.findIndex((app) => app.id === id) < 0);
if (discard?.length) {
Promise.all(
discard.map((id) => UserService.setUnFavoriteApp({ userName: email, favoriteApp: id })),
).then((res) => res.length && getFavoriteApps());
}
};

const handleSelect: MenuSelectProps<ApplicationDataType, any[]>['onSelect'] = (value) => {
props.onSelect?.(value); // to streamline the params, remove the types from onSelect handler
};
Expand Down Expand Up @@ -179,9 +163,6 @@ const ReplayMenu: ArexMenuFC = (props) => {
request={ApplicationService.getAppList}
requestOptions={{
refreshDeps: [timestamp], // refresh when delete app
onSuccess(res) {
!loadingFavoriteApp && recycleDiscard(res);
},
}}
filter={filter}
itemRender={(app) => ({
Expand Down

0 comments on commit 8c700e7

Please sign in to comment.