Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
key: string,
value: any,
owner: string,
target: DataStoreTarget,
expires: number,
) {
const isNull = !value && typeof value === 'object';
const data = isNull
? value
: {
value,
owner,
target,
expires,
};
swap(ctx, state => ({
...state,
data: updateKey(state.data, key, data),
}));
this.emit('store-data', {
name,
target,
value,
owner,
expires,
});
}
export function closeModal(ctx: Atom, dialog: OpenModalDialog) {
swap(ctx, state => ({
...state,
modals: excludeItem(state.modals, dialog),
}));
}
return context => {
context.defineActions(createActions(localizer));
swap(context.state, state => ({
...state,
components: {
...state.components,
LanguagesPicker: DefaultPicker,
},
language: {
loading: false,
available: localizer.languages,
selected: localizer.language,
},
}));
return () => {
let localTranslations: LocalizationMessages = {};
return {
export function injectPilet(ctx: Atom, pilet: Pilet) {
swap(ctx, state => ({
...state,
modules: replaceOrAddItem(state.modules, pilet, m => m.name === pilet.name),
registry: removeNested(state.registry, m => m.pilet === pilet.name),
}));
}
export function appendSearchResults(ctx: Atom, items: Array, done: boolean) {
swap(ctx, state => ({
...state,
search: {
...state.search,
results: {
loading: !done,
items: appendItems(state.search.results.items, items),
},
},
}));
}
export function unregisterTile(ctx: Atom, name: string) {
swap(ctx, state => ({
...state,
registry: {
...state.registry,
tiles: withoutKey(state.registry.tiles, name),
},
}));
}
return context => {
context.defineActions(actions);
swap(context.state, state => ({
...state,
components: {
...state.components,
NotificationsHost: DefaultHost,
NotificationsToast: DefaultToast,
},
notifications: getNotifications(context, messages, defaultOptions),
}));
return {
showNotification(content, customOptions) {
const notification = createNotification(context, selectId(), content, defaultOptions, customOptions);
context.openNotification(notification);
return notification.close;
},
};
export function setRoute(
ctx: Atom,
path: string,
component: ComponentType>,
) {
swap(ctx, state => ({
...state,
routes: withKey(state.routes, path, component),
}));
}
export function destroyPortal(ctx: Atom, id: string) {
swap(ctx, state => ({
...state,
portals: withoutKey(state.portals, id),
}));
}
export function registerTile(ctx: Atom, name: string, value: TileRegistration) {
swap(ctx, state => ({
...state,
registry: {
...state.registry,
tiles: withKey(state.registry.tiles, name, value),
},
}));
}