using set instead of array for search (#7126)

* Resolve #6905

* Resolve #6905

* Resolve #6905
This commit is contained in:
Ehsan Javadynia
2021-01-30 05:39:46 +03:30
committed by GitHub
parent 100a131913
commit ff67fb337e
7 changed files with 18 additions and 18 deletions

View File

@@ -19,9 +19,9 @@ import { UserProfile } from '../../../models/entities/user-profile';
export default class Connection {
public user?: User;
public userProfile?: UserProfile;
public following: User['id'][] = [];
public muting: User['id'][] = [];
public followingChannels: ChannelModel['id'][] = [];
public following: Set<User['id']> = new Set();
public muting: Set<User['id']> = new Set();
public followingChannels: Set<ChannelModel['id']> = new Set();
public token?: AccessToken;
private wsConnection: websocket.connection;
public subscriber: EventEmitter;
@@ -267,7 +267,7 @@ export default class Connection {
select: ['followeeId']
});
this.following = followings.map(x => x.followeeId);
this.following = new Set<string>(followings.map(x => x.followeeId));
}
@autobind
@@ -279,7 +279,7 @@ export default class Connection {
select: ['muteeId']
});
this.muting = mutings.map(x => x.muteeId);
this.muting = new Set<string>(mutings.map(x => x.muteeId));
}
@autobind
@@ -291,7 +291,7 @@ export default class Connection {
select: ['followeeId']
});
this.followingChannels = followings.map(x => x.followeeId);
this.followingChannels = new Set<string>(followings.map(x => x.followeeId));
}
@autobind