-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat): implement direct Application links (issue #2950)
- Loading branch information
1 parent
fa6bf20
commit 1eee9e7
Showing
7 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { EMPTY, filter, of, switchMap } from 'rxjs'; | ||
|
||
import { combineEpics } from 'redux-observable'; | ||
|
||
import { AppEpic } from '@/src/types/store'; | ||
|
||
import { MarketplaceQueryParams } from '@/src/constants/marketplace'; | ||
|
||
import { ModelsSelectors } from '../models/models.reducers'; | ||
import { UIActions } from '../ui/ui.reducers'; | ||
import { MarketplaceActions } from './marketplace.reducers'; | ||
|
||
const setDetailsModelEpic: AppEpic = (action$, _, { router }) => | ||
action$.pipe( | ||
filter(MarketplaceActions.setDetailsModel.match), | ||
switchMap(({ payload }) => { | ||
const reference = payload?.reference; | ||
const query = router.query; | ||
if (reference) { | ||
router.push({ | ||
query: { | ||
...query, | ||
[MarketplaceQueryParams.model]: reference, | ||
}, | ||
}); | ||
} else { | ||
delete query[MarketplaceQueryParams.model]; | ||
router.push({ | ||
query, | ||
}); | ||
} | ||
return EMPTY; | ||
}), | ||
); | ||
|
||
const initQueryParamsEpic: AppEpic = (action$, state$, { router }) => | ||
action$.pipe( | ||
filter(MarketplaceActions.initQueryParams.match), | ||
switchMap(() => { | ||
const query = router.query; | ||
const modelReference = query[MarketplaceQueryParams.model] as | ||
| string | ||
| undefined; | ||
const modelsMap = ModelsSelectors.selectModelsMap(state$.value); | ||
const model = modelReference ? modelsMap[modelReference] : undefined; | ||
|
||
if (modelReference) { | ||
if (model) { | ||
return of( | ||
MarketplaceActions.setDetailsModel({ | ||
reference: modelReference, | ||
isSuggested: false, | ||
}), | ||
); | ||
} else { | ||
return of(UIActions.showErrorToast('Agent by this link not found')); | ||
} | ||
} | ||
|
||
return EMPTY; | ||
}), | ||
); | ||
|
||
export const MarketplaceEpics = combineEpics( | ||
initQueryParamsEpic, | ||
setDetailsModelEpic, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters