Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(settings, enteredEmail) =>
createUrl(
filterName(enteredEmail) ||
settings?.gravatarEmail ||
settings?.currentEmail ||
defaultAvatar,
),
)
export const $nameChanged: Store = combine(
$settings,
$name,
(settings, name) => (settings?.displayName || "") !== filterName(name),
)
export const $avaEmailChanged: Store = combine(
$settings,
$avaEmail,
// just remove spaces from email
(settings, email) => (settings?.gravatarEmail || "") !== filterName(email),
)
forward({
from: pageMounted,
to: loadSettings,
})
loadSettings.use(accountApi.getSettings)
saveSettings.use(accountApi.updateSettings)
forward({ from: saveSettings.done, to: loadSession })
export const $isDisabled: Store = combine(
$isSettingsReady,
$isLoading,
(ready, loading) => !ready || loading,
)
// Stores for inputs
const defaultAvatar =
"https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mp&s=512"
const avatarParams = "d=retro&rating=g&s=512"
export const $name: Store = createStore("")
export const $avaEmail: Store = createStore("")
export const $avatarUrl: Store = combine(
$settings,
$avaEmail,
(settings, enteredEmail) =>
createUrl(
filterName(enteredEmail) ||
settings?.gravatarEmail ||
settings?.currentEmail ||
defaultAvatar,
),
)
export const $nameChanged: Store = combine(
$settings,
$name,
(settings, name) => (settings?.displayName || "") !== filterName(name),
)
<h3>Users:</h3>
)
export const installHistory = app.createEvent()
const changeLocation = app.createEvent()
// triggered when current location not equal new location
// and new location is valid user ID
const onValidLocation = guard(changeLocation, {
filter: sample({
source: combine({loc: location$, users: userList}),
clock: changeLocation,
fn: ({loc, users}, path) =>
loc !== path && users.includes(path.replace('/user/', '')),
}),
})
installHistory.watch(history => {
const locationUpdate = scopeBind(changeLocation)
history.listen(location => {
locationUpdate(location.pathname)
})
})
forward({
from: startClient,
to: installHistory,
export const $name: Store = createStore("")
export const $avaEmail: Store = createStore("")
export const $avatarUrl: Store = combine(
$settings,
$avaEmail,
(settings, enteredEmail) =>
createUrl(
filterName(enteredEmail) ||
settings?.gravatarEmail ||
settings?.currentEmail ||
defaultAvatar,
),
)
export const $nameChanged: Store = combine(
$settings,
$name,
(settings, name) => (settings?.displayName || "") !== filterName(name),
)
export const $avaEmailChanged: Store = combine(
$settings,
$avaEmail,
// just remove spaces from email
(settings, email) => (settings?.gravatarEmail || "") !== filterName(email),
)
forward({
from: pageMounted,
to: loadSettings,
})
$user.on(loadUser.done, (_, { result: user }) => user)
$cards.on(loadCards.done, (_, { result: { useful, created } }) => ({
useful: useful.map(({ id }) => id),
created: created.map(({ id }) => id),
}))
$cardsRegistry.on(
loadCards.done,
(registry, { result: { useful, created } }) => ({
...registry,
...cardsToObject(useful),
...cardsToObject(created),
}),
)
export const $isLoading: Store = combine(
userFetching.isLoading,
cardsFetching.isLoading,
(userLoading, cardsLoading) => userLoading || cardsLoading,
)
export const $isFailed: Store = combine(
userFetching.isFailed,
cardsFetching.isFailed,
(userFailed, cardsFailed) => userFailed || cardsFailed,
)
export const $error: Store = combine(
userFetching.isFailed,
userFetching.error,
cardsFetching.isFailed,
cardsFetching.error,
(value) => value === null,
)
export const $form = createStoreObject({
email: $email,
password: $password,
})
const $isFormValid = combine(
$isPasswordCorrect,
$isEmailCorrect,
(isPasswordCorrect, isEmailCorrect) => isPasswordCorrect && isEmailCorrect,
)
export const $isFormDisabled = registerFetching.isLoading
export const $isSubmitEnabled: Store = combine(
$isFormValid,
registerFetching.isLoading,
(isFormValid, isregisterFetching) => isFormValid && !isregisterFetching,
)
sample($isAuthenticated, formMounted).watch((isAuthenticated) => {
if (isAuthenticated) history.replace("/")
})
const trimEvent = (event) => event.currentTarget.value.trim()
$email.on(emailChanged.map(trimEvent), (_, email) => email)
$password.on(passwordChanged.map(trimEvent), (_, password) => password)
$form.reset(formUnmounted).reset(formMounted)
sample(
export default ($data, $columns, $sort, $searchValue, $filterValues) => {
const $computedData = combine(
$data,
$columns,
$sort,
$searchValue,
$filterValues,
(data, columns, sort, searchValue, filterValues) =>
pipe(
sortFn(sort),
search(searchValue, columns),
filter(filterValues, columns)
)(data)
);
return { $computedData };
};
export const pageUnloaded = createEvent()
export const cardLoading: Effect<
{ cardId: number },
{ card: Card },
void,
> = createEffect()
export const cardFetching: Fetching<*, void> = createFetching(
cardLoading,
"loading",
)
const $cardId = createStore(-1)
export const $card: Store = combine(
$cardsRegistry,
$cardId,
(registry, cardId) => registry[cardId],
)
cardLoading.use(({ cardId }) => cardsApi.getById(cardId))
$cardId.on(cardLoading, (_, { cardId }) => cardId)
$cardId.on(cardLoading.done, (_, { result }) => result.card.id)
$cardId.reset(pageUnloaded)
$cardsRegistry.on(cardLoading.done, (registry, { result }) => {
return {
...registry,
...cardsToObject([result.card]),
}
{...stats}
/>
),
)
const ErrorsView = createComponent(
codeError,
({}, {isError, error, stackFrames}) => (
),
)
const changeSourcesDebounced = debounce(changeSources, 500)
const CodeView = createComponent(
{
displayEditor: combine(tab, isDesktopChanges, (tab, isDesktop) =>
isDesktop ? true : tab === 'editor',
),
sourceCode,
mode,
},
({}, {displayEditor, mode, sourceCode}) => (
<div style="{{visibility:">
</div>
export const $password = createStore("")
export const $passwordError = $password.map((value) => {
if (value && value.length > 1) return null
return "Please, enter password"
})
export const $isPasswordCorrect = $passwordError.map(
(value) => value === null,
)
export const $form = createStoreObject({
email: $email,
password: $password,
})
const $isFormValid = combine(
$isPasswordCorrect,
$isEmailCorrect,
(isPasswordCorrect, isEmailCorrect) => isPasswordCorrect && isEmailCorrect,
)
export const $isFormDisabled = loginFetching.isLoading
export const $isSubmitEnabled: Store = combine(
$isFormValid,
loginFetching.isLoading,
(isFormValid, isLoginFetching) => isFormValid && !isLoginFetching,
)
formMounted.watch(() => {
if ($isAuthenticated.getState()) {
history.replace("/")
}