Skip to content

Commit

Permalink
Remove duplicate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
retrouser955 committed Sep 24, 2024
1 parent b36aa81 commit 1d46123
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/hooks/user/helpers/User/ClientUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ type OnFriendsUpdateHandler = (friends: string[]) => void;
export class ClientUser extends BaseUser {
_sea: ISEAPair;
private _isListeningForFriends = false;
public alias: string = "";
public avatar: string = "";
public bio: string = "";
public display_name: string = "";

constructor(sea: ISEAPair, db: IGunInstance, user: GunUserInstance) {
super(db, user);
Expand All @@ -21,18 +17,12 @@ export class ClientUser extends BaseUser {

onFriendsUpdate(onUpdate: OnFriendsUpdateHandler, forceMultiple = false) {
if(this._isListeningForFriends && !forceMultiple) return
this._user.get("friends").on((data: string[] /* these are gun souls */) => onUpdate(data));
}

async loadAll() {
const arr = Object.values(UserKeys);

// For loop
for (let i = 0; i < arr.length; i++) {
const key = arr[i];
const list = this._user.get("friends")

list.on((data: string[] /* these are gun souls */) => onUpdate(data));

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this as any)[key as any] = await this.createPromiseGunGetUser(key as any);
return () => {
list.off()
}
}

Expand Down

0 comments on commit 1d46123

Please sign in to comment.