Skip to content

Commit

Permalink
Fixes for websocket changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Jun 29, 2023
1 parent 8253774 commit 35ae13c
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 81 deletions.
133 changes: 65 additions & 68 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,10 @@ speechSynthesis.getVoices();
});

API.$on('USER', function (args) {
if (!args?.json?.displayName) {
console.error('API.$on(USER) invalid args', args);
return;
}
$app.queueUpdateFriend({ id: args.json.id, state: args.json.state });
args.ref = this.applyUser(args.json);
});
Expand Down Expand Up @@ -2591,7 +2595,12 @@ speechSynthesis.getVoices();
}
ref.$location = this.parseLocation(ref.location);
if (json.world?.id) {
ref.world = this.applyWorld(json.world);
this.getCachedWorld({
worldId: json.world.id
}).then((args) => {
ref.world = args.ref;
return args;
});
}
if (!json.$fetchedAt) {
ref.$fetchedAt = new Date().toJSON();
Expand Down Expand Up @@ -4702,27 +4711,18 @@ speechSynthesis.getVoices();
break;

case 'friend-online':
if (
content.location !== 'private' &&
content.location !== 'traveling'
) {
this.$emit('WORLD', {
json: content.world,
if (content?.user?.id) {
this.$emit('USER', {
json: {
location: content.location,
travelingToLocation: content.travelingToLocation,
...content.user
},
params: {
worldId: content.world.id
userId: content.userId
}
});
}
this.$emit('USER', {
json: {
location: content.location,
travelingToLocation: content.travelingToLocation,
...content.user
},
params: {
userId: content.userId
}
});
this.$emit('FRIEND:STATE', {
json: {
state: 'online'
Expand All @@ -4734,12 +4734,14 @@ speechSynthesis.getVoices();
break;

case 'friend-active':
this.$emit('USER', {
json: content.user,
params: {
userId: content.userId
}
});
if (content?.user?.id) {
this.$emit('USER', {
json: content.user,
params: {
userId: content.userId
}
});
}
this.$emit('FRIEND:STATE', {
json: {
state: 'active'
Expand All @@ -4762,6 +4764,8 @@ speechSynthesis.getVoices();
break;

case 'friend-update':
// is this used anymore?
console.error('friend-update', content);
this.$emit('USER', {
json: content.user,
params: {
Expand All @@ -4771,36 +4775,32 @@ speechSynthesis.getVoices();
break;

case 'friend-location':
if (
content.location !== 'private' &&
content.location !== 'traveling'
) {
this.$emit('WORLD', {
json: content.world,
params: {
worldId: content.world.id
}
});
}
if (content.userId === this.currentUser.id) {
this.$emit('USER', {
json: content.user,
params: {
userId: content.userId
}
});
} else {
this.$emit('USER', {
json: {
location: content.location,
travelingToLocation: content.travelingToLocation,
...content.user
},
params: {
userId: content.userId
}
});
if (!content?.user?.id) {
var ref = this.cachedUsers.get(content.userId);
if (typeof ref !== 'undefined') {
this.$emit('USER', {
json: {
...ref,
location: content.location,
travelingToLocation: content.travelingToLocation
},
params: {
userId: content.userId
}
});
}
break;
}
this.$emit('USER', {
json: {
location: content.location,
travelingToLocation: content.travelingToLocation,
...content.user
},
params: {
userId: content.userId
}
});
break;

case 'user-update':
Expand Down Expand Up @@ -10997,20 +10997,25 @@ speechSynthesis.getVoices();
case 71:
// Spawn Emoji
var photonId = data.Parameters[254];
if (photonId === this.photonLobbyCurrentUser) {
return;
}
var type = data.Parameters[245][0];
var emojiName = '';
var imageUrl = '';
if (type === 0) {
var emojiId = data.Parameters[245][2];
emojiName = this.photonEmojis[emojiId];
} else if (type === 1) {
// file_id
emojiName = data.Parameters[245][1];
imageUrl = `https://api.vrchat.cloud/api/1/file/${emojiName}/1/`;
}
this.addEntryPhotonEvent({
photonId,
text: emojiName,
type: 'SpawnEmoji',
created_at: gameLogDate
created_at: gameLogDate,
imageUrl
});
break;
}
Expand Down Expand Up @@ -25892,13 +25897,12 @@ speechSynthesis.getVoices();
fetchedAt: args.json.fetchedAt
}
});
this.$emit('WORLD', {
json: json.world,
params: {
worldId: json.world.id
}
this.getCachedWorld({
worldId: json.world.id
}).then((args1) => {
json.world = args1.ref;
return args1;
});
json.world = this.applyWorld(json.world);
}
});

Expand Down Expand Up @@ -25959,13 +25963,6 @@ speechSynthesis.getVoices();
fetchedAt: args.json.fetchedAt
}
});
this.$emit('WORLD', {
json: json.world,
params: {
worldId: json.world.id
}
});

var ref = this.cachedGroups.get(json.ownerId);
if (typeof ref === 'undefined') {
if ($app.friendLogInitStatus) {
Expand Down
3 changes: 1 addition & 2 deletions html/src/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ html
el-tooltip(placement="top" :content="$t('dialog.user.info.refresh_instance_info')" :disabled="hideTooltips")
el-button(@click="refreshInstancePlayerCount(userDialog.$location.tag)" size="mini" icon="el-icon-refresh" style="margin-left:5px" circle)
instance-info(:location="userDialog.$location.tag" :instance="userDialog.instance.ref" :friendcount="userDialog.instance.friendCount" :updateelement="updateInstanceInfo")
br
location(:location="userDialog.ref.location" :traveling="userDialog.ref.travelingToLocation" style="margin-top:5px")
location(:location="userDialog.ref.location" :traveling="userDialog.ref.travelingToLocation" style="display:block;margin-top:5px")
.x-friend-list(style="flex:1;margin-top:10px;max-height:150px")
.x-friend-item(v-if="userDialog.$location.userId" @click="showUserDialog(userDialog.$location.userId)" class="x-friend-item-border")
template(v-if="userDialog.$location.user")
Expand Down
22 changes: 11 additions & 11 deletions html/src/mixins/tabs/playerList.pug
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ mixin playerListTab()
i.el-icon-right
el-tooltip(placement="top")
template(#content)
span(v-if="scope.row.status === 'active'") Active
span(v-else-if="scope.row.status === 'join me'") Join Me
span(v-else-if="scope.row.status === 'ask me'") Ask Me
span(v-else-if="scope.row.status === 'busy'") Do Not Disturb
span(v-else) Offline
span(v-if="scope.row.status === 'active'") {{ $t('dialog.user.status.active') }}
span(v-else-if="scope.row.status === 'join me'") {{ $t('dialog.user.status.join_me') }}
span(v-else-if="scope.row.status === 'ask me'") {{ $t('dialog.user.status.ask_me') }}
span(v-else-if="scope.row.status === 'busy'") {{ $t('dialog.user.status.busy') }}
span(v-else) {{ $t('dialog.user.status.offline') }}
i.x-user-status(:class="statusClass(scope.row.status)" style="margin-right:5px")
span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription")
template(v-else-if="scope.row.type === 'ChangeGroup'")
Expand Down Expand Up @@ -136,8 +136,8 @@ mixin playerListTab()
span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)")
|  
span(v-if="!scope.row.inCache" style="color:#aaa") #[i.el-icon-download] 
span.avatar-info-public(v-if="scope.row.avatar.releaseStatus === 'public'") (Public)
span.avatar-info-own(v-else-if="scope.row.avatar.releaseStatus === 'private'") (Private)
span.avatar-info-public(v-if="scope.row.avatar.releaseStatus === 'public'") {{ $t('dialog.avatar.labels.public') }}
span.avatar-info-own(v-else-if="scope.row.avatar.releaseStatus === 'private'") {{ $t('dialog.avatar.labels.private') }}
template(v-if="scope.row.avatar.description && scope.row.avatar.name !== scope.row.avatar.description")
| - {{ scope.row.avatar.description }}
template(v-else-if="scope.row.type === 'ChangeStatus'")
Expand All @@ -159,8 +159,8 @@ mixin playerListTab()
span(v-else-if="scope.row.status === 'ask me'") {{ $t('dialog.user.status.ask_me') }}
span(v-else-if="scope.row.status === 'busy'") {{ $t('dialog.user.status.busy') }}
span(v-else) {{ $t('dialog.user.status.offline') }}
i.x-user-status(:class="statusClass(scope.row.status)")
span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription" style="margin-left:5px")
i.x-user-status(:class="statusClass(scope.row.status)" style="margin-right:5px")
span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription")
template(v-else-if="scope.row.type === 'ChangeGroup'")
span.x-link(v-if="scope.row.previousGroupName" v-text="scope.row.previousGroupName" @click="showGroupDialog(scope.row.previousGroupId)" style="margin-right:5px")
span.x-link(v-else v-text="scope.row.previousGroupId" @click="showGroupDialog(scope.row.previousGroupId)" style="margin-right:5px")
Expand All @@ -178,8 +178,8 @@ mixin playerListTab()
span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)")
|  
span(v-if="!scope.row.inCache" style="color:#aaa") #[i.el-icon-download] 
span.avatar-info-public(v-if="scope.row.avatar.releaseStatus === 'public'") (Public)
span.avatar-info-own(v-else-if="scope.row.avatar.releaseStatus === 'private'") (Private)
span.avatar-info-public(v-if="scope.row.avatar.releaseStatus === 'public'") {{ $t('dialog.avatar.labels.public') }}
span.avatar-info-own(v-else-if="scope.row.avatar.releaseStatus === 'private'") {{ $t('dialog.avatar.labels.private') }}
span(v-else-if="scope.row.color === 'yellow'" v-text="scope.row.text" style="color:yellow")
span(v-else v-text="scope.row.text")
div.current-instance-table
Expand Down

0 comments on commit 35ae13c

Please sign in to comment.