Slight simplification
This commit is contained in:
parent
12ae68f45e
commit
12bbc525dc
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue