Slight simplification

This commit is contained in:
Eric van der Vlist 2023-03-02 16:35:10 +01:00
parent 12ae68f45e
commit 12bbc525dc
1 changed files with 7 additions and 8 deletions

View File

@ -84,13 +84,12 @@ const User: Component<Props> = (props) => {
return false;
};
const addSubscriptionFactory =
(username: string) => (userDocument: any) => {
const subscriptions = userDocument.subscriptions || [];
subscriptions.push({ username, direction: '' });
userDocument.subscriptions = subscriptions;
return { username, ...userDocument };
};
const addSubscription = (userDocument: any) => {
const subscriptions = userDocument.subscriptions || [];
subscriptions.push({ username, direction: '' });
userDocument.subscriptions = subscriptions;
return { username, ...userDocument };
};
const defaultUserDocument = {
database,
@ -101,7 +100,7 @@ const User: Component<Props> = (props) => {
if (!isIn(subscription.username, subscriptions)) {
update(
userId(subscription.username, database),
addSubscriptionFactory(username),
addSubscription,
defaultUserDocument
);
console.log({