mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-20 23:33:50 +02:00
Move isRealInstance
This commit is contained in:
78
src/app.js
78
src/app.js
@@ -488,12 +488,12 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
|
|
||||||
API.applyPresenceLocation = function (ref) {
|
API.applyPresenceLocation = function (ref) {
|
||||||
var presence = ref.presence;
|
var presence = ref.presence;
|
||||||
if ($app.isRealInstance(presence.world)) {
|
if ($utils.isRealInstance(presence.world)) {
|
||||||
ref.$locationTag = `${presence.world}:${presence.instance}`;
|
ref.$locationTag = `${presence.world}:${presence.instance}`;
|
||||||
} else {
|
} else {
|
||||||
ref.$locationTag = presence.world;
|
ref.$locationTag = presence.world;
|
||||||
}
|
}
|
||||||
if ($app.isRealInstance(presence.travelingToWorld)) {
|
if ($utils.isRealInstance(presence.travelingToWorld)) {
|
||||||
ref.$travelingToLocation = `${presence.travelingToWorld}:${presence.travelingToInstance}`;
|
ref.$travelingToLocation = `${presence.travelingToWorld}:${presence.travelingToInstance}`;
|
||||||
} else {
|
} else {
|
||||||
ref.$travelingToLocation = presence.travelingToWorld;
|
ref.$travelingToLocation = presence.travelingToWorld;
|
||||||
@@ -976,13 +976,13 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
userLocation
|
userLocation
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($app.isRealInstance(userLocation)) {
|
if ($utils.isRealInstance(userLocation)) {
|
||||||
console.warn('PWI: returning user location', userLocation);
|
console.warn('PWI: returning user location', userLocation);
|
||||||
const L = $utils.parseLocation(userLocation);
|
const L = $utils.parseLocation(userLocation);
|
||||||
return L.worldId;
|
return L.worldId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($app.isRealInstance(gameLogLocation)) {
|
if ($utils.isRealInstance(gameLogLocation)) {
|
||||||
console.warn(`PWI: returning gamelog location: `, gameLogLocation);
|
console.warn(`PWI: returning gamelog location: `, gameLogLocation);
|
||||||
const L = $utils.parseLocation(gameLogLocation);
|
const L = $utils.parseLocation(gameLogLocation);
|
||||||
return L.worldId;
|
return L.worldId;
|
||||||
@@ -4579,7 +4579,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
fromGetCurrentUser &&
|
fromGetCurrentUser &&
|
||||||
ctx.state !== 'online' &&
|
ctx.state !== 'online' &&
|
||||||
typeof ref !== 'undefined' &&
|
typeof ref !== 'undefined' &&
|
||||||
this.isRealInstance(ref.location)
|
$utils.isRealInstance(ref.location)
|
||||||
) {
|
) {
|
||||||
if (this.debugFriendState) {
|
if (this.debugFriendState) {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -4783,17 +4783,15 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
|
|
||||||
$app.methods.getWorldName = async function (location) {
|
$app.methods.getWorldName = async function (location) {
|
||||||
var worldName = '';
|
var worldName = '';
|
||||||
if (this.isRealInstance(location)) {
|
try {
|
||||||
try {
|
var L = $utils.parseLocation(location);
|
||||||
var L = $utils.parseLocation(location);
|
if (L.isRealInstance && L.worldId) {
|
||||||
if (L.worldId) {
|
var args = await API.getCachedWorld({
|
||||||
var args = await API.getCachedWorld({
|
worldId: L.worldId
|
||||||
worldId: L.worldId
|
});
|
||||||
});
|
worldName = args.ref.name;
|
||||||
worldName = args.ref.name;
|
}
|
||||||
}
|
} catch (err) {}
|
||||||
} catch (err) {}
|
|
||||||
}
|
|
||||||
return worldName;
|
return worldName;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -10178,7 +10176,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var L = $utils.parseLocation(D.ref.$location.tag);
|
var L = $utils.parseLocation(D.ref.$location.tag);
|
||||||
if (updateInstanceOccupants && this.isRealInstance(L.tag)) {
|
if (updateInstanceOccupants && L.isRealInstance) {
|
||||||
API.getInstance({
|
API.getInstance({
|
||||||
worldId: L.worldId,
|
worldId: L.worldId,
|
||||||
instanceId: L.instanceId
|
instanceId: L.instanceId
|
||||||
@@ -10278,7 +10276,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
ref: {}
|
ref: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!this.isRealInstance(L.tag)) {
|
if (!L.isRealInstance) {
|
||||||
D.instance = {
|
D.instance = {
|
||||||
id: L.instanceId,
|
id: L.instanceId,
|
||||||
tag: L.tag,
|
tag: L.tag,
|
||||||
@@ -10597,7 +10595,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.isRealInstance(instanceId)) {
|
if ($utils.isRealInstance(instanceId)) {
|
||||||
var ref = API.cachedInstances.get(instanceId);
|
var ref = API.cachedInstances.get(instanceId);
|
||||||
if (typeof ref !== 'undefined') {
|
if (typeof ref !== 'undefined') {
|
||||||
this.currentInstanceWorld.instance = ref;
|
this.currentInstanceWorld.instance = ref;
|
||||||
@@ -11319,7 +11317,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
D.stickersDisabled = ref.tags?.includes('feature_stickers_disabled');
|
D.stickersDisabled = ref.tags?.includes('feature_stickers_disabled');
|
||||||
$app.applyWorldDialogInstances();
|
$app.applyWorldDialogInstances();
|
||||||
for (var room of D.rooms) {
|
for (var room of D.rooms) {
|
||||||
if ($app.isRealInstance(room.tag)) {
|
if ($utils.isRealInstance(room.tag)) {
|
||||||
API.getInstance({
|
API.getInstance({
|
||||||
worldId: D.id,
|
worldId: D.id,
|
||||||
instanceId: room.id
|
instanceId: room.id
|
||||||
@@ -11861,7 +11859,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
var ref = API.cachedInstances.get(room.tag);
|
var ref = API.cachedInstances.get(room.tag);
|
||||||
if (typeof ref !== 'undefined') {
|
if (typeof ref !== 'undefined') {
|
||||||
room.ref = ref;
|
room.ref = ref;
|
||||||
} else if ($app.isRealInstance(room.tag)) {
|
} else if ($utils.isRealInstance(room.tag)) {
|
||||||
API.getInstance({
|
API.getInstance({
|
||||||
worldId: room.$location.worldId,
|
worldId: room.$location.worldId,
|
||||||
instanceId: room.$location.instanceId
|
instanceId: room.$location.instanceId
|
||||||
@@ -12764,7 +12762,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.showInviteDialog = function (tag) {
|
$app.methods.showInviteDialog = function (tag) {
|
||||||
if (!this.isRealInstance(tag)) {
|
if (!$utils.isRealInstance(tag)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$nextTick(() => $app.adjustDialogZ(this.$refs.inviteDialog.$el));
|
this.$nextTick(() => $app.adjustDialogZ(this.$refs.inviteDialog.$el));
|
||||||
@@ -13176,10 +13174,10 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.selfInvite = function (location, shortName) {
|
$app.methods.selfInvite = function (location, shortName) {
|
||||||
if (!this.isRealInstance(location)) {
|
var L = $utils.parseLocation(location);
|
||||||
|
if (!L.isRealInstance) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var L = $utils.parseLocation(location);
|
|
||||||
API.selfInvite({
|
API.selfInvite({
|
||||||
instanceId: L.instanceId,
|
instanceId: L.instanceId,
|
||||||
worldId: L.worldId,
|
worldId: L.worldId,
|
||||||
@@ -13249,7 +13247,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.showNewInstanceDialog = async function (tag) {
|
$app.methods.showNewInstanceDialog = async function (tag) {
|
||||||
if (!this.isRealInstance(tag)) {
|
if (!$utils.isRealInstance(tag)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$nextTick(() =>
|
this.$nextTick(() =>
|
||||||
@@ -13872,7 +13870,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.showLaunchDialog = function (tag, shortName) {
|
$app.methods.showLaunchDialog = function (tag, shortName) {
|
||||||
if (!this.isRealInstance(tag)) {
|
if (!$utils.isRealInstance(tag)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.$nextTick(() => $app.adjustDialogZ(this.$refs.launchDialog.$el));
|
this.$nextTick(() => $app.adjustDialogZ(this.$refs.launchDialog.$el));
|
||||||
@@ -17358,7 +17356,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
}
|
}
|
||||||
var { location } = this.lastLocation;
|
var { location } = this.lastLocation;
|
||||||
AppApi.VrcClosedGracefully().then((result) => {
|
AppApi.VrcClosedGracefully().then((result) => {
|
||||||
if (result || !this.isRealInstance(location)) {
|
if (result || !$utils.isRealInstance(location)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// wait a bit for SteamVR to potentially close before deciding to relaunch
|
// wait a bit for SteamVR to potentially close before deciding to relaunch
|
||||||
@@ -19736,23 +19734,6 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.isRealInstance = function (instanceId) {
|
|
||||||
if (!instanceId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
switch (instanceId) {
|
|
||||||
case 'offline':
|
|
||||||
case 'offline:offline':
|
|
||||||
case 'private':
|
|
||||||
case 'private:private':
|
|
||||||
case 'traveling':
|
|
||||||
case 'traveling:traveling':
|
|
||||||
case instanceId.startsWith('local'):
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
$app.methods.onPlayerTraveling = function (ref) {
|
$app.methods.onPlayerTraveling = function (ref) {
|
||||||
if (
|
if (
|
||||||
!this.isGameRunning ||
|
!this.isGameRunning ||
|
||||||
@@ -19842,7 +19823,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
this.lastLocationDestination = '';
|
this.lastLocationDestination = '';
|
||||||
this.lastLocationDestinationTime = 0;
|
this.lastLocationDestinationTime = 0;
|
||||||
|
|
||||||
if (this.isRealInstance(location)) {
|
if ($utils.isRealInstance(location)) {
|
||||||
var dt = new Date().toJSON();
|
var dt = new Date().toJSON();
|
||||||
var L = $utils.parseLocation(location);
|
var L = $utils.parseLocation(location);
|
||||||
|
|
||||||
@@ -23171,11 +23152,10 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
$app.computed.friendsInSameInstance = function () {
|
$app.computed.friendsInSameInstance = function () {
|
||||||
const friendsList = {};
|
const friendsList = {};
|
||||||
|
|
||||||
const allFriends = [...this.vipFriends, ...this.onlineFriends];
|
this.friends.forEach((friend) => {
|
||||||
|
if (!friend.ref?.$location.isRealInstance) return;
|
||||||
|
|
||||||
allFriends.forEach((friend) => {
|
const key = friend.ref.$location.tag;
|
||||||
const key = friend.ref?.$location.tag;
|
|
||||||
if (!key || key === 'private' || key === 'offline') return;
|
|
||||||
if (!friendsList[key]) {
|
if (!friendsList[key]) {
|
||||||
friendsList[key] = [];
|
friendsList[key] = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export default class extends baseClass {
|
|||||||
var travelingToWorld = $travelingLocation.worldId;
|
var travelingToWorld = $travelingLocation.worldId;
|
||||||
var travelingToInstance = $travelingLocation.instanceId;
|
var travelingToInstance = $travelingLocation.instanceId;
|
||||||
if (!$app.isGameRunning && json.presence) {
|
if (!$app.isGameRunning && json.presence) {
|
||||||
if ($app.isRealInstance(json.presence.world)) {
|
if ($utils.isRealInstance(json.presence.world)) {
|
||||||
location = `${json.presence.world}:${json.presence.instance}`;
|
location = `${json.presence.world}:${json.presence.instance}`;
|
||||||
travelingToLocation = `${json.presence.travelingToWorld}:${json.presence.travelingToInstance}`;
|
travelingToLocation = `${json.presence.travelingToWorld}:${json.presence.travelingToInstance}`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -84,6 +84,23 @@ export default {
|
|||||||
return s.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
|
return s.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isRealInstance(instanceId) {
|
||||||
|
if (!instanceId) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (instanceId) {
|
||||||
|
case 'offline':
|
||||||
|
case 'offline:offline':
|
||||||
|
case 'private':
|
||||||
|
case 'private:private':
|
||||||
|
case 'traveling':
|
||||||
|
case 'traveling:traveling':
|
||||||
|
case instanceId.startsWith('local'):
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
parseLocation(tag) {
|
parseLocation(tag) {
|
||||||
var _tag = String(tag || '');
|
var _tag = String(tag || '');
|
||||||
var ctx = {
|
var ctx = {
|
||||||
@@ -91,6 +108,7 @@ export default {
|
|||||||
isOffline: false,
|
isOffline: false,
|
||||||
isPrivate: false,
|
isPrivate: false,
|
||||||
isTraveling: false,
|
isTraveling: false,
|
||||||
|
isRealInstance: false,
|
||||||
worldId: '',
|
worldId: '',
|
||||||
instanceId: '',
|
instanceId: '',
|
||||||
instanceName: '',
|
instanceName: '',
|
||||||
@@ -114,7 +132,8 @@ export default {
|
|||||||
ctx.isPrivate = true;
|
ctx.isPrivate = true;
|
||||||
} else if (_tag === 'traveling' || _tag === 'traveling:traveling') {
|
} else if (_tag === 'traveling' || _tag === 'traveling:traveling') {
|
||||||
ctx.isTraveling = true;
|
ctx.isTraveling = true;
|
||||||
} else if (_tag.startsWith('local') === false) {
|
} else if (!_tag.startsWith('local')) {
|
||||||
|
ctx.isRealInstance = true;
|
||||||
var sep = _tag.indexOf(':');
|
var sep = _tag.indexOf(':');
|
||||||
// technically not part of instance id, but might be there when coping id from url so why not support it
|
// technically not part of instance id, but might be there when coping id from url so why not support it
|
||||||
var shortNameQualifier = '&shortName=';
|
var shortNameQualifier = '&shortName=';
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ mixin friendsListSidebar
|
|||||||
i.el-icon-arrow-right(:class='{ rotate: isSidebarGroupByInstanceCollapsed }')
|
i.el-icon-arrow-right(:class='{ rotate: isSidebarGroupByInstanceCollapsed }')
|
||||||
span(style='margin-left: 5px') {{ $t('side_panel.same_instance') }} ― {{ friendsInSameInstance.length }}
|
span(style='margin-left: 5px') {{ $t('side_panel.same_instance') }} ― {{ friendsInSameInstance.length }}
|
||||||
div(v-show='!isSidebarGroupByInstanceCollapsed')
|
div(v-show='!isSidebarGroupByInstanceCollapsed')
|
||||||
div(v-for='friendArr in friendsInSameInstance' :key='friendArr[0].ref?.location.tag')
|
div(v-for='friendArr in friendsInSameInstance' :key='friendArr[0].ref?.$location.tag')
|
||||||
div(style='margin-bottom: 3px')
|
div(style='margin-bottom: 3px')
|
||||||
location.extra(:location='getFriendsLocations(friendArr)' style='color: #c7c7c7')
|
location.extra(:location='getFriendsLocations(friendArr)' style='color: #c7c7c7')
|
||||||
span(style='margin-left: 5px') {{ `(${friendArr.length})` }}
|
span(style='margin-left: 5px') {{ `(${friendArr.length})` }}
|
||||||
|
|||||||
Reference in New Issue
Block a user