Skip to content

Commit

Permalink
fix(iridium): remove old friends manager references
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwoodland committed Aug 19, 2022
1 parent 0561e4b commit 3d95f47
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 30 deletions.
2 changes: 1 addition & 1 deletion components/views/media/incomingCall/IncomingCall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default Vue.extend({
if (this.isGroup) {
return
}
return iridium.friends.getFriend(this.incomingCall.did)
return iridium.users.getUser(this.incomingCall.did)
},
callerAvatar(): string {
if (!this.caller) {
Expand Down
4 changes: 2 additions & 2 deletions components/views/navigation/mobile/toolbar/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default Vue.extend({
},
data() {
return {
friends: iridium.friends.state.details,
users: iridium.users.state,
groups: iridium.groups.state,
isGroupInviteVisible: false,
webrtc: iridium.webRTC.state,
Expand Down Expand Up @@ -65,7 +65,7 @@ export default Vue.extend({
if (!friendDid) {
return
}
return this.friends[friendDid]
return this.users[friendDid]
},
groupMembers(): GroupMemberDetails[] {
const members = (this.details as Group).members ?? []
Expand Down
10 changes: 5 additions & 5 deletions components/views/navigation/sidebar/live/Live.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default Vue.extend({
data() {
return {
webrtc: iridium.webRTC,
friends: iridium.friends.state.details,
users: iridium.users.state,
groups: iridium.groups.state,
}
},
Expand All @@ -32,7 +32,7 @@ export default Vue.extend({
return false // TODO : Fix later
},
selUserName(): string {
const sUser = Object.values(this.friends).find(
const sUser = Object.values(this.users).find(
(friend) => friend.did === this.webrtc.state.activeCall?.did,
)
return sUser?.name ?? ''
Expand Down Expand Up @@ -62,7 +62,7 @@ export default Vue.extend({
if (!participant) {
return
}
return Object.values(this.friends).find((f) => f.did === participant)
return Object.values(this.users).find((f) => f.did === participant)
},
groupMembers(): GroupMemberDetails[] {
const members = (this.details as Group).members ?? []
Expand All @@ -71,13 +71,13 @@ export default Vue.extend({
enableRTC(): boolean {
if (this.isGroup) {
const memberIds = this.groupMembers.map((m) => m.id)
return Object.values(this.friends).some(
return Object.values(this.users).some(
(friend: Friend) =>
memberIds.includes(friend.did) && friend.status === 'online',
)
}
// Check current recipient is on the user's friends list
const friend = Object.values(this.friends).find(
const friend = Object.values(this.users).find(
(f) => f.did === (this.details as User)?.did,
)
return friend?.status === 'online'
Expand Down
4 changes: 2 additions & 2 deletions components/views/navigation/toolbar/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ export default Vue.extend({
// todo- hook up to usermanager
if (this.isGroup) {
const memberIds = this.groupMembers.map((m) => m.id)
return Object.values(this.friends).some(
return Object.values(this.users).some(
(friend: Friend) =>
memberIds.includes(friend.did) && friend.status === 'online',
)
}
// Check current recipient is on the user's friends list
const friend = Object.values(this.friends).find(
const friend = Object.values(this.users).find(
(f) => f.did === (this.details as User)?.did,
)
return friend?.status === 'online'
Expand Down
2 changes: 1 addition & 1 deletion libraries/Iridium/chat/ChatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default class ChatManager extends Emitter<ConversationMessage> {
`/conversations/${conversationId}/message/${message.id}`,
message,
)
const friendName = this.iridium.friends.getFriend(message?.from)
const friendName = this.iridium.users.getUser(message?.from)
const buildNotification: Partial<Notification> = {
fromName: friendName?.name,
at: Date.now(),
Expand Down
13 changes: 0 additions & 13 deletions libraries/Iridium/friends/FriendsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,4 @@ export default class FriendsManager extends Emitter<IridiumFriendPubsub> {
await this.send(payload)
}
}

/**
* @method updateFriend
* @description check if there's a friend with the current did and change it with new user object
* @param did string (required)
* @param user User (required)
*/
updateFriend(user: User): void {
const friend = this.getFriend(user.did)
if (!friend) return

Vue.set(this.state.details, user.did, user)
}
}
2 changes: 1 addition & 1 deletion libraries/Iridium/groups/GroupManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default class GroupManager extends Emitter<IridiumMessage> {
throw new Error(GroupsError.CANNOT_ADD_MEMBER)
}

const member = this.iridium.friends.getFriend(remotePeerDID)
const member = this.iridium.users.getUser(remotePeerDID)
if (!member) {
logger.error(this.loggerTag, 'friend not found')
throw new Error(GroupsError.CANNOT_ADD_MEMBER)
Expand Down
9 changes: 4 additions & 5 deletions libraries/Iridium/webrtc/WebRTCManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export default class WebRTCManager extends Emitter {
})
}

const friends = Object.values(this.iridium.friends.state.details)
const friends = Object.values(this.iridium.users.state)

friends
.filter((friend) => friend.did && friend.status !== 'online')
Expand Down Expand Up @@ -437,12 +437,12 @@ export default class WebRTCManager extends Emitter {

private onPeerAnnounce = (payload: any) => {
const did = payload.did as string
const requestFriend = this.iridium.friends.getFriend(did)
const requestFriend = this.iridium.users.getUser(did)

if (!requestFriend || requestFriend.status === 'online') return

// TO DO : move to usermanager
this.iridium.friends.updateFriend({
this.iridium.users.setUser(requestFriend.did, {
...requestFriend,
status: 'online',
})
Expand Down Expand Up @@ -516,8 +516,7 @@ export default class WebRTCManager extends Emitter {

const peers = participants.map((did) => {
const user =
this.iridium.friends.getFriend(did) ||
(this.iridium.profile.state ?? '')
this.iridium.users.getUser(did) || (this.iridium.profile.state ?? '')

return {
name: user.name,
Expand Down

0 comments on commit 3d95f47

Please sign in to comment.