diff --git a/html/src/app.dark.scss b/html/src/app.dark.scss index 8f225267..6e9f01d1 100644 --- a/html/src/app.dark.scss +++ b/html/src/app.dark.scss @@ -44,7 +44,8 @@ button { border: #333; } -.el-input-group__append, .el-input-group__prepend { +.el-input-group__append, +.el-input-group__prepend { color: #fff; background-color: #666; border: #555; @@ -157,11 +158,11 @@ button { background-color: #444; } -.el-popper[x-placement^="bottom"] .popper__arrow::after { +.el-popper[x-placement^='bottom'] .popper__arrow::after { border-bottom-color: #333; } -.el-popper[x-placement^="bottom"] .popper__arrow { +.el-popper[x-placement^='bottom'] .popper__arrow { border-bottom-color: #404040; } @@ -230,11 +231,11 @@ button { border-color: #5f5f5f; } -.el-popper[x-placement^="right"] .popper__arrow::after { +.el-popper[x-placement^='right'] .popper__arrow::after { border-right-color: #5f5f5f; } -.el-popper[x-placement^="right"] .popper__arrow { +.el-popper[x-placement^='right'] .popper__arrow { border-right-color: #5f5f5f; } diff --git a/html/src/app.js b/html/src/app.js index ea2a48e6..52364baa 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -7,16 +7,14 @@ import Noty from 'noty'; import Vue from 'vue'; import VueLazyload from 'vue-lazyload'; -import { DataTables } from 'vue-data-tables'; -// eslint-disable-next-line no-unused-vars +import {DataTables} from 'vue-data-tables'; import VSwatches from 'vue-swatches'; Vue.component('v-swatches', VSwatches); -import '../node_modules/vue-swatches/dist/vue-swatches.css'; import ElementUI from 'element-ui'; import locale from 'element-ui/lib/locale/lang/en'; -import { v4 as uuidv4 } from 'uuid'; +import {v4 as uuidv4} from 'uuid'; -import { appVersion } from './constants.js'; +import {appVersion} from './constants.js'; import sharedRepository from './repository/shared.js'; import configRepository from './repository/config.js'; import webApiService from './service/webapi.js'; @@ -130,7 +128,7 @@ speechSynthesis.getVoices(); }); var removeFromArray = function (array, item) { - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (array[i] === item) { array.splice(i, 1); @@ -159,26 +157,28 @@ speechSynthesis.getVoices(); } var hours = dt.getHours(); var map = { - 'YYYY': String(10000 + dt.getFullYear()).substr(-4), - 'MM': String(101 + dt.getMonth()).substr(-2), - 'DD': String(100 + dt.getDate()).substr(-2), - 'HH24': String(100 + hours).substr(-2), - 'HH': String(100 + (hours > 12 - ? hours - 12 - : hours)).substr(-2), - 'MI': String(100 + dt.getMinutes()).substr(-2), - 'SS': String(100 + dt.getSeconds()).substr(-2), - 'AMPM': hours >= 12 - ? 'PM' - : 'AM' + YYYY: String(10000 + dt.getFullYear()).substr(-4), + MM: String(101 + dt.getMonth()).substr(-2), + DD: String(100 + dt.getDate()).substr(-2), + HH24: String(100 + hours).substr(-2), + HH: String(100 + (hours > 12 ? hours - 12 : hours)).substr(-2), + MI: String(100 + dt.getMinutes()).substr(-2), + SS: String(100 + dt.getSeconds()).substr(-2), + AMPM: hours >= 12 ? 'PM' : 'AM' }; - return format.replace(/YYYY|MM|DD|HH24|HH|MI|SS|AMPM/g, (c) => map[c] || c); + return format.replace( + /YYYY|MM|DD|HH24|HH|MI|SS|AMPM/g, + (c) => map[c] || c + ); }; Vue.filter('formatDate', formatDate); var textToHex = function (text) { var s = String(text); - return s.split('').map((c) => c.charCodeAt(0).toString(16)).join(' '); + return s + .split('') + .map((c) => c.charCodeAt(0).toString(16)) + .join(' '); }; Vue.filter('textToHex', textToHex); @@ -204,15 +204,13 @@ speechSynthesis.getVoices(); arr.push(`${Math.floor(n / 60)}m`); n %= 60; } - if (n || - arr.length === 0) { + if (n || arr.length === 0) { arr.push(`${n}s`); } return arr.join(' '); }; Vue.filter('timeToText', timeToText); - const loadimage = require('./blank.png'); Vue.use(VueLazyload, { preLoad: 1, observer: true, @@ -338,7 +336,7 @@ speechSynthesis.getVoices(); if (typeof handlers === 'undefined') { return; } - var { length } = handlers; + var {length} = handlers; for (var i = 0; i < length; ++i) { if (handlers[i] === handler) { if (length > 1) { @@ -360,20 +358,23 @@ speechSynthesis.getVoices(); method: 'GET', ...options }; - var { params } = init; + var {params} = init; if (init.method === 'GET') { // don't retry recent 404 if (this.failedGetRequests.has(endpoint)) { var lastRun = this.failedGetRequests.get(endpoint); - if (lastRun >= Date.now() - 900000) { //15mins - throw new Error(`Bailing request due to past 404, ${endpoint}`); + if (lastRun >= Date.now() - 900000) { + // 15mins + throw new Error( + `Bailing request due to past 404, ${endpoint}` + ); } this.failedGetRequests.delete(endpoint); } // transform body to url if (params === Object(params)) { var url = new URL(init.url); - var { searchParams } = url; + var {searchParams} = url; for (var key in params) { searchParams.set(key, params[key]); } @@ -385,78 +386,84 @@ speechSynthesis.getVoices(); return req; } } else if (init.uploadImage || init.uploadFilePUT) { + // nothing } else { init.headers = { 'Content-Type': 'application/json;charset=utf-8', ...init.headers }; - init.body = params === Object(params) - ? JSON.stringify(params) - : '{}'; + init.body = + params === Object(params) ? JSON.stringify(params) : '{}'; } init.headers = { 'User-Agent': appVersion, ...init.headers }; - var req = webApiService.execute(init).catch((err) => { - this.$throw(0, err); - }).then((response) => { - try { - response.data = JSON.parse(response.data); - if ($app.debugWebRequests) { - console.log(init, response.data); + var req = webApiService + .execute(init) + .catch((err) => { + this.$throw(0, err); + }) + .then((response) => { + try { + response.data = JSON.parse(response.data); + if ($app.debugWebRequests) { + console.log(init, response.data); + } + return response; + } catch (e) {} + if (response.status === 200) { + this.$throw(0, 'Invalid JSON response'); } - return response; - } catch (e) { - } - if (response.status === 200) { - this.$throw(0, 'Invalid JSON response'); - } - this.$throw(response.status, endpoint); - return {}; - }).then(({ data, status }) => { - if (status === 200) { - if (data.success === Object(data.success)) { - new Noty({ - type: 'success', - text: escapeTag(data.success.message) - }).show(); + this.$throw(response.status, endpoint); + return {}; + }) + .then(({data, status}) => { + if (status === 200) { + if (data.success === Object(data.success)) { + new Noty({ + type: 'success', + text: escapeTag(data.success.message) + }).show(); + } + return data; } + if ( + status === 401 && + data.error.message === '"Missing Credentials"' + ) { + if (endpoint.substring(0, 10) === 'auth/user?') { + this.$emit('AUTOLOGIN'); + } + throw new Error('401: Missing Credentials'); + } + if (status === 404 && endpoint.substring(0, 8) === 'avatars/') { + $app.$message({ + message: 'Avatar private or deleted', + type: 'error' + }); + $app.avatarDialog.visable = false; + throw new Error("404: Can't find avatarǃ"); + } + if (init.method === 'GET' && status === 404) { + this.failedGetRequests.set(endpoint, Date.now()); + } + if (data.error === Object(data.error)) { + this.$throw( + data.error.status_code || status, + data.error.message, + endpoint + ); + } else if (typeof data.error === 'string') { + this.$throw( + data.status_code || status, + data.error, + endpoint + ); + } + this.$throw(status, data); return data; - } - if ((status === 401) && (data.error.message === '"Missing Credentials"')) { - if (endpoint.substring(0, 10) === 'auth/user?') { - this.$emit('AUTOLOGIN'); - } - throw new Error('401: Missing Credentials'); - } - if ((status === 404) && (endpoint.substring(0, 8) === 'avatars/')) { - $app.$message({ - message: 'Avatar private or deleted', - type: 'error' - }); - $app.avatarDialog.visable = false; - throw new Error('404: Can\'t find avatarǃ'); - } - if ((init.method === 'GET') && (status === 404)) { - this.failedGetRequests.set(endpoint, Date.now()); - } - if (data.error === Object(data.error)) { - this.$throw( - data.error.status_code || status, - data.error.message, - endpoint - ); - } else if (typeof data.error === 'string') { - this.$throw( - data.status_code || status, - data.error, - endpoint - ); - } - this.$throw(status, data); - return data; - }); + }); if (init.method === 'GET') { req.finally(() => { this.pendingGetRequests.delete(init.url); @@ -575,14 +582,16 @@ speechSynthesis.getVoices(); if ('handle' in options) { options.handle.call(this, args, options); } - if (args.json.length > 0 && - (options.params.offset += args.json.length, - // eslint-disable-next-line no-nested-ternary - options.N > 0 - ? options.N > options.params.offset - : options.N < 0 - ? args.json.length - : options.params.n === args.json.length)) { + if ( + args.json.length > 0 && + ((options.params.offset += args.json.length), + // eslint-disable-next-line no-nested-ternary + options.N > 0 + ? options.N > options.params.offset + : options.N < 0 + ? args.json.length + : options.params.n === args.json.length) + ) { this.bulk(options); } else if ('done' in options) { options.done.call(this, true, options); @@ -591,12 +600,14 @@ speechSynthesis.getVoices(); }; API.bulk = function (options) { - this[options.fn](options.params).catch((err) => { - if ('done' in options) { - options.done.call(this, false, options); - } - throw err; - }).then((args) => this.$bulk(options, args)); + this[options.fn](options.params) + .catch((err) => { + if ('done' in options) { + options.done.call(this, false, options); + } + throw err; + }) + .then((args) => this.$bulk(options, args)); }; // API: Config @@ -631,9 +642,9 @@ speechSynthesis.getVoices(); // API: Location API.parseLocation = function (tag) { - tag = String(tag || ''); + var _tag = String(tag || ''); var ctx = { - tag, + tag: _tag, isOffline: false, isPrivate: false, worldId: '', @@ -647,27 +658,21 @@ speechSynthesis.getVoices(); friendsId: null, canRequestInvite: false }; - if (tag === 'offline') { + if (_tag === 'offline') { ctx.isOffline = true; - } else if (tag === 'private') { + } else if (_tag === 'private') { ctx.isPrivate = true; - } else if (tag.startsWith('local') === false) { - var sep = tag.indexOf(':'); + } else if (_tag.startsWith('local') === false) { + var sep = _tag.indexOf(':'); if (sep >= 0) { - ctx.worldId = tag.substr(0, sep); - ctx.instanceId = tag.substr(sep + 1); + ctx.worldId = _tag.substr(0, sep); + ctx.instanceId = _tag.substr(sep + 1); ctx.instanceId.split('~').forEach((s, i) => { if (i) { var A = s.indexOf('('); - var Z = A >= 0 - ? s.lastIndexOf(')') - : -1; - var key = Z >= 0 - ? s.substr(0, A) - : s; - var value = A < Z - ? s.substr(A + 1, Z - A - 1) - : ''; + var Z = A >= 0 ? s.lastIndexOf(')') : -1; + var key = Z >= 0 ? s.substr(0, A) : s; + var value = A < Z ? s.substr(A + 1, Z - A - 1) : ''; if (key === 'hidden') { ctx.hiddenId = value; } else if (key === 'private') { @@ -703,23 +708,23 @@ speechSynthesis.getVoices(); ctx.userId = ctx.hiddenId; } } else { - ctx.worldId = tag; + ctx.worldId = _tag; } } return ctx; }; Vue.component('launch', { - template: '', + template: + '', props: { location: String }, methods: { parse() { var L = API.parseLocation(this.location); - this.$el.style.display = L.isOffline || L.isPrivate - ? 'none' - : ''; + this.$el.style.display = + L.isOffline || L.isPrivate ? 'none' : ''; }, confirm() { API.$emit('SHOW_LAUNCH_DIALOG', this.location); @@ -736,27 +741,26 @@ speechSynthesis.getVoices(); }); Vue.component('invite-yourself', { - template: '', + template: + '', props: { location: String }, methods: { parse() { var L = API.parseLocation(this.location); - this.$el.style.display = L.isOffline || L.isPrivate - ? 'none' - : ''; + this.$el.style.display = + L.isOffline || L.isPrivate ? 'none' : ''; }, confirm() { var L = API.parseLocation(this.location); - if (L.isOffline || - L.isPrivate || - L.worldId === '') { + if (L.isOffline || L.isPrivate || L.worldId === '') { return; } if (API.currentUser.status === 'busy') { this.$message({ - message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', + message: + "You can't invite yourself in 'Do Not Disturb' mode", type: 'error' }); return; @@ -778,7 +782,8 @@ speechSynthesis.getVoices(); }); Vue.component('location', { - template: '{{ text }}', + template: + '{{ text }}', props: { location: String, hint: { @@ -832,7 +837,12 @@ speechSynthesis.getVoices(); } } this.region = ''; - if ((this.location !== '') && (L.instanceId) && (!L.isOffline) && (!L.isPrivate)) { + if ( + this.location !== '' && + L.instanceId && + !L.isOffline && + !L.isPrivate + ) { if (L.region === 'eu') { this.region = 'europeanunion'; } else if (L.region === 'jp') { @@ -859,7 +869,8 @@ speechSynthesis.getVoices(); }); Vue.component('avatar-info', { - template: '
{{ avatarName }}{{ avatarType }}
', + template: + '
{{ avatarName }}{{ avatarType }}
', props: { imageurl: String, userid: String, @@ -884,13 +895,14 @@ speechSynthesis.getVoices(); this.ownerId = this.hintownerid; } else { try { - var avatarInfo = await $app.getAvatarName(this.imageurl); + var avatarInfo = await $app.getAvatarName( + this.imageurl + ); this.avatarName = avatarInfo.avatarName; this.ownerId = avatarInfo.ownerId; - } catch (err) { - } + } catch (err) {} } - if ((typeof this.userid === 'undefined') || (!this.ownerId)) { + if (typeof this.userid === 'undefined' || !this.ownerId) { this.color = 'avatar-info-unknown'; this.avatarType = '(unknown)'; } else if (this.ownerId === this.userid) { @@ -951,7 +963,7 @@ speechSynthesis.getVoices(); }); API.$on('USER:CURRENT', function (args) { - var { json } = args; + var {json} = args; args.ref = this.applyCurrentUser(json); this.applyUser({ id: json.id, @@ -1012,7 +1024,7 @@ speechSynthesis.getVoices(); } */ API.login = function (params) { - var { username, password, saveCredentials, cipher } = params; + var {username, password, saveCredentials, cipher} = params; username = encodeURIComponent(username); password = encodeURIComponent(password); var auth = btoa(`${username}:${password}`); @@ -1050,10 +1062,13 @@ speechSynthesis.getVoices(); } */ API.loginWithSteam = function (params) { - return this.call(`auth/steam?apiKey=${this.cachedConfig.clientApiKey}`, { - method: 'POST', - params - }).then((json) => { + return this.call( + `auth/steam?apiKey=${this.cachedConfig.clientApiKey}`, + { + method: 'POST', + params + } + ).then((json) => { var args = { json, params, @@ -1107,15 +1122,16 @@ speechSynthesis.getVoices(); }; API.applyUserTrustLevel = function (ref) { - ref.$isModerator = ref.developerType && - ref.developerType !== 'none'; + ref.$isModerator = ref.developerType && ref.developerType !== 'none'; ref.$isTroll = false; - var { tags } = ref; + var {tags} = ref; if (tags.includes('admin_moderator')) { ref.$isModerator = true; } - if (tags.includes('system_troll') || - tags.includes('system_probable_troll')) { + if ( + tags.includes('system_troll') || + tags.includes('system_probable_troll') + ) { ref.$isTroll = true; } if (tags.includes('system_legend')) { @@ -1164,7 +1180,7 @@ speechSynthesis.getVoices(); // FIXME: it may performance issue. review here API.applyUserLanguage = function (ref) { ref.$languages = []; - var { tags } = ref; + var {tags} = ref; for (var tag of tags) { if (tag.startsWith('language_') === false) { continue; @@ -1273,7 +1289,7 @@ speechSynthesis.getVoices(); } userUpdateTimer = setTimeout(function () { userUpdateTimer = null; - var { length } = userUpdateQueue; + var {length} = userUpdateQueue; for (var i = 0; i < length; ++i) { API.$emit('USER:UPDATE', userUpdateQueue[i]); } @@ -1289,7 +1305,10 @@ speechSynthesis.getVoices(); json.statusDescription = API.currentUser.statusDescription; json.state = API.currentUser.state; json.last_login = API.currentUser.last_login; - if ((typeof json.location !== 'undefined') && (json.location === 'offline')) { + if ( + typeof json.location !== 'undefined' && + json.location === 'offline' + ) { json.location = ''; } if ($app.lastLocation.location) { @@ -1300,7 +1319,9 @@ speechSynthesis.getVoices(); json.$offline_for = API.currentUser.$offline_for; } if (typeof json.statusDescription !== 'undefined') { - json.statusDescription = $app.replaceBioSymbols(json.statusDescription); + json.statusDescription = $app.replaceBioSymbols( + json.statusDescription + ); } if (typeof json.bio !== 'undefined') { json.bio = $app.replaceBioSymbols(json.bio); @@ -1356,7 +1377,7 @@ speechSynthesis.getVoices(); props[prop] = true; } } - var $ref = { ...ref }; + var $ref = {...ref}; Object.assign(ref, json); if (ref.location !== ref.$location.tag) { ref.$location = this.parseLocation(ref.location); @@ -1377,16 +1398,12 @@ speechSynthesis.getVoices(); delete props[prop]; } else { has = true; - props[prop] = [ - tobe, - asis - ]; + props[prop] = [tobe, asis]; } } // FIXME // if the status is offline, just ignore status and statusDescription only. - if (has && - (ref.status !== 'offline' && $ref.status !== 'offline')) { + if (has && ref.status !== 'offline' && $ref.status !== 'offline') { if (props.location) { var ts = Date.now(); props.location.push(ts - ref.$location_at); @@ -1541,7 +1558,7 @@ speechSynthesis.getVoices(); }); API.$on('WORLD:DELETE', function (args) { - var { json } = args; + var {json} = args; this.cachedWorlds.delete(json.id); if ($app.worldDialog.ref.authorId === json.authorId) { var map = new Map(); @@ -1556,7 +1573,7 @@ speechSynthesis.getVoices(); }); API.$on('WORLD:SAVE', function (args) { - var { json } = args; + var {json} = args; this.$emit('WORLD', { json, params: { @@ -1747,9 +1764,12 @@ speechSynthesis.getVoices(); } */ API.selfInvite = function (params) { - return this.call(`instances/${params.worldId}:${params.instanceId}/invite`, { - method: 'POST' - }).then((json) => { + return this.call( + `instances/${params.worldId}:${params.instanceId}/invite`, + { + method: 'POST' + } + ).then((json) => { var args = { json, params @@ -1759,10 +1779,9 @@ speechSynthesis.getVoices(); }; API.$on('INSTANCE', function (args) { - var { json } = args; + var {json} = args; var D = $app.userDialog; - if (($app.userDialog.visible) && - (D.ref.location === json.id)) { + if ($app.userDialog.visible && D.ref.location === json.id) { D.instance = { id: json.id, occupants: json.n_users @@ -1771,10 +1790,9 @@ speechSynthesis.getVoices(); }); API.$on('INSTANCE', function (args) { - var { json } = args; + var {json} = args; var D = $app.worldDialog; - if (($app.worldDialog.visible) && - ($app.worldDialog.id === json.worldId)) { + if ($app.worldDialog.visible && $app.worldDialog.id === json.worldId) { for (var instance of D.rooms) { if (instance.id === json.instanceId) { instance.occupants = json.n_users; @@ -1815,7 +1833,9 @@ speechSynthesis.getVoices(); offset: 0, offline: false }; - var N = this.currentUser.onlineFriends.length + this.currentUser.activeFriends.length; + var N = + this.currentUser.onlineFriends.length + + this.currentUser.activeFriends.length; var count = Math.trunc(N / 50); for (var i = count; i > -1; i--) { var args = await this.getFriends(params); @@ -1832,7 +1852,9 @@ speechSynthesis.getVoices(); offset: 0, offline: true }; - var onlineCount = this.currentUser.onlineFriends.length + this.currentUser.activeFriends.length; + var onlineCount = + this.currentUser.onlineFriends.length + + this.currentUser.activeFriends.length; var N = this.currentUser.friends.length - onlineCount; var count = Math.trunc(N / 50); for (var i = count; i > -1; i--) { @@ -1971,7 +1993,7 @@ speechSynthesis.getVoices(); }); API.$on('AVATAR:SAVE', function (args) { - var { json } = args; + var {json} = args; this.$emit('AVATAR', { json, params: { @@ -1985,7 +2007,7 @@ speechSynthesis.getVoices(); }); API.$on('AVATAR:DELETE', function (args) { - var { json } = args; + var {json} = args; this.cachedAvatars.delete(json._id); if ($app.userDialog.id === json.authorId) { var map = new Map(); @@ -2189,8 +2211,7 @@ speechSynthesis.getVoices(); API.$on('NOTIFICATION:ACCEPT', function (args) { var ref = this.cachedNotifications.get(args.params.notificationId); - if (typeof ref === 'undefined' || - ref.$isDeleted) { + if (typeof ref === 'undefined' || ref.$isDeleted) { return; } args.ref = ref; @@ -2210,8 +2231,7 @@ speechSynthesis.getVoices(); API.$on('NOTIFICATION:HIDE', function (args) { var ref = this.cachedNotifications.get(args.params.notificationId); - if (typeof ref === 'undefined' && - ref.$isDeleted) { + if (typeof ref === 'undefined' && ref.$isDeleted) { return; } args.ref = ref; @@ -2255,8 +2275,7 @@ speechSynthesis.getVoices(); if (object === Object(object)) { details = object; } - } catch (err) { - } + } catch (err) {} } ref.details = details; } @@ -2266,7 +2285,10 @@ speechSynthesis.getVoices(); API.expireNotifications = function () { for (var ref of this.cachedNotifications.values()) { ref.$isExpired = true; - if ((ref.type === 'friendRequest') || (ref.type === 'hiddenFriendRequest')) { + if ( + ref.type === 'friendRequest' || + ref.type === 'hiddenFriendRequest' + ) { this.cachedNotifications.delete(ref.id); } } @@ -2274,8 +2296,7 @@ speechSynthesis.getVoices(); API.deleteExpiredNotifcations = function () { for (var ref of this.cachedNotifications.values()) { - if (ref.$isDeleted || - ref.$isExpired === false) { + if (ref.$isDeleted || ref.$isExpired === false) { continue; } ref.$isDeleted = true; @@ -2295,7 +2316,7 @@ speechSynthesis.getVoices(); n: 100, offset: 0 }; - var count = 50; //5000 max + var count = 50; // 5000 max for (var i = 0; i < count; i++) { var args = await this.getNotifications(params); $app.unseenNotifications = []; @@ -2308,7 +2329,7 @@ speechSynthesis.getVoices(); n: 100, offset: 0 }; - var count = 50; //5000 max + var count = 50; // 5000 max for (var i = 0; i < count; i++) { var args = await this.getHiddenFriendRequests(params); $app.unseenNotifications = []; @@ -2484,9 +2505,12 @@ speechSynthesis.getVoices(); } */ API.acceptNotification = function (params) { - return this.call(`auth/user/notifications/${params.notificationId}/accept`, { - method: 'PUT' - }).then((json) => { + return this.call( + `auth/user/notifications/${params.notificationId}/accept`, + { + method: 'PUT' + } + ).then((json) => { var args = { json, params @@ -2502,9 +2526,12 @@ speechSynthesis.getVoices(); } */ API.hideNotification = function (params) { - return this.call(`auth/user/notifications/${params.notificationId}/hide`, { - method: 'PUT' - }).then((json) => { + return this.call( + `auth/user/notifications/${params.notificationId}/hide`, + { + method: 'PUT' + } + ).then((json) => { var args = { json, params @@ -2516,9 +2543,11 @@ speechSynthesis.getVoices(); API.getFriendRequest = function (userId) { for (var ref of this.cachedNotifications.values()) { - if (ref.$isDeleted === false && + if ( + ref.$isDeleted === false && ref.type === 'friendRequest' && - ref.senderUserId === userId) { + ref.senderUserId === userId + ) { return ref.id; } } @@ -2563,13 +2592,15 @@ speechSynthesis.getVoices(); }); API.$on('PLAYER-MODERATION:DELETE', function (args) { - var { type, moderated } = args.params; + var {type, moderated} = args.params; var userId = this.currentUser.id; for (var ref of this.cachedPlayerModerations.values()) { - if (ref.$isDeleted === false && + if ( + ref.$isDeleted === false && ref.type === type && ref.targetUserId === moderated && - ref.sourceUserId === userId) { + ref.sourceUserId === userId + ) { ref.$isDeleted = true; this.$emit('PLAYER-MODERATION:@DELETE', { ref, @@ -2614,8 +2645,7 @@ speechSynthesis.getVoices(); API.deleteExpiredPlayerModerations = function () { for (var ref of this.cachedPlayerModerations.values()) { - if (ref.$isDeleted || - ref.$isExpired === false) { + if (ref.$isDeleted || ref.$isExpired === false) { continue; } ref.$isDeleted = true; @@ -2635,13 +2665,15 @@ speechSynthesis.getVoices(); this.isPlayerModerationsLoading = true; this.expirePlayerModerations(); Promise.all([ - this.getPlayerModerations(), - //this.getPlayerModerationsAgainstMe(); - ]).finally(() => { - this.isPlayerModerationsLoading = false; - }).then(() => { - this.deleteExpiredPlayerModerations(); - }); + this.getPlayerModerations() + // this.getPlayerModerationsAgainstMe(); + ]) + .finally(() => { + this.isPlayerModerationsLoading = false; + }) + .then(() => { + this.deleteExpiredPlayerModerations(); + }); }; API.getPlayerModerations = function () { @@ -2744,7 +2776,7 @@ speechSynthesis.getVoices(); }); API.$on('FAVORITE:@DELETE', function (args) { - var { ref } = args; + var {ref} = args; if (ref.$groupRef !== null) { --ref.$groupRef.count; } @@ -2771,7 +2803,10 @@ speechSynthesis.getVoices(); }); API.$on('FAVORITE:ADD', function (args) { - if ((args.params.type === 'avatar') && (!API.cachedAvatars.has(args.params.favoriteId))) { + if ( + args.params.type === 'avatar' && + !API.cachedAvatars.has(args.params.favoriteId) + ) { this.refreshFavoriteAvatars(args.params.tags); } }); @@ -2831,8 +2866,7 @@ speechSynthesis.getVoices(); API.$on('FAVORITE:GROUP:CLEAR', function (args) { var key = `${args.params.type}:${args.params.group}`; for (var ref of this.cachedFavorites.values()) { - if (ref.$isDeleted || - ref.$groupKey !== key) { + if (ref.$isDeleted || ref.$groupKey !== key) { continue; } this.cachedFavoritesByObjectId.delete(ref.favoriteId); @@ -2901,8 +2935,7 @@ speechSynthesis.getVoices(); ref.$isExpired = false; } ref.$groupKey = `${ref.type}:${String(ref.tags[0])}`; - if (ref.$isDeleted === false && - ref.$groupRef === null) { + if (ref.$isDeleted === false && ref.$groupRef === null) { var group = this.cachedFavoriteGroupsByTypeName.get(ref.$groupKey); if (typeof group !== 'undefined') { ref.$groupRef = group; @@ -2920,8 +2953,7 @@ speechSynthesis.getVoices(); API.deleteExpiredFavorites = function () { for (var ref of this.cachedFavorites.values()) { - if (ref.$isDeleted || - ref.$isExpired === false) { + if (ref.$isDeleted || ref.$isExpired === false) { continue; } ref.$isDeleted = true; @@ -2945,8 +2977,8 @@ speechSynthesis.getVoices(); API.refreshFavoriteItems = function () { var types = { - 'world': [0, 'getFavoriteWorlds'], - 'avatar': [0, 'getFavoriteAvatars'] + world: [0, 'getFavoriteWorlds'], + avatar: [0, 'getFavoriteAvatars'] }; var tags = []; for (var ref of this.cachedFavorites.values()) { @@ -2957,7 +2989,7 @@ speechSynthesis.getVoices(); if (typeof type === 'undefined') { continue; } - if ((ref.type === 'avatar') && (!tags.includes(ref.tags[0]))) { + if (ref.type === 'avatar' && !tags.includes(ref.tags[0])) { tags.push(ref.tags[0]); } ++type[0]; @@ -3096,9 +3128,9 @@ speechSynthesis.getVoices(); }); } var types = { - 'friend': this.favoriteFriendGroups, - 'world': this.favoriteWorldGroups, - 'avatar': this.favoriteAvatarGroups + friend: this.favoriteFriendGroups, + world: this.favoriteWorldGroups, + avatar: this.favoriteAvatarGroups }; var assigns = new Set(); // assign the same name first @@ -3111,8 +3143,7 @@ speechSynthesis.getVoices(); continue; } for (var group of groups) { - if (group.assign === false && - group.name === ref.name) { + if (group.assign === false && group.name === ref.name) { group.assign = true; if (ref.type !== 'avatar') { group.displayName = ref.displayName; @@ -3131,8 +3162,7 @@ speechSynthesis.getVoices(); // used Map(), the order would be a mess. So we need something to solve // this. for (var ref of this.cachedFavoriteGroups.values()) { - if (ref.$isDeleted || - assigns.has(ref.id)) { + if (ref.$isDeleted || assigns.has(ref.id)) { continue; } var groups = types[ref.type]; @@ -3182,8 +3212,7 @@ speechSynthesis.getVoices(); API.deleteExpiredFavoriteGroups = function () { for (var ref of this.cachedFavoriteGroups.values()) { - if (ref.$isDeleted || - ref.$isExpired === false) { + if (ref.$isDeleted || ref.$isExpired === false) { continue; } ref.$isDeleted = true; @@ -3310,10 +3339,13 @@ speechSynthesis.getVoices(); } */ API.saveFavoriteGroup = function (params) { - return this.call(`favorite/group/${params.type}/${params.group}/${this.currentUser.id}`, { - method: 'PUT', - params - }).then((json) => { + return this.call( + `favorite/group/${params.type}/${params.group}/${this.currentUser.id}`, + { + method: 'PUT', + params + } + ).then((json) => { var args = { json, params @@ -3330,10 +3362,13 @@ speechSynthesis.getVoices(); } */ API.clearFavoriteGroup = function (params) { - return this.call(`favorite/group/${params.type}/${params.group}/${this.currentUser.id}`, { - method: 'DELETE', - params - }).then((json) => { + return this.call( + `favorite/group/${params.type}/${params.group}/${this.currentUser.id}`, + { + method: 'DELETE', + params + } + ).then((json) => { var args = { json, params @@ -3404,7 +3439,7 @@ speechSynthesis.getVoices(); }); API.$on('PIPELINE', function (args) { - var { type, content } = args.json; + var {type, content} = args.json; if (typeof content.user !== 'undefined') { delete content.user.state; } @@ -3578,9 +3613,6 @@ speechSynthesis.getVoices(); } }); break; - - default: - break; } }); @@ -3598,32 +3630,41 @@ speechSynthesis.getVoices(); API.connectWebSocket = function (token) { if (this.webSocket === null) { - var socket = new WebSocket(`wss://pipeline.vrchat.cloud/?auth=${token}`); + var socket = new WebSocket( + `wss://pipeline.vrchat.cloud/?auth=${token}` + ); socket.onclose = () => { if (this.webSocket === socket) { this.webSocket = null; } try { socket.close(); - } catch (err) { - } + } catch (err) {} }; socket.onerror = socket.onclose; - socket.onmessage = ({ data }) => { + socket.onmessage = ({data}) => { try { var json = JSON.parse(data); try { json.content = JSON.parse(json.content); - } catch (err) { - } + } catch (err) {} this.$emit('PIPELINE', { json }); - if (($app.debugWebSocket) && (json.content) && (this.cachedUsers.has(json.content.userId))) { + if ( + $app.debugWebSocket && + json.content && + this.cachedUsers.has(json.content.userId) + ) { var displayName = ''; var user = this.cachedUsers.get(json.content.userId); displayName = user.displayName; - console.log('WebSocket', json.type, displayName, json.content); + console.log( + 'WebSocket', + json.type, + displayName, + json.content + ); } } catch (err) { console.error(err); @@ -3641,8 +3682,7 @@ speechSynthesis.getVoices(); this.webSocket = null; try { socket.close(); - } catch (err) { - } + } catch (err) {} }; // API: Visit @@ -3663,16 +3703,12 @@ speechSynthesis.getVoices(); var extractFileId = (s) => { var match = String(s).match(/file_[0-9A-Za-z-]+/); - return match - ? match[0] - : ''; + return match ? match[0] : ''; }; var extractFileVersion = (s) => { var match = /(?:\/file_[0-9A-Za-z-]+\/)([0-9]+)/gi.exec(s); - return match - ? match[1] - : ''; + return match ? match[1] : ''; }; var buildTreeData = (json) => { @@ -3792,7 +3828,10 @@ speechSynthesis.getVoices(); }, methods: { update() { - var epoch = new Date(this.datetime).getTime() + (1000 * 60 * 60 * this.hours) - Date.now(); + var epoch = + new Date(this.datetime).getTime() + + 1000 * 60 * 60 * this.hours - + Date.now(); if (epoch >= 0) { this.text = timeToText(epoch); } else { @@ -3849,15 +3888,17 @@ speechSynthesis.getVoices(); this.$el.style.display = ''; if (!this.enablePrimaryPassword) { this.loginForm.loading = true; - API.getConfig().catch((err) => { - this.loginForm.loading = false; - throw err; - }).then((args) => { - API.getCurrentUser().finally(() => { + API.getConfig() + .catch((err) => { this.loginForm.loading = false; + throw err; + }) + .then((args) => { + API.getCurrentUser().finally(() => { + this.loginForm.loading = false; + }); + return args; }); - return args; - }); } else { this.loginForm.loading = false; } @@ -3891,7 +3932,7 @@ speechSynthesis.getVoices(); try { if (API.isLoggedIn === true) { if (--this.nextCurrentUserRefresh <= 0) { - this.nextCurrentUserRefresh = 60; // 30secs + this.nextCurrentUserRefresh = 60; // 30secs API.getCurrentUser().catch((err1) => { throw err1; }); @@ -3909,15 +3950,17 @@ speechSynthesis.getVoices(); this.checkForVRCXUpdate(); } } - AppApi.CheckGameRunning().then(([isGameRunning, isGameNoVR]) => { - if (isGameRunning !== this.isGameRunning) { - this.isGameRunning = isGameRunning; - Discord.SetTimestamps(Date.now(), 0); + AppApi.CheckGameRunning().then( + ([isGameRunning, isGameNoVR]) => { + if (isGameRunning !== this.isGameRunning) { + this.isGameRunning = isGameRunning; + Discord.SetTimestamps(Date.now(), 0); + } + this.isGameNoVR = isGameNoVR; + this.updateDiscord(); + this.updateOpenVR(); } - this.isGameNoVR = isGameNoVR; - this.updateDiscord(); - this.updateOpenVR(); - }); + ); } } catch (err) { console.error(err); @@ -3958,7 +4001,7 @@ speechSynthesis.getVoices(); $app.data.appInit = false; $app.data.notyInit = false; - API.$on('LOGIN', function (args) { + API.$on('LOGIN', function () { sharedRepository.setArray('wristFeed', []); sharedRepository.setArray('notyFeed', []); setTimeout(function () { @@ -3982,24 +4025,43 @@ speechSynthesis.getVoices(); return; } var wristFeed = []; - wristFeed = wristFeed.concat(feeds.gameLog.wrist, feeds.feedTable.wrist, feeds.notificationTable.wrist, feeds.friendLogTable.wrist); + wristFeed = wristFeed.concat( + feeds.gameLog.wrist, + feeds.feedTable.wrist, + feeds.notificationTable.wrist, + feeds.friendLogTable.wrist + ); var notyFeed = []; - notyFeed = notyFeed.concat(feeds.gameLog.noty, feeds.feedTable.noty, feeds.notificationTable.noty, feeds.friendLogTable.noty); + notyFeed = notyFeed.concat( + feeds.gameLog.noty, + feeds.feedTable.noty, + feeds.notificationTable.noty, + feeds.friendLogTable.noty + ); // OnPlayerJoining - var L = API.parseLocation(this.lastLocation.location); //WebSocket dosen't update friend only instances - var locationBias = Date.now() - 30000; //30 seconds - if ((this.isGameRunning) && (L.accessType !== 'friends') && (this.lastLocation.date < locationBias) && - ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends') || (this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP') || - (this.sharedFeedFilters.noty.OnPlayerJoining === 'Friends') || (this.sharedFeedFilters.noty.OnPlayerJoining === 'VIP'))) { + var L = API.parseLocation(this.lastLocation.location); // WebSocket dosen't update friend only instances + var locationBias = Date.now() - 30000; // 30 seconds + if ( + this.isGameRunning && + L.accessType !== 'friends' && + this.lastLocation.date < locationBias && + (this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends' || + this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP' || + this.sharedFeedFilters.noty.OnPlayerJoining === 'Friends' || + this.sharedFeedFilters.noty.OnPlayerJoining === 'VIP') + ) { var joiningMap = []; - var bias = new Date(Date.now() - 120000).toJSON(); //2 minutes + var bias = new Date(Date.now() - 120000).toJSON(); // 2 minutes var feedTable = this.feedTable.data; for (var i = feedTable.length - 1; i > -1; i--) { var ctx = feedTable[i]; if (ctx.created_at < bias) { break; } - if ((ctx.type === 'GPS') && (ctx.location === this.lastLocation.location)) { + if ( + ctx.type === 'GPS' && + ctx.location === this.lastLocation.location + ) { if (joiningMap[ctx.displayName]) { continue; } @@ -4021,29 +4083,47 @@ speechSynthesis.getVoices(); if (gameLogItem.type === 'Notification') { continue; } - if ((gameLogItem.type === 'Location') || (gameLogItem.created_at < bias)) { + if ( + gameLogItem.type === 'Location' || + gameLogItem.created_at < bias + ) { break; } - if ((gameLogItem.type === 'OnPlayerJoined') && (gameLogItem.data === ctx.displayName)) { + if ( + gameLogItem.type === 'OnPlayerJoined' && + gameLogItem.data === ctx.displayName + ) { joining = false; break; } } if (joining) { var isFriend = this.friends.has(ctx.userId); - var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId); + var isFavorite = API.cachedFavoritesByObjectId.has( + ctx.userId + ); var onPlayerJoining = { ...ctx, isFriend, isFavorite, type: 'OnPlayerJoining' }; - if ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'Friends') || - ((this.sharedFeedFilters.wrist.OnPlayerJoining === 'VIP') && (isFavorite))) { + if ( + this.sharedFeedFilters.wrist.OnPlayerJoining === + 'Friends' || + (this.sharedFeedFilters.wrist.OnPlayerJoining === + 'VIP' && + isFavorite) + ) { wristFeed.unshift(onPlayerJoining); } - if ((this.sharedFeedFilters.noty.OnPlayerJoining === 'Friends') || - ((this.sharedFeedFilters.noty.OnPlayerJoining === 'VIP') && (isFavorite))) { + if ( + this.sharedFeedFilters.noty.OnPlayerJoining === + 'Friends' || + (this.sharedFeedFilters.noty.OnPlayerJoining === + 'VIP' && + isFavorite) + ) { notyFeed.unshift(onPlayerJoining); } } @@ -4084,18 +4164,21 @@ speechSynthesis.getVoices(); $app.methods.updateSharedFeedGameLog = function (forceUpdate) { // Location, OnPlayerJoined, OnPlayerLeft - var { data } = this.gameLogTable; + var {data} = this.gameLogTable; var i = data.length; if (i > 0) { - if ((data[i - 1].created_at === this.sharedFeed.gameLog.lastEntryDate) && - (forceUpdate === false)) { + if ( + data[i - 1].created_at === + this.sharedFeed.gameLog.lastEntryDate && + forceUpdate === false + ) { return; } this.sharedFeed.gameLog.lastEntryDate = data[i - 1].created_at; } else { return; } - var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours + var bias = new Date(Date.now() - 86400000).toJSON(); // 24 hours var wristArr = []; var notyArr = []; var w = 0; @@ -4115,7 +4198,7 @@ speechSynthesis.getVoices(); if (ctx.type === 'Notification') { continue; } - if ((playerCountIndex === 0) && (ctx.type === 'Location')) { + if (playerCountIndex === 0 && ctx.type === 'Location') { playerCountIndex = i; } // on Location change remove OnPlayerLeft @@ -4124,20 +4207,26 @@ speechSynthesis.getVoices(); continue; } if (ctx.data === API.currentUser.displayName) { - var { created_at } = ctx; + var {created_at} = ctx; currentUserLeaveTime = created_at.slice(0, -4); for (var k = w - 1; k > -1; k--) { var feedItem = wristArr[k]; - if ((feedItem.created_at.slice(0, -4) === currentUserLeaveTime) && - (feedItem.type === 'OnPlayerLeft')) { + if ( + feedItem.created_at.slice(0, -4) === + currentUserLeaveTime && + feedItem.type === 'OnPlayerLeft' + ) { wristArr.splice(k, 1); w--; } } for (var k = n - 1; k > -1; k--) { var feedItem = notyArr[k]; - if ((feedItem.created_at.slice(0, -4) === currentUserLeaveTime) && - (feedItem.type === 'OnPlayerLeft')) { + if ( + feedItem.created_at.slice(0, -4) === + currentUserLeaveTime && + feedItem.type === 'OnPlayerLeft' + ) { notyArr.splice(k, 1); n--; } @@ -4151,20 +4240,26 @@ speechSynthesis.getVoices(); continue; } if (ctx.data === API.currentUser.displayName) { - var { created_at } = ctx; + var {created_at} = ctx; currentUserJoinTime = created_at.slice(0, -4); for (var k = w - 1; k > -1; k--) { var feedItem = wristArr[k]; - if ((feedItem.created_at.slice(0, -4) === currentUserJoinTime) && - (feedItem.type === 'OnPlayerJoined')) { + if ( + feedItem.created_at.slice(0, -4) === + currentUserJoinTime && + feedItem.type === 'OnPlayerJoined' + ) { wristArr.splice(k, 1); w--; } } for (var k = n - 1; k > -1; k--) { var feedItem = notyArr[k]; - if ((feedItem.created_at.slice(0, -4) === currentUserJoinTime) && - (feedItem.type === 'OnPlayerJoined')) { + if ( + feedItem.created_at.slice(0, -4) === + currentUserJoinTime && + feedItem.type === 'OnPlayerJoined' + ) { notyArr.splice(k, 1); n--; } @@ -4173,17 +4268,21 @@ speechSynthesis.getVoices(); } } // remove current user - if (((ctx.type === 'OnPlayerJoined') || - (ctx.type === 'OnPlayerLeft') || - (ctx.type === 'PortalSpawn')) && - (ctx.data === API.currentUser.displayName)) { + if ( + (ctx.type === 'OnPlayerJoined' || + ctx.type === 'OnPlayerLeft' || + ctx.type === 'PortalSpawn') && + ctx.data === API.currentUser.displayName + ) { continue; } var isFriend = false; var isFavorite = false; - if ((ctx.type === 'OnPlayerJoined') || - (ctx.type === 'OnPlayerLeft') || - (ctx.type === 'PortalSpawn')) { + if ( + ctx.type === 'OnPlayerJoined' || + ctx.type === 'OnPlayerLeft' || + ctx.type === 'PortalSpawn' + ) { for (var ref of API.cachedUsers.values()) { if (ref.displayName === ctx.data) { isFriend = this.friends.has(ref.id); @@ -4192,9 +4291,8 @@ speechSynthesis.getVoices(); } } } - //BlockedOnPlayerJoined, BlockedOnPlayerLeft, MutedOnPlayerJoined, MutedOnPlayerLeft - if ((ctx.type === 'OnPlayerJoined') || - (ctx.type === 'OnPlayerLeft')) { + // BlockedOnPlayerJoined, BlockedOnPlayerLeft, MutedOnPlayerJoined, MutedOnPlayerLeft + if (ctx.type === 'OnPlayerJoined' || ctx.type === 'OnPlayerLeft') { for (var ref of this.playerModerationTable.data) { if (ref.targetDisplayName === ctx.data) { if (ref.type === 'block') { @@ -4207,10 +4305,12 @@ speechSynthesis.getVoices(); var displayName = ref.targetDisplayName; var userId = ref.targetUserId; var created_at = ctx.created_at; - if ((wristFilter[type]) && - ((wristFilter[type] === 'Everyone') || - ((wristFilter[type] === 'Friends') && (isFriend)) || - ((wristFilter[type] === 'VIP') && (isFavorite)))) { + if ( + wristFilter[type] && + (wristFilter[type] === 'Everyone' || + (wristFilter[type] === 'Friends' && isFriend) || + (wristFilter[type] === 'VIP' && isFavorite)) + ) { wristArr.unshift({ created_at, type, @@ -4220,10 +4320,12 @@ speechSynthesis.getVoices(); isFavorite }); } - if ((notyFilter[type]) && - ((notyFilter[type] === 'Everyone') || - ((notyFilter[type] === 'Friends') && (isFriend)) || - ((notyFilter[type] === 'VIP') && (isFavorite)))) { + if ( + notyFilter[type] && + (notyFilter[type] === 'Everyone' || + (notyFilter[type] === 'Friends' && isFriend) || + (notyFilter[type] === 'VIP' && isFavorite)) + ) { notyArr.unshift({ created_at, type, @@ -4236,11 +4338,14 @@ speechSynthesis.getVoices(); } } } - if ((w < 20) && (wristFilter[ctx.type]) && - ((wristFilter[ctx.type] === 'On') || - (wristFilter[ctx.type] === 'Everyone') || - ((wristFilter[ctx.type] === 'Friends') && (isFriend)) || - ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + w < 20 && + wristFilter[ctx.type] && + (wristFilter[ctx.type] === 'On' || + wristFilter[ctx.type] === 'Everyone' || + (wristFilter[ctx.type] === 'Friends' && isFriend) || + (wristFilter[ctx.type] === 'VIP' && isFavorite)) + ) { wristArr.push({ ...ctx, isFriend, @@ -4248,11 +4353,14 @@ speechSynthesis.getVoices(); }); ++w; } - if ((n < 1) && (notyFilter[ctx.type]) && - ((notyFilter[ctx.type] === 'On') || - (notyFilter[ctx.type] === 'Everyone') || - ((notyFilter[ctx.type] === 'Friends') && (isFriend)) || - ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + n < 1 && + notyFilter[ctx.type] && + (notyFilter[ctx.type] === 'On' || + notyFilter[ctx.type] === 'Everyone' || + (notyFilter[ctx.type] === 'Friends' && isFriend) || + (notyFilter[ctx.type] === 'VIP' && isFavorite)) + ) { notyArr.push({ ...ctx, isFriend, @@ -4303,18 +4411,21 @@ speechSynthesis.getVoices(); $app.methods.updateSharedFeedFeedTable = function (forceUpdate) { // GPS, Online, Offline, Status, Avatar - var { data } = this.feedTable; + var {data} = this.feedTable; var i = data.length; if (i > 0) { - if ((data[i - 1].created_at === this.sharedFeed.feedTable.lastEntryDate) && - (forceUpdate === false)) { + if ( + data[i - 1].created_at === + this.sharedFeed.feedTable.lastEntryDate && + forceUpdate === false + ) { return; } this.sharedFeed.feedTable.lastEntryDate = data[i - 1].created_at; } else { return; } - var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours + var bias = new Date(Date.now() - 86400000).toJSON(); // 24 hours var wristArr = []; var notyArr = []; var w = 0; @@ -4330,15 +4441,21 @@ speechSynthesis.getVoices(); continue; } // hide private worlds from feeds - if ((this.hidePrivateFromFeed) && - (ctx.type === 'GPS') && (ctx.location === 'private')) { + if ( + this.hidePrivateFromFeed && + ctx.type === 'GPS' && + ctx.location === 'private' + ) { continue; } var isFriend = this.friends.has(ctx.userId); var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId); - if ((w < 20) && (wristFilter[ctx.type]) && - ((wristFilter[ctx.type] === 'Friends') || - ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + w < 20 && + wristFilter[ctx.type] && + (wristFilter[ctx.type] === 'Friends' || + (wristFilter[ctx.type] === 'VIP' && isFavorite)) + ) { wristArr.push({ ...ctx, isFriend, @@ -4346,9 +4463,12 @@ speechSynthesis.getVoices(); }); ++w; } - if ((n < 1) && (notyFilter[ctx.type]) && - ((notyFilter[ctx.type] === 'Friends') || - ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + n < 1 && + notyFilter[ctx.type] && + (notyFilter[ctx.type] === 'Friends' || + (notyFilter[ctx.type] === 'VIP' && isFavorite)) + ) { notyArr.push({ ...ctx, isFriend, @@ -4364,18 +4484,22 @@ speechSynthesis.getVoices(); $app.methods.updateSharedFeedNotificationTable = function (forceUpdate) { // invite, requestInvite, requestInviteResponse, inviteResponse, friendRequest - var { data } = this.notificationTable; + var {data} = this.notificationTable; var i = data.length; if (i > 0) { - if ((data[i - 1].created_at === this.sharedFeed.notificationTable.lastEntryDate) && - (forceUpdate === false)) { + if ( + data[i - 1].created_at === + this.sharedFeed.notificationTable.lastEntryDate && + forceUpdate === false + ) { return; } - this.sharedFeed.notificationTable.lastEntryDate = data[i - 1].created_at; + this.sharedFeed.notificationTable.lastEntryDate = + data[i - 1].created_at; } else { return; } - var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours + var bias = new Date(Date.now() - 86400000).toJSON(); // 24 hours var wristArr = []; var notyArr = []; var w = 0; @@ -4391,11 +4515,16 @@ speechSynthesis.getVoices(); continue; } var isFriend = this.friends.has(ctx.senderUserId); - var isFavorite = API.cachedFavoritesByObjectId.has(ctx.senderUserId); - if ((w < 20) && (wristFilter[ctx.type]) && - ((wristFilter[ctx.type] === 'On') || - (wristFilter[ctx.type] === 'Friends') || - ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) { + var isFavorite = API.cachedFavoritesByObjectId.has( + ctx.senderUserId + ); + if ( + w < 20 && + wristFilter[ctx.type] && + (wristFilter[ctx.type] === 'On' || + wristFilter[ctx.type] === 'Friends' || + (wristFilter[ctx.type] === 'VIP' && isFavorite)) + ) { wristArr.push({ ...ctx, isFriend, @@ -4403,10 +4532,13 @@ speechSynthesis.getVoices(); }); ++w; } - if ((n < 1) && (notyFilter[ctx.type]) && - ((notyFilter[ctx.type] === 'On') || - (notyFilter[ctx.type] === 'Friends') || - ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + n < 1 && + notyFilter[ctx.type] && + (notyFilter[ctx.type] === 'On' || + notyFilter[ctx.type] === 'Friends' || + (notyFilter[ctx.type] === 'VIP' && isFavorite)) + ) { notyArr.push({ ...ctx, isFriend, @@ -4422,18 +4554,22 @@ speechSynthesis.getVoices(); $app.methods.updateSharedFeedFriendLogTable = function (forceUpdate) { // TrustLevel, Friend, FriendRequest, Unfriend, DisplayName - var { data } = this.friendLogTable; + var {data} = this.friendLogTable; var i = data.length; if (i > 0) { - if ((data[i - 1].created_at === this.sharedFeed.friendLogTable.lastEntryDate) && - (forceUpdate === false)) { + if ( + data[i - 1].created_at === + this.sharedFeed.friendLogTable.lastEntryDate && + forceUpdate === false + ) { return; } - this.sharedFeed.friendLogTable.lastEntryDate = data[i - 1].created_at; + this.sharedFeed.friendLogTable.lastEntryDate = + data[i - 1].created_at; } else { return; } - var bias = new Date(Date.now() - 86400000).toJSON(); //24 hours + var bias = new Date(Date.now() - 86400000).toJSON(); // 24 hours var wristArr = []; var notyArr = []; var w = 0; @@ -4450,10 +4586,13 @@ speechSynthesis.getVoices(); } var isFriend = this.friends.has(ctx.userId); var isFavorite = API.cachedFavoritesByObjectId.has(ctx.userId); - if ((w < 20) && (wristFilter[ctx.type]) && - ((wristFilter[ctx.type] === 'On') || - (wristFilter[ctx.type] === 'Friends') || - ((wristFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + w < 20 && + wristFilter[ctx.type] && + (wristFilter[ctx.type] === 'On' || + wristFilter[ctx.type] === 'Friends' || + (wristFilter[ctx.type] === 'VIP' && isFavorite)) + ) { wristArr.push({ ...ctx, isFriend, @@ -4461,10 +4600,13 @@ speechSynthesis.getVoices(); }); ++w; } - if ((n < 1) && (notyFilter[ctx.type]) && - ((notyFilter[ctx.type] === 'On') || - (notyFilter[ctx.type] === 'Friends') || - ((notyFilter[ctx.type] === 'VIP') && (isFavorite)))) { + if ( + n < 1 && + notyFilter[ctx.type] && + (notyFilter[ctx.type] === 'On' || + notyFilter[ctx.type] === 'Friends' || + (notyFilter[ctx.type] === 'VIP' && isFavorite)) + ) { notyArr.push({ ...ctx, isFriend, @@ -4482,25 +4624,32 @@ speechSynthesis.getVoices(); $app.methods.playNoty = function (notyFeed) { var playNotificationTTS = false; - if ((this.notificationTTS === 'Always') || - ((this.notificationTTS === 'Inside VR') && (!this.isGameNoVR) && (this.isGameRunning)) || - ((this.notificationTTS === 'Game Closed') && (!this.isGameRunning)) || - ((this.notificationTTS === 'Game Running') && (this.isGameRunning))) { + if ( + this.notificationTTS === 'Always' || + (this.notificationTTS === 'Inside VR' && + !this.isGameNoVR && + this.isGameRunning) || + (this.notificationTTS === 'Game Closed' && !this.isGameRunning) || + (this.notificationTTS === 'Game Running' && this.isGameRunning) + ) { playNotificationTTS = true; } var playDesktopToast = false; - if ((this.desktopToast === 'Always') || - ((this.desktopToast === 'Inside VR') && (!this.isGameNoVR) && (this.isGameRunning)) || - ((this.desktopToast === 'Game Closed') && (!this.isGameRunning)) || - ((this.desktopToast === 'Game Running') && (this.isGameRunning))) { + if ( + this.desktopToast === 'Always' || + (this.desktopToast === 'Inside VR' && + !this.isGameNoVR && + this.isGameRunning) || + (this.desktopToast === 'Game Closed' && !this.isGameRunning) || + (this.desktopToast === 'Game Running' && this.isGameRunning) + ) { playDesktopToast = true; } var playXSNotification = false; - if ((this.xsNotifications) && (this.isGameRunning) && (!this.isGameNoVR)) { + if (this.xsNotifications && this.isGameRunning && !this.isGameNoVR) { playXSNotification = true; } - if ((this.currentUserStatus === 'busy') || - (!this.notyInit)) { + if (this.currentUserStatus === 'busy' || !this.notyInit) { return; } var notyToPlay = []; @@ -4517,23 +4666,31 @@ speechSynthesis.getVoices(); } else { console.error('missing displayName'); } - if ((displayName) && (!this.notyMap[displayName]) || - (this.notyMap[displayName] < feed.created_at)) { + if ( + (displayName && !this.notyMap[displayName]) || + this.notyMap[displayName] < feed.created_at + ) { this.notyMap[displayName] = feed.created_at; notyToPlay.push(feed); } }); var bias = new Date(Date.now() - 60000).toJSON(); - var noty = {}; - var messageList = ['inviteMessage', 'requestMessage', 'responseMessage']; + var messageList = [ + 'inviteMessage', + 'requestMessage', + 'responseMessage' + ]; for (var i = 0; i < notyToPlay.length; i++) { - noty = notyToPlay[i]; + let noty = notyToPlay[i]; if (noty.created_at < bias) { continue; } - var message = ''; + let message = ''; for (var k = 0; k < messageList.length; k++) { - if (typeof noty.details !== 'undefined' && typeof noty.details[messageList[k]] !== 'undefined') { + if ( + typeof noty.details !== 'undefined' && + typeof noty.details[messageList[k]] !== 'undefined' + ) { message = noty.details[messageList[k]]; } } @@ -4543,7 +4700,7 @@ speechSynthesis.getVoices(); if (playNotificationTTS) { this.playNotyTTS(noty, message); } - if ((playDesktopToast) || (playXSNotification)) { + if (playDesktopToast || playXSNotification) { this.notyGetImage(noty).then((image) => { if (playXSNotification) { this.displayXSNotification(noty, message, image); @@ -4573,22 +4730,30 @@ speechSynthesis.getVoices(); } } } - if ((noty.details) && (noty.details.imageUrl)) { + if (noty.details && noty.details.imageUrl) { imageURL = noty.details.imageUrl; } else if (userId) { imageURL = await API.getCachedUser({ userId - }).catch((err) => { - console.error(err); - return false; - }).then((args) => { - if ((this.displayProfilePicOverrideAsAvatar) && (args.json.profilePicOverride)) { - return args.json.profilePicOverride; - } else if ((this.displayVRCPlusIconsAsAvatar) && (args.json.userIcon)) { - return args.json.userIcon; - } - return args.json.currentAvatarThumbnailImageUrl; - }); + }) + .catch((err) => { + console.error(err); + return false; + }) + .then((args) => { + if ( + this.displayProfilePicOverrideAsAvatar && + args.json.profilePicOverride + ) { + return args.json.profilePicOverride; + } else if ( + this.displayVRCPlusIconsAsAvatar && + args.json.userIcon + ) { + return args.json.userIcon; + } + return args.json.currentAvatarThumbnailImageUrl; + }); } if (!imageURL) { return false; @@ -4600,18 +4765,18 @@ speechSynthesis.getVoices(); headers: { 'User-Agent': appVersion } - }).then(response => { - return response.arrayBuffer(); - }).then(buffer => { - var binary = ''; - var bytes = new Uint8Array(buffer); - var length = bytes.byteLength; - for (var i = 0; i < length; i++) { - binary += String.fromCharCode(bytes[i]); - } - var imageData = btoa(binary); - AppApi.CacheImage(imageData); - }); + }) + .then((response) => response.arrayBuffer()) + .then((buffer) => { + var binary = ''; + var bytes = new Uint8Array(buffer); + var length = bytes.byteLength; + for (var i = 0; i < length; i++) { + binary += String.fromCharCode(bytes[i]); + } + var imageData = btoa(binary); + AppApi.CacheImage(imageData); + }); return true; } catch (err) { console.error(err); @@ -4631,7 +4796,12 @@ speechSynthesis.getVoices(); this.speak(`${noty.displayName} is joining`); break; case 'GPS': - this.speak(`${noty.displayName} is in ${this.displayLocation(noty.location, noty.worldName)}`); + this.speak( + `${noty.displayName} is in ${this.displayLocation( + noty.location, + noty.worldName + )}` + ); break; case 'Online': this.speak(`${noty.displayName} has logged in`); @@ -4640,22 +4810,39 @@ speechSynthesis.getVoices(); this.speak(`${noty.displayName} has logged out`); break; case 'Status': - this.speak(`${noty.displayName} status is now ${noty.status} ${noty.statusDescription}`); + this.speak( + `${noty.displayName} status is now ${noty.status} ${noty.statusDescription}` + ); break; case 'invite': - this.speak(`${noty.senderUsername} has invited you to ${this.displayLocation(noty.details.worldId, noty.details.worldName)}${message}`); + this.speak( + `${ + noty.senderUsername + } has invited you to ${this.displayLocation( + noty.details.worldId, + noty.details.worldName + )}${message}` + ); break; case 'requestInvite': - this.speak(`${noty.senderUsername} has requested an invite${message}`); + this.speak( + `${noty.senderUsername} has requested an invite${message}` + ); break; case 'inviteResponse': - this.speak(`${noty.senderUsername} has responded to your invite${message}`); + this.speak( + `${noty.senderUsername} has responded to your invite${message}` + ); break; case 'requestInviteResponse': - this.speak(`${noty.senderUsername} has responded to your invite request${message}`); + this.speak( + `${noty.senderUsername} has responded to your invite request${message}` + ); break; case 'friendRequest': - this.speak(`${noty.senderUsername} has sent you a friend request`); + this.speak( + `${noty.senderUsername} has sent you a friend request` + ); break; case 'Friend': this.speak(`${noty.displayName} is now your friend`); @@ -4664,10 +4851,14 @@ speechSynthesis.getVoices(); this.speak(`${noty.displayName} is no longer your friend`); break; case 'TrustLevel': - this.speak(`${noty.displayName} trust level is now ${noty.trustLevel}`); + this.speak( + `${noty.displayName} trust level is now ${noty.trustLevel}` + ); break; case 'DisplayName': - this.speak(`${noty.previousDisplayName} changed their name to ${noty.displayName}`); + this.speak( + `${noty.previousDisplayName} changed their name to ${noty.displayName}` + ); break; case 'PortalSpawn': this.speak(`${noty.data} has spawned a portal`); @@ -4690,84 +4881,198 @@ speechSynthesis.getVoices(); case 'MutedOnPlayerLeft': this.speak(`Muted user ${noty.displayName} has left`); break; - default: - break; } }; $app.methods.displayXSNotification = function (noty, message, image) { - var timeout = parseInt(parseInt(this.notificationTimeout) / 1000); + var timeout = Math.floor(parseInt(this.notificationTimeout, 10) / 1000); switch (noty.type) { case 'OnPlayerJoined': - AppApi.XSNotification('VRCX', `${noty.data} has joined`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.data} has joined`, + timeout, + image + ); break; case 'OnPlayerLeft': - AppApi.XSNotification('VRCX', `${noty.data} has left`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.data} has left`, + timeout, + image + ); break; case 'OnPlayerJoining': - AppApi.XSNotification('VRCX', `${noty.displayName} is joining`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} is joining`, + timeout, + image + ); break; case 'GPS': - AppApi.XSNotification('VRCX', `${noty.displayName} is in ${this.displayLocation(noty.location, noty.worldName)}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} is in ${this.displayLocation( + noty.location, + noty.worldName + )}`, + timeout, + image + ); break; case 'Online': - AppApi.XSNotification('VRCX', `${noty.displayName} has logged in`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} has logged in`, + timeout, + image + ); break; case 'Offline': - AppApi.XSNotification('VRCX', `${noty.displayName} has logged out`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} has logged out`, + timeout, + image + ); break; case 'Status': - AppApi.XSNotification('VRCX', `${noty.displayName} status is now ${noty.status} ${noty.statusDescription}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} status is now ${noty.status} ${noty.statusDescription}`, + timeout, + image + ); break; case 'invite': - AppApi.XSNotification('VRCX', `${noty.senderUsername} has invited you to ${this.displayLocation(noty.details.worldId, noty.details.worldName)}${message}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${ + noty.senderUsername + } has invited you to ${this.displayLocation( + noty.details.worldId, + noty.details.worldName + )}${message}`, + timeout, + image + ); break; case 'requestInvite': - AppApi.XSNotification('VRCX', `${noty.senderUsername} has requested an invite${message}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.senderUsername} has requested an invite${message}`, + timeout, + image + ); break; case 'inviteResponse': - AppApi.XSNotification('VRCX', `${noty.senderUsername} has responded to your invite${message}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.senderUsername} has responded to your invite${message}`, + timeout, + image + ); break; case 'requestInviteResponse': - AppApi.XSNotification('VRCX', `${noty.senderUsername} has responded to your invite request${message}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.senderUsername} has responded to your invite request${message}`, + timeout, + image + ); break; case 'friendRequest': - AppApi.XSNotification('VRCX', `${noty.senderUsername} has sent you a friend request`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.senderUsername} has sent you a friend request`, + timeout, + image + ); break; case 'Friend': - AppApi.XSNotification('VRCX', `${noty.displayName} is now your friend`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} is now your friend`, + timeout, + image + ); break; case 'Unfriend': - AppApi.XSNotification('VRCX', `${noty.displayName} is no longer your friend`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} is no longer your friend`, + timeout, + image + ); break; case 'TrustLevel': - AppApi.XSNotification('VRCX', `${noty.displayName} trust level is now ${noty.trustLevel}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.displayName} trust level is now ${noty.trustLevel}`, + timeout, + image + ); break; case 'DisplayName': - AppApi.XSNotification('VRCX', `${noty.previousDisplayName} changed their name to ${noty.displayName}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.previousDisplayName} changed their name to ${noty.displayName}`, + timeout, + image + ); break; case 'PortalSpawn': - AppApi.XSNotification('VRCX', `${noty.data} has spawned a portal`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `${noty.data} has spawned a portal`, + timeout, + image + ); break; case 'Event': AppApi.XSNotification('VRCX', noty.data, timeout, image); break; case 'VideoPlay': - AppApi.XSNotification('VRCX', `Now playing: ${noty.data}`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `Now playing: ${noty.data}`, + timeout, + image + ); break; case 'BlockedOnPlayerJoined': - AppApi.XSNotification('VRCX', `Blocked user ${noty.displayName} has joined`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `Blocked user ${noty.displayName} has joined`, + timeout, + image + ); break; case 'BlockedOnPlayerLeft': - AppApi.XSNotification('VRCX', `Blocked user ${noty.displayName} has left`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `Blocked user ${noty.displayName} has left`, + timeout, + image + ); break; case 'MutedOnPlayerJoined': - AppApi.XSNotification('VRCX', `Muted user ${noty.displayName} has joined`, timeout, image); + AppApi.XSNotification( + 'VRCX', + `Muted user ${noty.displayName} has joined`, + timeout, + image + ); break; case 'MutedOnPlayerLeft': - AppApi.XSNotification('VRCX', `Muted user ${noty.displayName} has left`, timeout, image); - break; - default: + AppApi.XSNotification( + 'VRCX', + `Muted user ${noty.displayName} has left`, + timeout, + image + ); break; } }; @@ -4781,49 +5086,115 @@ speechSynthesis.getVoices(); AppApi.DesktopNotification(noty.data, 'has left', image); break; case 'OnPlayerJoining': - AppApi.DesktopNotification(noty.displayName, 'is joining', image); + AppApi.DesktopNotification( + noty.displayName, + 'is joining', + image + ); break; case 'GPS': - AppApi.DesktopNotification(noty.displayName, `is in ${this.displayLocation(noty.location, noty.worldName)}`, image); + AppApi.DesktopNotification( + noty.displayName, + `is in ${this.displayLocation( + noty.location, + noty.worldName + )}`, + image + ); break; case 'Online': - AppApi.DesktopNotification(noty.displayName, 'has logged in', image); + AppApi.DesktopNotification( + noty.displayName, + 'has logged in', + image + ); break; case 'Offline': - AppApi.DesktopNotification(noty.displayName, 'has logged out', image); + AppApi.DesktopNotification( + noty.displayName, + 'has logged out', + image + ); break; case 'Status': - AppApi.DesktopNotification(noty.displayName, `status is now ${noty.status} ${noty.statusDescription}`, image); + AppApi.DesktopNotification( + noty.displayName, + `status is now ${noty.status} ${noty.statusDescription}`, + image + ); break; case 'invite': - AppApi.DesktopNotification(noty.senderUsername, `has invited you to ${this.displayLocation(noty.details.worldId, noty.details.worldName)}${message}`, image); + AppApi.DesktopNotification( + noty.senderUsername, + `has invited you to ${this.displayLocation( + noty.details.worldId, + noty.details.worldName + )}${message}`, + image + ); break; case 'requestInvite': - AppApi.DesktopNotification(noty.senderUsername, `has requested an invite${message}`, image); + AppApi.DesktopNotification( + noty.senderUsername, + `has requested an invite${message}`, + image + ); break; case 'inviteResponse': - AppApi.DesktopNotification(noty.senderUsername, `has responded to your invite${message}`, image); + AppApi.DesktopNotification( + noty.senderUsername, + `has responded to your invite${message}`, + image + ); break; case 'requestInviteResponse': - AppApi.DesktopNotification(noty.senderUsername, `has responded to your invite request${message}`, image); + AppApi.DesktopNotification( + noty.senderUsername, + `has responded to your invite request${message}`, + image + ); break; case 'friendRequest': - AppApi.DesktopNotification(noty.senderUsername, 'has sent you a friend request', image); + AppApi.DesktopNotification( + noty.senderUsername, + 'has sent you a friend request', + image + ); break; case 'Friend': - AppApi.DesktopNotification(noty.displayName, 'is now your friend', image); + AppApi.DesktopNotification( + noty.displayName, + 'is now your friend', + image + ); break; case 'Unfriend': - AppApi.DesktopNotification(noty.displayName, 'is no longer your friend', image); + AppApi.DesktopNotification( + noty.displayName, + 'is no longer your friend', + image + ); break; case 'TrustLevel': - AppApi.DesktopNotification(noty.displayName, `trust level is now ${noty.trustLevel}`, image); + AppApi.DesktopNotification( + noty.displayName, + `trust level is now ${noty.trustLevel}`, + image + ); break; case 'DisplayName': - AppApi.DesktopNotification(noty.previousDisplayName, `changed their name to ${noty.displayName}`, image); + AppApi.DesktopNotification( + noty.previousDisplayName, + `changed their name to ${noty.displayName}`, + image + ); break; case 'PortalSpawn': - AppApi.DesktopNotification(noty.data, `has spawned a portal`, image); + AppApi.DesktopNotification( + noty.data, + `has spawned a portal`, + image + ); break; case 'Event': AppApi.DesktopNotification('Event', noty.data, image); @@ -4832,18 +5203,32 @@ speechSynthesis.getVoices(); AppApi.DesktopNotification('Now playing', noty.data, image); break; case 'BlockedOnPlayerJoined': - AppApi.DesktopNotification(noty.displayName, 'blocked user has joined', image); + AppApi.DesktopNotification( + noty.displayName, + 'blocked user has joined', + image + ); break; case 'BlockedOnPlayerLeft': - AppApi.DesktopNotification(noty.displayName, 'blocked user has left', image); + AppApi.DesktopNotification( + noty.displayName, + 'blocked user has left', + image + ); break; case 'MutedOnPlayerJoined': - AppApi.DesktopNotification(noty.displayName, 'muted user has joined', image); + AppApi.DesktopNotification( + noty.displayName, + 'muted user has joined', + image + ); break; case 'MutedOnPlayerLeft': - AppApi.DesktopNotification(noty.displayName, 'muted user has left', image); - break; - default: + AppApi.DesktopNotification( + noty.displayName, + 'muted user has left', + image + ); break; } }; @@ -4866,7 +5251,7 @@ speechSynthesis.getVoices(); }; $app.methods.notifyMenu = function (index) { - var { menu } = this.$refs; + var {menu} = this.$refs; if (menu.activeIndex !== index) { var item = menu.items[index]; if (item) { @@ -4892,68 +5277,78 @@ speechSynthesis.getVoices(); }; $app.methods.promptTOTP = function () { - this.$prompt('Enter a numeric code from your authenticator app', 'Two-factor Authentication', { - distinguishCancelAndClose: true, - cancelButtonText: 'Use OTP', - confirmButtonText: 'Verify', - inputPlaceholder: 'Code', - inputPattern: /^[0-9]{6}$/, - inputErrorMessage: 'Invalid Code', - callback: (action, instance) => { - if (action === 'confirm') { - API.verifyTOTP({ - code: instance.inputValue - }).catch((err) => { - this.promptTOTP(); - throw err; - }).then((args) => { - API.getCurrentUser(); - return args; - }); - } else if (action === 'cancel') { - this.promptOTP(); + this.$prompt( + 'Enter a numeric code from your authenticator app', + 'Two-factor Authentication', + { + distinguishCancelAndClose: true, + cancelButtonText: 'Use OTP', + confirmButtonText: 'Verify', + inputPlaceholder: 'Code', + inputPattern: /^[0-9]{6}$/, + inputErrorMessage: 'Invalid Code', + callback: (action, instance) => { + if (action === 'confirm') { + API.verifyTOTP({ + code: instance.inputValue + }) + .catch((err) => { + this.promptTOTP(); + throw err; + }) + .then((args) => { + API.getCurrentUser(); + return args; + }); + } else if (action === 'cancel') { + this.promptOTP(); + } } } - }); + ); }; $app.methods.promptOTP = function () { - this.$prompt('Enter one of your saved recovery codes', 'Two-factor Authentication', { - distinguishCancelAndClose: true, - cancelButtonText: 'Use TOTP', - confirmButtonText: 'Verify', - inputPlaceholder: 'Code', - inputPattern: /^[a-z0-9]{4}-[a-z0-9]{4}$/, - inputErrorMessage: 'Invalid Code', - callback: (action, instance) => { - if (action === 'confirm') { - API.verifyOTP({ - code: instance.inputValue - }).catch((err) => { - this.promptOTP(); - throw err; - }).then((args) => { - API.getCurrentUser(); - return args; - }); - } else if (action === 'cancel') { - this.promptTOTP(); + this.$prompt( + 'Enter one of your saved recovery codes', + 'Two-factor Authentication', + { + distinguishCancelAndClose: true, + cancelButtonText: 'Use TOTP', + confirmButtonText: 'Verify', + inputPlaceholder: 'Code', + inputPattern: /^[a-z0-9]{4}-[a-z0-9]{4}$/, + inputErrorMessage: 'Invalid Code', + callback: (action, instance) => { + if (action === 'confirm') { + API.verifyOTP({ + code: instance.inputValue + }) + .catch((err) => { + this.promptOTP(); + throw err; + }) + .then((args) => { + API.getCurrentUser(); + return args; + }); + } else if (action === 'cancel') { + this.promptTOTP(); + } } } - }); + ); }; $app.methods.showExportFriendsListDialog = function () { - var { friends } = API.currentUser; + var {friends} = API.currentUser; if (Array.isArray(friends) === false) { return; } - var lines = [ - 'UserID,DisplayName,Memo' - ]; + var lines = ['UserID,DisplayName,Memo']; var _ = function (str) { if (/[\x00-\x1f,"]/.test(str) === true) { - str = `"${str.replace(/"/g, '""')}"`; + return `"${str.replace(/"/g, '""')}"`; } return str; }; @@ -4982,7 +5377,7 @@ speechSynthesis.getVoices(); sort: 'updated', order: 'descending', releaseStatus: 'all', - user: 'me', + user: 'me' }; var map = new Map(); API.bulk({ @@ -5002,12 +5397,10 @@ speechSynthesis.getVoices(); if (Array.isArray(avatars) === false) { return; } - var lines = [ - 'AvatarID,AvatarName' - ]; + var lines = ['AvatarID,AvatarName']; var _ = function (str) { if (/[\x00-\x1f,"]/.test(str) === true) { - str = `"${str.replace(/"/g, '""')}"`; + return `"${str.replace(/"/g, '""')}"`; } return str; }; @@ -5027,14 +5420,18 @@ speechSynthesis.getVoices(); API.$on('LOGOUT', function () { new Noty({ type: 'success', - text: `See you again, ${escapeTag(this.currentUser.displayName)}!` + text: `See you again, ${escapeTag( + this.currentUser.displayName + )}!` }).show(); }); API.$on('LOGIN', function (args) { new Noty({ type: 'success', - text: `Hello there, ${escapeTag(args.ref.displayName)}!` + text: `Hello there, ${escapeTag( + args.ref.displayName + )}!` }).show(); $app.$refs.menu.activeIndex = 'feed'; $app.resetGameLog(); @@ -5051,33 +5448,35 @@ speechSynthesis.getVoices(); $app.methods.checkPrimaryPassword = function (args) { return new Promise((resolve, reject) => { if (!this.enablePrimaryPassword) { - return resolve(args.password); + resolve(args.password); } $app.$prompt( 'Please enter your Primary Password.', 'Primary Password Required', { - inputType: "password", + inputType: 'password', inputPattern: /[\s\S]{1,32}/ - }, - ).then(({ value }) => { - security.decrypt(args.password, value).then(pwd => { - return resolve(pwd); - }).catch(_ => { - return reject(); + } + ) + .then(({value}) => { + security + .decrypt(args.password, value) + .then(resolve) + .catch(reject); }) - }).catch(_ => { - return reject(); - }) - }) - } + .catch(reject); + }); + }; - $app.data.enablePrimaryPassword = !!configRepository.getBool('enablePrimaryPassword'); + $app.data.enablePrimaryPassword = configRepository.getBool( + 'enablePrimaryPassword', + false + ); $app.data.enablePrimaryPasswordDialog = { visible: false, password: '', rePassword: '', - beforeClose: function (done) { + beforeClose(done) { $app._data.enablePrimaryPassword = false; done(); } @@ -5092,36 +5491,67 @@ speechSynthesis.getVoices(); 'Please enter your Primary Password.', 'Primary Password Required', { - inputType: "password", + inputType: 'password', inputPattern: /[\s\S]{1,32}/ - }, - ).then(({ value }) => { - for (let name in this.loginForm.savedCredentials) { - security.decrypt(this.loginForm.savedCredentials[name].loginParmas.password, value).then(pt => { - this.saveCredentials = { username: name, password: pt }; - this.updateStoredUser(this.loginForm.savedCredentials[name].user); - configRepository.setBool('enablePrimaryPassword', false); - }).catch(_ => { - this.enablePrimaryPassword = true; - configRepository.setBool('enablePrimaryPassword', true); - }); } - }).catch(_ => { - this.enablePrimaryPassword = true; - configRepository.setBool('enablePrimaryPassword', true); - }); + ) + .then(({value}) => { + for (let name in this.loginForm.savedCredentials) { + security + .decrypt( + this.loginForm.savedCredentials[name] + .loginParmas.password, + value + ) + .then((pt) => { + this.saveCredentials = { + username: name, + password: pt + }; + this.updateStoredUser( + this.loginForm.savedCredentials[name].user + ); + configRepository.setBool( + 'enablePrimaryPassword', + false + ); + }) + .catch(() => { + this.enablePrimaryPassword = true; + configRepository.setBool( + 'enablePrimaryPassword', + true + ); + }); + } + }) + .catch(() => { + this.enablePrimaryPassword = true; + configRepository.setBool('enablePrimaryPassword', true); + }); } }; $app.methods.setPrimaryPassword = function () { - configRepository.setBool('enablePrimaryPassword', this.enablePrimaryPassword); + configRepository.setBool( + 'enablePrimaryPassword', + this.enablePrimaryPassword + ); this.enablePrimaryPasswordDialog.visible = false; if (this.enablePrimaryPassword) { let key = this.enablePrimaryPasswordDialog.password; for (let name in this.loginForm.savedCredentials) { - security.encrypt(this.loginForm.savedCredentials[name].loginParmas.password, key).then(ct => { - this.saveCredentials = { username: name, password: ct }; - this.updateStoredUser(this.loginForm.savedCredentials[name].user); - }); + security + .encrypt( + this.loginForm.savedCredentials[name].loginParmas + .password, + key + ) + .then((ct) => { + this.saveCredentials = {username: name, password: ct}; + this.updateStoredUser( + this.loginForm.savedCredentials[name].user + ); + }); } } }; @@ -5129,13 +5559,20 @@ speechSynthesis.getVoices(); $app.methods.updateStoredUser = function (currentUser) { var savedCredentialsArray = {}; if (configRepository.getString('savedCredentials') !== null) { - var savedCredentialsArray = JSON.parse(configRepository.getString('savedCredentials')); + var savedCredentialsArray = JSON.parse( + configRepository.getString('savedCredentials') + ); } if (this.saveCredentials) { - var credentialsToSave = { user: currentUser, loginParmas: this.saveCredentials }; + var credentialsToSave = { + user: currentUser, + loginParmas: this.saveCredentials + }; savedCredentialsArray[currentUser.username] = credentialsToSave; delete this.saveCredentials; - } else if (typeof savedCredentialsArray[currentUser.username] !== 'undefined') { + } else if ( + typeof savedCredentialsArray[currentUser.username] !== 'undefined' + ) { savedCredentialsArray[currentUser.username].user = currentUser; } this.loginForm.savedCredentials = savedCredentialsArray; @@ -5147,37 +5584,45 @@ speechSynthesis.getVoices(); $app.methods.relogin = function (loginParmas) { return new Promise((resolve, reject) => { - this.checkPrimaryPassword(loginParmas).then(pwd => { - this.loginForm.loading = true; - return API.getConfig().catch((err) => { - this.loginForm.loading = false; - return reject(err); - }).then(() => { - API.login({ - username: loginParmas.username, - password: pwd, - cipher: loginParmas.password - }).catch((err2) => { - this.loginForm.loading = false; - API.logout(); - return reject(err2); - }).then(() => { - this.loginForm.loading = false; - return resolve(); + this.checkPrimaryPassword(loginParmas) + .then((pwd) => { + this.loginForm.loading = true; + return API.getConfig() + .catch((err) => { + this.loginForm.loading = false; + reject(err); + }) + .then(() => { + API.login({ + username: loginParmas.username, + password: pwd, + cipher: loginParmas.password + }) + .catch((err2) => { + this.loginForm.loading = false; + API.logout(); + reject(err2); + }) + .then(() => { + this.loginForm.loading = false; + resolve(); + }); + }); + }) + .catch((_) => { + this.$message({ + message: 'Incorrect primary password', + type: 'error' }); + reject(_); }); - }).catch(_ => { - this.$message({ - message: 'Incorrect primary password', - type: 'error' - }); - return reject(); - }); }); }; $app.methods.deleteSavedLogin = function (username) { - var savedCredentialsArray = JSON.parse(configRepository.getString('savedCredentials')); + var savedCredentialsArray = JSON.parse( + configRepository.getString('savedCredentials') + ); delete savedCredentialsArray[username]; // Disable primary password when no account is available. if (Object.keys(savedCredentialsArray).length === 0) { @@ -5197,7 +5642,8 @@ speechSynthesis.getVoices(); if ($app.enablePrimaryPassword) { return; } - var user = $app.loginForm.savedCredentials[$app.loginForm.lastUserLoggedIn]; + var user = + $app.loginForm.savedCredentials[$app.loginForm.lastUserLoggedIn]; if (typeof user !== 'undefined') { $app.relogin({ username: user.loginParmas.username, @@ -5216,9 +5662,10 @@ speechSynthesis.getVoices(); username: '', password: '', saveCredentials: false, - savedCredentials: ((configRepository.getString('lastUserLoggedIn') !== null) - ? JSON.parse(configRepository.getString('savedCredentials')) - : {}), + savedCredentials: + configRepository.getString('lastUserLoggedIn') !== null + ? JSON.parse(configRepository.getString('savedCredentials')) + : {}, lastUserLoggedIn: configRepository.getString('lastUserLoggedIn'), rules: { username: [ @@ -5238,52 +5685,81 @@ speechSynthesis.getVoices(); $app.methods.login = function () { this.$refs.loginForm.validate((valid) => { - if (valid && - !this.loginForm.loading) { + if (valid && !this.loginForm.loading) { this.loginForm.loading = true; - API.getConfig().catch((err) => { - this.loginForm.loading = false; - throw err; - }).then((args) => { - if (this.loginForm.saveCredentials && this.enablePrimaryPassword) { - $app.$prompt( - 'Please enter your Primary Password.', - 'Primary Password Required', - { - inputType: "password", - inputPattern: /[\s\S]{1,32}/ - }, - ).then(({ value }) => { - let saveCredential = this.loginForm.savedCredentials[Object.keys(this.loginForm.savedCredentials)[0]]; - security.decrypt(saveCredential.loginParmas.password, value).then(_ => { - security.encrypt(this.loginForm.password, value).then(pwd => { - API.login({ - username: this.loginForm.username, - password: this.loginForm.password, - saveCredentials: this.loginForm.saveCredentials, - cipher: pwd - }).finally(() => { - this.loginForm.username = ''; - this.loginForm.password = ''; - }); + API.getConfig() + .catch((err) => { + this.loginForm.loading = false; + throw err; + }) + .then((args) => { + if ( + this.loginForm.saveCredentials && + this.enablePrimaryPassword + ) { + $app.$prompt( + 'Please enter your Primary Password.', + 'Primary Password Required', + { + inputType: 'password', + inputPattern: /[\s\S]{1,32}/ + } + ) + .then(({value}) => { + let saveCredential = + this.loginForm.savedCredentials[ + Object.keys( + this.loginForm.savedCredentials + )[0] + ]; + security + .decrypt( + saveCredential.loginParmas.password, + value + ) + .then(() => { + security + .encrypt( + this.loginForm.password, + value + ) + .then((pwd) => { + API.login({ + username: + this.loginForm + .username, + password: + this.loginForm + .password, + saveCredentials: + this.loginForm + .saveCredentials, + cipher: pwd + }).finally(() => { + this.loginForm.username = + ''; + this.loginForm.password = + ''; + }); + }); + }); }) - }) + .finally(() => { + this.loginForm.loading = false; + }); + return args; + } + API.login({ + username: this.loginForm.username, + password: this.loginForm.password, + saveCredentials: this.loginForm.saveCredentials }).finally(() => { + this.loginForm.username = ''; + this.loginForm.password = ''; this.loginForm.loading = false; }); - return args - } - API.login({ - username: this.loginForm.username, - password: this.loginForm.password, - saveCredentials: this.loginForm.saveCredentials - }).finally(() => { - this.loginForm.username = ''; - this.loginForm.password = ''; - this.loginForm.loading = false; + return args; }); - return args; - }); } }); }; @@ -5291,30 +5767,34 @@ speechSynthesis.getVoices(); $app.methods.loginWithSteam = function () { if (!this.loginForm.loading) { this.loginForm.loading = true; - AppApi.LoginWithSteam().catch((err) => { - this.loginForm.loading = false; - throw err; - }).then((steamTicket) => { - if (steamTicket) { - API.getConfig().catch((err) => { - this.loginForm.loading = false; - throw err; - }).then((args) => { - API.loginWithSteam({ - steamTicket - }).finally(() => { - this.loginForm.loading = false; - }); - return args; - }); - } else { + AppApi.LoginWithSteam() + .catch((err) => { this.loginForm.loading = false; - this.$message({ - message: 'It only works when VRChat is running.', - type: 'error' - }); - } - }); + throw err; + }) + .then((steamTicket) => { + if (steamTicket) { + API.getConfig() + .catch((err) => { + this.loginForm.loading = false; + throw err; + }) + .then((args) => { + API.loginWithSteam({ + steamTicket + }).finally(() => { + this.loginForm.loading = false; + }); + return args; + }); + } else { + this.loginForm.loading = false; + this.$message({ + message: 'It only works when VRChat is running.', + type: 'error' + }); + } + }); } }; @@ -5338,8 +5818,7 @@ speechSynthesis.getVoices(); try { var row = await database.getMemo(userId); return row.memo; - } catch (err) { - } + } catch (err) {} return ''; }; @@ -5381,21 +5860,40 @@ speechSynthesis.getVoices(); $app.data.sortFriendsGroup1 = false; $app.data.sortFriendsGroup2 = false; $app.data.sortFriendsGroup3 = false; - $app.data.orderFriendsGroup0 = configRepository.getBool('orderFriendGroup0'); - $app.data.orderFriendsGroup1 = configRepository.getBool('orderFriendGroup1'); - $app.data.orderFriendsGroup2 = configRepository.getBool('orderFriendGroup2'); - $app.data.orderFriendsGroup3 = configRepository.getBool('orderFriendGroup3'); - $app.data.orderFriendsGroupPrivate = configRepository.getBool('orderFriendGroupPrivate'); - $app.data.orderFriendsGroupStatus = configRepository.getBool('orderFriendGroupPrivate'); - $app.data.orderFriendsGroupGPS = configRepository.getBool('orderFriendGroupGPS'); + $app.data.orderFriendsGroup0 = + configRepository.getBool('orderFriendGroup0'); + $app.data.orderFriendsGroup1 = + configRepository.getBool('orderFriendGroup1'); + $app.data.orderFriendsGroup2 = + configRepository.getBool('orderFriendGroup2'); + $app.data.orderFriendsGroup3 = + configRepository.getBool('orderFriendGroup3'); + $app.data.orderFriendsGroupPrivate = configRepository.getBool( + 'orderFriendGroupPrivate' + ); + $app.data.orderFriendsGroupStatus = configRepository.getBool( + 'orderFriendGroupPrivate' + ); + $app.data.orderFriendsGroupGPS = configRepository.getBool( + 'orderFriendGroupGPS' + ); var saveOrderFriendGroup = function () { configRepository.setBool('orderFriendGroup0', this.orderFriendsGroup0); configRepository.setBool('orderFriendGroup1', this.orderFriendsGroup1); configRepository.setBool('orderFriendGroup2', this.orderFriendsGroup2); configRepository.setBool('orderFriendGroup3', this.orderFriendsGroup3); - configRepository.setBool('orderFriendGroupPrivate', this.orderFriendsGroupPrivate); - configRepository.setBool('orderFriendsGroupStatus', this.orderFriendsGroupStatus); - configRepository.setBool('orderFriendGroupGPS', this.orderFriendsGroupGPS); + configRepository.setBool( + 'orderFriendGroupPrivate', + this.orderFriendsGroupPrivate + ); + configRepository.setBool( + 'orderFriendsGroupStatus', + this.orderFriendsGroupStatus + ); + configRepository.setBool( + 'orderFriendGroupGPS', + this.orderFriendsGroupGPS + ); this.sortFriendsGroup0 = true; this.sortFriendsGroup1 = true; }; @@ -5431,8 +5929,7 @@ speechSynthesis.getVoices(); continue; } var user = API.cachedUsers.get(userId); - if (typeof user !== 'undefined' && - user.status !== 'offline') { + if (typeof user !== 'undefined' && user.status !== 'offline') { continue; } if (this.pendingActiveFriends.size >= 5) { @@ -5544,8 +6041,7 @@ speechSynthesis.getVoices(); }); if (typeof ref === 'undefined') { ref = this.friendLog.get(id); - if (typeof ref !== 'undefined' && - ref.displayName) { + if (typeof ref !== 'undefined' && ref.displayName) { ctx.name = ref.displayName; } } else { @@ -5609,8 +6105,7 @@ speechSynthesis.getVoices(); this.updateFriendInProgress.add(id); var ref = API.cachedUsers.get(id); var isVIP = API.cachedFavoritesByObjectId.has(id); - if (typeof newState === 'undefined' || - ctx.state === newState) { + if (typeof newState === 'undefined' || ctx.state === newState) { // this is should be: undefined -> user if (ctx.ref !== ref) { ctx.ref = ref; @@ -5656,8 +6151,7 @@ speechSynthesis.getVoices(); } } } - if (typeof ref !== 'undefined' && - ctx.name !== ref.displayName) { + if (typeof ref !== 'undefined' && ctx.name !== ref.displayName) { ctx.name = ref.displayName; if (ctx.state === 'online') { if (ctx.isVIP) { @@ -5672,23 +6166,30 @@ speechSynthesis.getVoices(); } } // FIXME: 도배 가능성 있음 - if (origin && + if ( + origin && ctx.state !== 'online' && typeof ref !== 'undefined' && ref.location !== '' && ref.location !== 'offline' && - ref.location !== 'private') { + ref.location !== 'private' + ) { API.getUser({ userId: id - }).catch((err) => { + }).catch(() => { this.updateFriendInProgress.delete(id); }); } } else { - //prevent status flapping - if ((ctx.state === 'online') && ((newState === 'active') || (newState === 'offline'))) { + // prevent status flapping + if ( + ctx.state === 'online' && + (newState === 'active' || newState === 'offline') + ) { this.updateFriendInProgress.delete(id); - await new Promise(resolve => setTimeout(resolve, 50000)); + await new Promise((resolve) => { + setTimeout(resolve, 50000); + }); if (this.APILastOnline.has(id)) { var date = this.APILastOnline.get(id); if (date > Date.now() - 60000) { @@ -5698,25 +6199,32 @@ speechSynthesis.getVoices(); } var location = ''; var $location_at = ''; - if ((typeof ref !== 'undefined') && - (typeof ref.location !== 'undefined')) { - var { location, $location_at } = ref; + if ( + typeof ref !== 'undefined' && + typeof ref.location !== 'undefined' + ) { + var {location, $location_at} = ref; } var args = await API.getUser({ userId: id - }).catch((err) => { + }).catch(() => { this.updateFriendInProgress.delete(id); }); - if ((typeof args !== 'undefined') && - (typeof args.ref !== 'undefined')) { + if ( + typeof args !== 'undefined' && + typeof args.ref !== 'undefined' + ) { + // eslint-disable-next-line no-param-reassign newState = args.ref.state; ctx.ref = args.ref; } if (ctx.state !== newState) { - if ((typeof ctx.ref.$offline_for !== 'undefined') && - (ctx.ref.$offline_for === '') && - ((newState === 'offline') || (newState === 'active')) && - (ctx.state === 'online')) { + if ( + typeof ctx.ref.$offline_for !== 'undefined' && + ctx.ref.$offline_for === '' && + (newState === 'offline' || newState === 'active') && + ctx.state === 'online' + ) { ctx.ref.$online_for = ''; ctx.ref.$offline_for = Date.now(); if (ctx.state === 'online') { @@ -5813,8 +6321,7 @@ speechSynthesis.getVoices(); }); worldName = args.ref.name; } - } catch (err) { - } + } catch (err) {} } return worldName; }; @@ -5824,8 +6331,7 @@ speechSynthesis.getVoices(); return; } var ctx = this.friends.get(userId); - if ((typeof ctx.ref !== 'undefined') && - (ctx.state === 'online')) { + if (typeof ctx.ref !== 'undefined' && ctx.state === 'online') { if (ctx.isVIP) { removeFromArray(this.friendsGroupA_, ctx); this.sortFriendsGroup1 = true; @@ -5864,25 +6370,12 @@ speechSynthesis.getVoices(); return 0; }; - // ascending - var compareByDisplayName = function (a, b) { - var A = String(a.displayName).toUpperCase(); - var B = String(b.displayName).toUpperCase(); - if (A < B) { - return -1; - } - if (A > B) { - return 1; - } - return 0; - }; - // private var compareByPrivate = function (a, b) { - if ((typeof a.ref === 'undefined') || (typeof b.ref === 'undefined')) { + if (typeof a.ref === 'undefined' || typeof b.ref === 'undefined') { return 0; } - if ((a.ref.location === 'private') && (b.ref.location === 'private')) { + if (a.ref.location === 'private' && b.ref.location === 'private') { return 0; } else if (a.ref.location === 'private') { return 1; @@ -5894,10 +6387,13 @@ speechSynthesis.getVoices(); // status var compareByStatus = function (a, b) { - if ((typeof a.ref === 'undefined') || (typeof b.ref === 'undefined')) { + if (typeof a.ref === 'undefined' || typeof b.ref === 'undefined') { return 0; } - if (($app.orderFriendsGroupPrivate) && ((a.ref.location !== 'private') || (b.ref.location !== 'private'))) { + if ( + $app.orderFriendsGroupPrivate && + (a.ref.location !== 'private' || b.ref.location !== 'private') + ) { return 0; } if (a.ref.status === b.ref.status) { @@ -5951,10 +6447,8 @@ speechSynthesis.getVoices(); return -1; } break; - default: - return 0; - break; } + return 0; }; // location at @@ -6049,16 +6543,20 @@ speechSynthesis.getVoices(); } else if (user.userId) { id = user.userId; } - if ((id) && (id === API.currentUser.id)) { + if (id && id === API.currentUser.id) { return this.statusClass(user.status); } if (!user.isFriend) { - return; + return ''; } - //temp fix - if ((user.status !== 'active') && (user.location === 'private') && (user.state === '') && - (id) && - (!API.currentUser.onlineFriends.includes(id))) { + // temp fix + if ( + user.status !== 'active' && + user.location === 'private' && + user.state === '' && + id && + !API.currentUser.onlineFriends.includes(id) + ) { if (API.currentUser.activeFriends.includes(id)) { // Active style.active = true; @@ -6141,11 +6639,11 @@ speechSynthesis.getVoices(); var match = NAME.includes(QUERY); if (!match) { var uname = String(ctx.ref.username); - match = uname.toUpperCase().includes(QUERY) && + match = + uname.toUpperCase().includes(QUERY) && !uname.startsWith('steam_'); } - if (!match && - ctx.memo) { + if (!match && ctx.memo) { match = String(ctx.memo).toUpperCase().includes(QUERY); } if (match) { @@ -6213,7 +6711,8 @@ speechSynthesis.getVoices(); { prop: 'type', value: [], - filterFn: (row, filter) => filter.value.some((v) => v === row.type) + filterFn: (row, filter) => + filter.value.some((v) => v === row.type) }, { prop: 'displayName', @@ -6222,7 +6721,8 @@ speechSynthesis.getVoices(); { prop: 'userId', value: false, - filterFn: (row, filter) => !filter.value || + filterFn: (row, filter) => + !filter.value || API.cachedFavoritesByObjectId.has(row.userId) } ], @@ -6238,12 +6738,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', - pageSizes: [ - 10, - 25, - 50, - 100 - ] + pageSizes: [10, 25, 50, 100] } }; @@ -6257,7 +6752,7 @@ speechSynthesis.getVoices(); } else { $app.initFriendLog(args.json.id); } - //remove old data from json file and migrate to SQLite + // remove old data from json file and migrate to SQLite if (VRCXStorage.Get(`${args.json.id}_friendLogUpdatedAt`)) { VRCXStorage.Remove(`${args.json.id}_feedTable`); $app.migrateMemos(); @@ -6266,15 +6761,17 @@ speechSynthesis.getVoices(); }); API.$on('USER:UPDATE', async function (args) { - var { ref, props } = args; + var {ref, props} = args; if ($app.friends.has(ref.id) === false) { return; } - if ((props.location) && - (props.location[0] !== 'offline') && - (props.location[0] !== '') && - (props.location[1] !== 'offline') && - (props.location[1] !== '')) { + if ( + props.location && + props.location[0] !== 'offline' && + props.location[0] !== '' && + props.location[1] !== 'offline' && + props.location[1] !== '' + ) { var worldName = await $app.getWorldName(props.location[0]); var feed = { created_at: new Date().toJSON(), @@ -6291,8 +6788,10 @@ speechSynthesis.getVoices(); $app.updateFriendGPS(ref.id); $app.feedDownloadWorldCache(ref.id, props.location[0]); } - if (props.currentAvatarImageUrl || - props.currentAvatarThumbnailImageUrl) { + if ( + props.currentAvatarImageUrl || + props.currentAvatarThumbnailImageUrl + ) { var currentAvatarImageUrl = ''; var previousCurrentAvatarImageUrl = ''; var currentAvatarThumbnailImageUrl = ''; @@ -6305,20 +6804,23 @@ speechSynthesis.getVoices(); previousCurrentAvatarImageUrl = ref.currentAvatarImageUrl; } if (props.currentAvatarThumbnailImageUrl) { - currentAvatarThumbnailImageUrl = props.currentAvatarThumbnailImageUrl[0]; - previousCurrentAvatarThumbnailImageUrl = props.currentAvatarThumbnailImageUrl[1]; + currentAvatarThumbnailImageUrl = + props.currentAvatarThumbnailImageUrl[0]; + previousCurrentAvatarThumbnailImageUrl = + props.currentAvatarThumbnailImageUrl[1]; } else { - currentAvatarThumbnailImageUrl = ref.currentAvatarThumbnailImageUrl; - previousCurrentAvatarThumbnailImageUrl = ref.currentAvatarThumbnailImageUrl; + currentAvatarThumbnailImageUrl = + ref.currentAvatarThumbnailImageUrl; + previousCurrentAvatarThumbnailImageUrl = + ref.currentAvatarThumbnailImageUrl; } var avatarInfo = { ownerId: '', avatarName: '' - } + }; try { avatarInfo = await $app.getAvatarName(currentAvatarImageUrl); - } catch (err) { - } + } catch (err) {} var feed = { created_at: new Date().toJSON(), type: 'Avatar', @@ -6334,8 +6836,7 @@ speechSynthesis.getVoices(); $app.addFeed(feed); database.addAvatarToDatabase(feed); } - if (props.status || - props.statusDescription) { + if (props.status || props.statusDescription) { var status = ''; var previousStatus = ''; var statusDescription = ''; @@ -6394,37 +6895,51 @@ speechSynthesis.getVoices(); if (action === 'confirm') { // 필터된 데이터만 삭제 하려면.. 허어 var T = this.feedTable; - T.data = T.data.filter((row) => !T.filters.every((filter) => { - if (filter.value) { - if (!Array.isArray(filter.value)) { - if (filter.filterFn) { - return filter.filterFn(row, filter); + T.data = T.data.filter( + (row) => + !T.filters.every((filter) => { + if (filter.value) { + if (!Array.isArray(filter.value)) { + if (filter.filterFn) { + return filter.filterFn(row, filter); + } + return String(row[filter.prop]) + .toUpperCase() + .includes( + String( + filter.value + ).toUpperCase() + ); + } + if (filter.value.length) { + if (filter.filterFn) { + return filter.filterFn(row, filter); + } + var prop = String( + row[filter.prop] + ).toUpperCase(); + return filter.value.some((v) => + prop.includes( + String(v).toUpperCase() + ) + ); + } } - return String(row[filter.prop]).toUpperCase().includes(String(filter.value).toUpperCase()); - } - if (filter.value.length) { - if (filter.filterFn) { - return filter.filterFn(row, filter); - } - var prop = String(row[filter.prop]).toUpperCase(); - return filter.value.some((v) => prop.includes(String(v).toUpperCase())); - } - } - return true; - })); + return true; + }) + ); } } }); }; $app.methods.sweepFeed = function () { - var { data } = this.feedTable; + var {data} = this.feedTable; // 로그는 3일까지만 남김 var limit = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toJSON(); var i = 0; var j = data.length; - while (i < j && - data[i].created_at < limit) { + while (i < j && data[i].created_at < limit) { ++i; } if (i === j) { @@ -6460,7 +6975,8 @@ speechSynthesis.getVoices(); { prop: 'type', value: [], - filterFn: (row, filter) => filter.value.some((v) => v === row.type) + filterFn: (row, filter) => + filter.value.some((v) => v === row.type) }, { prop: 'data', @@ -6469,12 +6985,12 @@ speechSynthesis.getVoices(); { prop: 'data', value: true, - filterFn: (row, filter) => row.data !== API.currentUser.displayName + filterFn: (row) => row.data !== API.currentUser.displayName }, { prop: 'type', value: true, - filterFn: (row, filter) => row.type !== 'Notification' + filterFn: (row) => row.type !== 'Notification' } ], tableProps: { @@ -6489,12 +7005,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', - pageSizes: [ - 10, - 25, - 50, - 100 - ] + pageSizes: [10, 25, 50, 100] } }; @@ -6518,10 +7029,14 @@ speechSynthesis.getVoices(); this.sweepGameLog(); var length = this.gameLogTable.data.length; if (length > 0) { - if (this.gameLogTable.data[length - 1].created_at !== this.gameLogTable.lastEntryDate) { + if ( + this.gameLogTable.data[length - 1].created_at !== + this.gameLogTable.lastEntryDate + ) { this.notifyMenu('gameLog'); } - this.gameLogTable.lastEntryDate = this.gameLogTable.data[length - 1].created_at; + this.gameLogTable.lastEntryDate = + this.gameLogTable.data[length - 1].created_at; } this.updateSharedFeed(false); } @@ -6601,9 +7116,6 @@ speechSynthesis.getVoices(); displayName: gameLog.displayName }; break; - - default: - break; } if (tableData !== null) { @@ -6613,13 +7125,12 @@ speechSynthesis.getVoices(); }; $app.methods.sweepGameLog = function () { - var { data } = this.gameLogTable; + var {data} = this.gameLogTable; // 로그는 7일까지만 남김 var limit = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toJSON(); var i = 0; var j = data.length; - while (i < j && - data[i].created_at < limit) { + while (i < j && data[i].created_at < limit) { ++i; } if (i === j) { @@ -6640,8 +7151,7 @@ speechSynthesis.getVoices(); }); } } - if (this.isGameRunning === false || - this.lastLocation.location === '') { + if (this.isGameRunning === false || this.lastLocation.location === '') { Discord.SetActive(false); return; } @@ -6670,7 +7180,10 @@ speechSynthesis.getVoices(); LL.worldName += '\uFFA0'.repeat(2 - LL.worldName.length); } if (this.discordInstance) { - Discord.SetText(LL.worldName, `#${LL.instanceName} ${LL.accessType}`); + Discord.SetText( + LL.worldName, + `#${LL.instanceName} ${LL.accessType}` + ); } else { Discord.SetText(LL.worldName, ''); } @@ -6755,19 +7268,21 @@ speechSynthesis.getVoices(); } } this.isSearchUserLoading = true; - await API.getUsers(params).finally(() => { - this.isSearchUserLoading = false; - }).then((args) => { - var map = new Map(); - for (var json of args.json) { - var ref = API.cachedUsers.get(json.id); - if (typeof ref !== 'undefined') { - map.set(ref.id, ref); + await API.getUsers(params) + .finally(() => { + this.isSearchUserLoading = false; + }) + .then((args) => { + var map = new Map(); + for (var json of args.json) { + var ref = API.cachedUsers.get(json.id); + if (typeof ref !== 'undefined') { + map.set(ref.id, ref); + } } - } - this.searchUserResults = Array.from(map.values()); - return args; - }); + this.searchUserResults = Array.from(map.values()); + return args; + }); }; $app.data.searchWorldLabs = false; @@ -6842,19 +7357,21 @@ speechSynthesis.getVoices(); } } this.isSearchWorldLoading = true; - API.getWorlds(params, this.searchWorldOption).finally(() => { - this.isSearchWorldLoading = false; - }).then((args) => { - var map = new Map(); - for (var json of args.json) { - var ref = API.cachedWorlds.get(json.id); - if (typeof ref !== 'undefined') { - map.set(ref.id, ref); + API.getWorlds(params, this.searchWorldOption) + .finally(() => { + this.isSearchWorldLoading = false; + }) + .then((args) => { + var map = new Map(); + for (var json of args.json) { + var ref = API.cachedWorlds.get(json.id); + if (typeof ref !== 'undefined') { + map.set(ref.id, ref); + } } - } - this.searchWorldResults = Array.from(map.values()); - return args; - }); + this.searchWorldResults = Array.from(map.values()); + return args; + }); }; $app.methods.searchAvatar = function (option) { @@ -6893,19 +7410,21 @@ speechSynthesis.getVoices(); } } this.isSearchAvatarLoading = true; - API.getAvatars(params).finally(() => { - this.isSearchAvatarLoading = false; - }).then((args) => { - var map = new Map(); - for (var json of args.json) { - var ref = API.cachedAvatars.get(json.id); - if (typeof ref !== 'undefined') { - map.set(ref.id, ref); + API.getAvatars(params) + .finally(() => { + this.isSearchAvatarLoading = false; + }) + .then((args) => { + var map = new Map(); + for (var json of args.json) { + var ref = API.cachedAvatars.get(json.id); + if (typeof ref !== 'undefined') { + map.set(ref.id, ref); + } } - } - this.searchAvatarResults = Array.from(map.values()); - return args; - }); + this.searchAvatarResults = Array.from(map.values()); + return args; + }); }; // App: Favorite @@ -6966,8 +7485,7 @@ speechSynthesis.getVoices(); var ref = API.cachedUsers.get(objectId); if (typeof ref === 'undefined') { ref = this.friendLog.get(objectId); - if (typeof ref !== 'undefined' && - ref.displayName) { + if (typeof ref !== 'undefined' && ref.displayName) { ctx.name = ref.displayName; } } else { @@ -7152,7 +7670,8 @@ speechSynthesis.getVoices(); { prop: 'type', value: [], - filterFn: (row, filter) => filter.value.some((v) => v === row.type) + filterFn: (row, filter) => + filter.value.some((v) => v === row.type) }, { prop: 'displayName', @@ -7171,12 +7690,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', - pageSizes: [ - 10, - 25, - 50, - 100 - ] + pageSizes: [10, 25, 50, 100] } }; @@ -7249,7 +7763,9 @@ speechSynthesis.getVoices(); $app.methods.migrateFriendLog = function (userId) { VRCXStorage.Remove(`${userId}_friendLogUpdatedAt`); VRCXStorage.Remove(`${userId}_friendLog`); - this.friendLogTable.data = VRCXStorage.GetArray(`${userId}_friendLogTable`); + this.friendLogTable.data = VRCXStorage.GetArray( + `${userId}_friendLogTable` + ); database.addFriendLogHistoryArray(this.friendLogTable.data); VRCXStorage.Remove(`${userId}_friendLogTable`); configRepository.setBool(`friendLogInit_${userId}`, true); @@ -7267,7 +7783,7 @@ speechSynthesis.getVoices(); }; $app.methods.addFriendship = function (id) { - if ((!this.friendLogInitStatus) || (this.friendLog.has(id))) { + if (!this.friendLogInitStatus || this.friendLog.has(id)) { return; } var ctx = { @@ -7331,7 +7847,7 @@ speechSynthesis.getVoices(); $app.methods.updateFriendship = function (ref) { var ctx = this.friendLog.get(ref.id); - if ((!this.friendLogInitStatus) || (typeof ctx === 'undefined')) { + if (!this.friendLogInitStatus || typeof ctx === 'undefined') { return; } if (ctx.displayName !== ref.displayName) { @@ -7365,10 +7881,14 @@ speechSynthesis.getVoices(); ctx.displayName = ref.displayName; this.notifyMenu('friendLog'); } - if (ref.$trustLevel && - ctx.trustLevel !== ref.$trustLevel) { - if ((ctx.trustLevel) && - (ctx.trustLevel !== 'Legendary User') && (ctx.trustLevel !== 'VRChat Team') && (ctx.trustLevel !== 'Nuisance')) { // TODO: remove + if (ref.$trustLevel && ctx.trustLevel !== ref.$trustLevel) { + if ( + ctx.trustLevel && + ctx.trustLevel !== 'Legendary User' && + ctx.trustLevel !== 'VRChat Team' && + ctx.trustLevel !== 'Nuisance' + ) { + // TODO: remove var friendLogHistory = { created_at: new Date().toJSON(), type: 'TrustLevel', @@ -7399,8 +7919,10 @@ speechSynthesis.getVoices(); cancelButtonText: 'Cancel', type: 'info', callback: (action) => { - if (action === 'confirm' && - removeFromArray(this.friendLogTable.data, row)) { + if ( + action === 'confirm' && + removeFromArray(this.friendLogTable.data, row) + ) { database.deleteFriendLogHistory(row.rowId); } } @@ -7416,13 +7938,11 @@ speechSynthesis.getVoices(); { prop: 'type', value: [], - filterFn: (row, filter) => filter.value.some((v) => v === row.type) + filterFn: (row, filter) => + filter.value.some((v) => v === row.type) }, { - prop: [ - 'sourceDisplayName', - 'targetDisplayName' - ], + prop: ['sourceDisplayName', 'targetDisplayName'], value: '' } ], @@ -7438,12 +7958,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', - pageSizes: [ - 10, - 25, - 50, - 100 - ] + pageSizes: [10, 25, 50, 100] } }; @@ -7452,9 +7967,9 @@ speechSynthesis.getVoices(); }); API.$on('PLAYER-MODERATION', function (args) { - var { ref } = args; + var {ref} = args; var array = $app.playerModerationTable.data; - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (array[i].id === ref.id) { if (ref.$isDeleted) { @@ -7471,9 +7986,9 @@ speechSynthesis.getVoices(); }); API.$on('PLAYER-MODERATION:@DELETE', function (args) { - var { ref } = args; + var {ref} = args; var array = $app.playerModerationTable.data; - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (array[i].id === ref.id) { array.splice(i, 1); @@ -7507,7 +8022,8 @@ speechSynthesis.getVoices(); { prop: 'type', value: [], - filterFn: (row, filter) => filter.value.some((v) => v === row.type) + filterFn: (row, filter) => + filter.value.some((v) => v === row.type) }, { prop: 'senderUsername', @@ -7526,12 +8042,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', - pageSizes: [ - 10, - 25, - 50, - 100 - ] + pageSizes: [10, 25, 50, 100] } }; @@ -7542,9 +8053,9 @@ speechSynthesis.getVoices(); $app.data.unseenNotifications = []; API.$on('NOTIFICATION', function (args) { - var { ref } = args; + var {ref} = args; var array = $app.notificationTable.data; - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (array[i].id === ref.id) { if (ref.$isDeleted) { @@ -7566,7 +8077,7 @@ speechSynthesis.getVoices(); }); API.$on('NOTIFICATION:SEE', function (args) { - var { notificationId } = args.params; + var {notificationId} = args.params; removeFromArray($app.unseenNotifications, notificationId); if ($app.unseenNotifications.length === 0) { $app.selectMenu('notification'); @@ -7574,9 +8085,9 @@ speechSynthesis.getVoices(); }); API.$on('NOTIFICATION:@DELETE', function (args) { - var { ref } = args; + var {ref} = args; var array = $app.notificationTable.data; - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (array[i].id === ref.id) { array.splice(i, 1); @@ -7610,7 +8121,8 @@ speechSynthesis.getVoices(); callback: (action) => { if (action === 'confirm') { if (row.type === 'hiddenFriendRequest') { - API.deleteHiddenFriendRequest({ + API.deleteHiddenFriendRequest( + { notificationId: row.id }, row.senderUserId @@ -7627,28 +8139,58 @@ speechSynthesis.getVoices(); // Save Table Filters $app.methods.saveTableFilters = function () { - configRepository.setString('VRCX_feedTableFilters', JSON.stringify(this.feedTable.filters[0].value)); - configRepository.setBool('VRCX_feedTableVIPFilter', this.feedTable.filters[2].value); - configRepository.setString('VRCX_gameLogTableFilters', JSON.stringify(this.gameLogTable.filters[0].value)); - configRepository.setString('VRCX_friendLogTableFilters', JSON.stringify(this.friendLogTable.filters[0].value)); - configRepository.setString('VRCX_playerModerationTableFilters', JSON.stringify(this.playerModerationTable.filters[0].value)); - configRepository.setString('VRCX_notificationTableFilters', JSON.stringify(this.notificationTable.filters[0].value)); + configRepository.setString( + 'VRCX_feedTableFilters', + JSON.stringify(this.feedTable.filters[0].value) + ); + configRepository.setBool( + 'VRCX_feedTableVIPFilter', + this.feedTable.filters[2].value + ); + configRepository.setString( + 'VRCX_gameLogTableFilters', + JSON.stringify(this.gameLogTable.filters[0].value) + ); + configRepository.setString( + 'VRCX_friendLogTableFilters', + JSON.stringify(this.friendLogTable.filters[0].value) + ); + configRepository.setString( + 'VRCX_playerModerationTableFilters', + JSON.stringify(this.playerModerationTable.filters[0].value) + ); + configRepository.setString( + 'VRCX_notificationTableFilters', + JSON.stringify(this.notificationTable.filters[0].value) + ); }; if (configRepository.getString('VRCX_feedTableFilters')) { - $app.data.feedTable.filters[0].value = JSON.parse(configRepository.getString('VRCX_feedTableFilters')); - $app.data.feedTable.filters[2].value = configRepository.getBool('VRCX_feedTableVIPFilter'); + $app.data.feedTable.filters[0].value = JSON.parse( + configRepository.getString('VRCX_feedTableFilters') + ); + $app.data.feedTable.filters[2].value = configRepository.getBool( + 'VRCX_feedTableVIPFilter' + ); } if (configRepository.getString('VRCX_gameLogTableFilters')) { - $app.data.gameLogTable.filters[0].value = JSON.parse(configRepository.getString('VRCX_gameLogTableFilters')); + $app.data.gameLogTable.filters[0].value = JSON.parse( + configRepository.getString('VRCX_gameLogTableFilters') + ); } if (configRepository.getString('VRCX_friendLogTableFilters')) { - $app.data.friendLogTable.filters[0].value = JSON.parse(configRepository.getString('VRCX_friendLogTableFilters')); + $app.data.friendLogTable.filters[0].value = JSON.parse( + configRepository.getString('VRCX_friendLogTableFilters') + ); } if (configRepository.getString('VRCX_playerModerationTableFilters')) { - $app.data.playerModerationTable.filters[0].value = JSON.parse(configRepository.getString('VRCX_playerModerationTableFilters')); + $app.data.playerModerationTable.filters[0].value = JSON.parse( + configRepository.getString('VRCX_playerModerationTableFilters') + ); } if (configRepository.getString('VRCX_notificationTableFilters')) { - $app.data.notificationTable.filters[0].value = JSON.parse(configRepository.getString('VRCX_notificationTableFilters')); + $app.data.notificationTable.filters[0].value = JSON.parse( + configRepository.getString('VRCX_notificationTableFilters') + ); } // App: Profile + Settings @@ -7720,12 +8262,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', - pageSizes: [ - 50, - 100, - 250, - 500 - ] + pageSizes: [50, 100, 250, 500] } }; $app.data.downloadHistoryTable = { @@ -7738,12 +8275,7 @@ speechSynthesis.getVoices(); paginationProps: { small: true, layout: 'prev,pager,next', - pageSizes: [ - 10, - 25, - 50, - 100 - ] + pageSizes: [10, 25, 50, 100] } }; $app.data.downloadQueueTable = { @@ -7766,57 +8298,128 @@ speechSynthesis.getVoices(); $app.data.openVR = configRepository.getBool('openVR'); $app.data.openVRAlways = configRepository.getBool('openVRAlways'); $app.data.overlaybutton = configRepository.getBool('VRCX_overlaybutton'); - $app.data.hidePrivateFromFeed = configRepository.getBool('VRCX_hidePrivateFromFeed'); - $app.data.hideDevicesFromFeed = configRepository.getBool('VRCX_hideDevicesFromFeed'); - $app.data.overlayNotifications = configRepository.getBool('VRCX_overlayNotifications'); + $app.data.hidePrivateFromFeed = configRepository.getBool( + 'VRCX_hidePrivateFromFeed' + ); + $app.data.hideDevicesFromFeed = configRepository.getBool( + 'VRCX_hideDevicesFromFeed' + ); + $app.data.overlayNotifications = configRepository.getBool( + 'VRCX_overlayNotifications' + ); $app.data.overlayWrist = configRepository.getBool('VRCX_overlayWrist'); - $app.data.xsNotifications = configRepository.getBool('VRCX_xsNotifications'); + $app.data.xsNotifications = configRepository.getBool( + 'VRCX_xsNotifications' + ); $app.data.desktopToast = configRepository.getString('VRCX_desktopToast'); $app.data.minimalFeed = configRepository.getBool('VRCX_minimalFeed'); - $app.data.displayVRCPlusIconsAsAvatar = configRepository.getBool('displayVRCPlusIconsAsAvatar'); - $app.data.displayProfilePicOverrideAsAvatar = configRepository.getBool('VRCX_displayProfilePicOverrideAsAvatar'); + $app.data.displayVRCPlusIconsAsAvatar = configRepository.getBool( + 'displayVRCPlusIconsAsAvatar' + ); + $app.data.displayProfilePicOverrideAsAvatar = configRepository.getBool( + 'VRCX_displayProfilePicOverrideAsAvatar' + ); $app.data.hideTooltips = configRepository.getBool('VRCX_hideTooltips'); - $app.data.notificationTTS = configRepository.getString('VRCX_notificationTTS'); - $app.data.notificationTTSVoice = configRepository.getString('VRCX_notificationTTSVoice'); - $app.data.notificationTimeout = configRepository.getString('VRCX_notificationTimeout'); - $app.data.worldAutoCacheInvite = configRepository.getString('VRCX_worldAutoCacheInvite'); - $app.data.worldAutoCacheGPS = configRepository.getString('VRCX_worldAutoCacheGPS'); - $app.data.worldAutoCacheInviteFilter = configRepository.getBool('VRCX_worldAutoCacheInviteFilter'); - $app.data.worldAutoCacheGPSFilter = configRepository.getBool('VRCX_worldAutoCacheGPSFilter'); - $app.data.autoSweepVRChatCache = configRepository.getBool('VRCX_autoSweepVRChatCache'); - $app.data.vrBackgroundEnabled = configRepository.getBool('VRCX_vrBackgroundEnabled'); + $app.data.notificationTTS = configRepository.getString( + 'VRCX_notificationTTS' + ); + $app.data.notificationTTSVoice = configRepository.getString( + 'VRCX_notificationTTSVoice' + ); + $app.data.notificationTimeout = configRepository.getString( + 'VRCX_notificationTimeout' + ); + $app.data.worldAutoCacheInvite = configRepository.getString( + 'VRCX_worldAutoCacheInvite' + ); + $app.data.worldAutoCacheGPS = configRepository.getString( + 'VRCX_worldAutoCacheGPS' + ); + $app.data.worldAutoCacheInviteFilter = configRepository.getBool( + 'VRCX_worldAutoCacheInviteFilter' + ); + $app.data.worldAutoCacheGPSFilter = configRepository.getBool( + 'VRCX_worldAutoCacheGPSFilter' + ); + $app.data.autoSweepVRChatCache = configRepository.getBool( + 'VRCX_autoSweepVRChatCache' + ); + $app.data.vrBackgroundEnabled = configRepository.getBool( + 'VRCX_vrBackgroundEnabled' + ); $app.data.asideWidth = configRepository.getInt('VRCX_asidewidth'); - $app.data.autoUpdateVRCX = configRepository.getString('VRCX_autoUpdateVRCX'); + $app.data.autoUpdateVRCX = configRepository.getString( + 'VRCX_autoUpdateVRCX' + ); $app.data.branch = configRepository.getString('VRCX_branch'); var saveOpenVROption = function () { configRepository.setBool('openVR', this.openVR); configRepository.setBool('openVRAlways', this.openVRAlways); configRepository.setBool('VRCX_overlaybutton', this.overlaybutton); - configRepository.setBool('VRCX_hidePrivateFromFeed', this.hidePrivateFromFeed); - configRepository.setBool('VRCX_hideDevicesFromFeed', this.hideDevicesFromFeed); - configRepository.setBool('VRCX_overlayNotifications', this.overlayNotifications); + configRepository.setBool( + 'VRCX_hidePrivateFromFeed', + this.hidePrivateFromFeed + ); + configRepository.setBool( + 'VRCX_hideDevicesFromFeed', + this.hideDevicesFromFeed + ); + configRepository.setBool( + 'VRCX_overlayNotifications', + this.overlayNotifications + ); configRepository.setBool('VRCX_overlayWrist', this.overlayWrist); configRepository.setBool('VRCX_xsNotifications', this.xsNotifications); configRepository.setString('VRCX_desktopToast', this.desktopToast); configRepository.setBool('VRCX_minimalFeed', this.minimalFeed); - configRepository.setBool('displayVRCPlusIconsAsAvatar', this.displayVRCPlusIconsAsAvatar); - configRepository.setBool('VRCX_displayProfilePicOverrideAsAvatar', this.displayProfilePicOverrideAsAvatar); + configRepository.setBool( + 'displayVRCPlusIconsAsAvatar', + this.displayVRCPlusIconsAsAvatar + ); + configRepository.setBool( + 'VRCX_displayProfilePicOverrideAsAvatar', + this.displayProfilePicOverrideAsAvatar + ); configRepository.setBool('VRCX_hideTooltips', this.hideTooltips); - configRepository.setString('VRCX_worldAutoCacheInvite', this.worldAutoCacheInvite); - configRepository.setString('VRCX_worldAutoCacheGPS', this.worldAutoCacheGPS); - configRepository.setBool('VRCX_worldAutoCacheInviteFilter', this.worldAutoCacheInviteFilter); - configRepository.setBool('VRCX_worldAutoCacheGPSFilter', this.worldAutoCacheGPSFilter); - configRepository.setBool('VRCX_autoSweepVRChatCache', this.autoSweepVRChatCache); - configRepository.setBool('VRCX_vrBackgroundEnabled', this.vrBackgroundEnabled); + configRepository.setString( + 'VRCX_worldAutoCacheInvite', + this.worldAutoCacheInvite + ); + configRepository.setString( + 'VRCX_worldAutoCacheGPS', + this.worldAutoCacheGPS + ); + configRepository.setBool( + 'VRCX_worldAutoCacheInviteFilter', + this.worldAutoCacheInviteFilter + ); + configRepository.setBool( + 'VRCX_worldAutoCacheGPSFilter', + this.worldAutoCacheGPSFilter + ); + configRepository.setBool( + 'VRCX_autoSweepVRChatCache', + this.autoSweepVRChatCache + ); + configRepository.setBool( + 'VRCX_vrBackgroundEnabled', + this.vrBackgroundEnabled + ); this.updateVRConfigVars(); }; $app.data.TTSvoices = speechSynthesis.getVoices(); var saveNotificationTTS = function () { speechSynthesis.cancel(); - if ((configRepository.getString('VRCX_notificationTTS') === 'Never') && (this.notificationTTS !== 'Never')) { + if ( + configRepository.getString('VRCX_notificationTTS') === 'Never' && + this.notificationTTS !== 'Never' + ) { this.speak('Notification text-to-speech enabled'); } - configRepository.setString('VRCX_notificationTTS', this.notificationTTS); + configRepository.setString( + 'VRCX_notificationTTS', + this.notificationTTS + ); this.updateVRConfigVars(); }; $app.watch.openVR = saveOpenVROption; @@ -7843,17 +8446,23 @@ speechSynthesis.getVoices(); if (!$app.data.themeMode) { $app.data.themeMode = 'system'; } - var systemIsDarkMode = _ => window.matchMedia('(prefers-color-scheme: dark)').matches; - $app.data.isDarkMode = $app.data.themeMode === 'system' ? systemIsDarkMode() : configRepository.getBool('isDarkMode'); + var systemIsDarkMode = () => + window.matchMedia('(prefers-color-scheme: dark)').matches; + $app.data.isDarkMode = + $app.data.themeMode === 'system' + ? systemIsDarkMode() + : configRepository.getBool('isDarkMode'); $appDarkStyle.disabled = $app.data.isDarkMode === false; $app.watch.isDarkMode = function () { configRepository.setBool('isDarkMode', this.isDarkMode); $appDarkStyle.disabled = this.isDarkMode === false; this.updateVRConfigVars(); }; - window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => { - $app._data.isDarkMode = e && e.matches; - }) + window + .matchMedia('(prefers-color-scheme: dark)') + .addEventListener('change', (e) => { + $app._data.isDarkMode = e && e.matches; + }); $app.watch.themeMode = function () { configRepository.setString('VRCX_ThemeMode', this.themeMode); if (this.themeMode === 'system') { @@ -7861,13 +8470,22 @@ speechSynthesis.getVoices(); } else { this.isDarkMode = this.themeMode === 'dark'; } - } - $app.data.isStartAtWindowsStartup = configRepository.getBool('VRCX_StartAtWindowsStartup'); - $app.data.isStartAsMinimizedState = (VRCXStorage.Get('VRCX_StartAsMinimizedState') === 'true'); + }; + $app.data.isStartAtWindowsStartup = configRepository.getBool( + 'VRCX_StartAtWindowsStartup' + ); + $app.data.isStartAsMinimizedState = + VRCXStorage.Get('VRCX_StartAsMinimizedState') === 'true'; $app.data.isCloseToTray = configRepository.getBool('VRCX_CloseToTray'); var saveVRCXWindowOption = function () { - configRepository.setBool('VRCX_StartAtWindowsStartup', this.isStartAtWindowsStartup); - VRCXStorage.Set('VRCX_StartAsMinimizedState', this.isStartAsMinimizedState.toString()); + configRepository.setBool( + 'VRCX_StartAtWindowsStartup', + this.isStartAtWindowsStartup + ); + VRCXStorage.Set( + 'VRCX_StartAsMinimizedState', + this.isStartAsMinimizedState.toString() + ); configRepository.setBool('VRCX_CloseToTray', this.isCloseToTray); AppApi.SetStartup(this.isStartAtWindowsStartup); }; @@ -7878,15 +8496,24 @@ speechSynthesis.getVoices(); // setting defaults if (!configRepository.getString('VRCX_notificationPosition')) { $app.data.notificationPosition = 'topCenter'; - configRepository.setString('VRCX_notificationPosition', $app.data.notificationPosition); + configRepository.setString( + 'VRCX_notificationPosition', + $app.data.notificationPosition + ); } if (!configRepository.getString('VRCX_notificationTimeout')) { $app.data.notificationTimeout = 3000; - configRepository.setString('VRCX_notificationTimeout', $app.data.notificationTimeout); + configRepository.setString( + 'VRCX_notificationTimeout', + $app.data.notificationTimeout + ); } if (!configRepository.getString('VRCX_notificationTTSVoice')) { $app.data.notificationTTSVoice = '0'; - configRepository.setString('VRCX_notificationTTSVoice', $app.data.notificationTTSVoice); + configRepository.setString( + 'VRCX_notificationTTSVoice', + $app.data.notificationTTSVoice + ); } if (!configRepository.getString('VRCX_desktopToast')) { $app.data.desktopToast = 'Never'; @@ -7894,19 +8521,31 @@ speechSynthesis.getVoices(); } if (!configRepository.getString('VRCX_notificationTTS')) { $app.data.notificationTTS = 'Never'; - configRepository.setString('VRCX_notificationTTS', $app.data.notificationTTS); + configRepository.setString( + 'VRCX_notificationTTS', + $app.data.notificationTTS + ); } if (!configRepository.getString('VRCX_worldAutoCacheInvite')) { $app.data.worldAutoCacheInvite = 'Never'; - configRepository.setString('VRCX_worldAutoCacheInvite', $app.data.worldAutoCacheInvite); + configRepository.setString( + 'VRCX_worldAutoCacheInvite', + $app.data.worldAutoCacheInvite + ); } if (!configRepository.getString('VRCX_worldAutoCacheGPS')) { $app.data.worldAutoCacheGPS = 'Never'; - configRepository.setString('VRCX_worldAutoCacheGPS', $app.data.worldAutoCacheGPS); + configRepository.setString( + 'VRCX_worldAutoCacheGPS', + $app.data.worldAutoCacheGPS + ); } if (!configRepository.getBool('VRCX_vrBackgroundEnabled')) { $app.data.vrBackgroundEnabled = false; - configRepository.setBool('VRCX_vrBackgroundEnabled', $app.data.vrBackgroundEnabled); + configRepository.setBool( + 'VRCX_vrBackgroundEnabled', + $app.data.vrBackgroundEnabled + ); } if (!configRepository.getInt('VRCX_asidewidth')) { $app.data.asideWidth = 236; @@ -7914,7 +8553,10 @@ speechSynthesis.getVoices(); } if (!configRepository.getString('VRCX_autoUpdateVRCX')) { $app.data.autoUpdateVRCX = 'Notify'; - configRepository.setString('VRCX_autoUpdateVRCX', $app.data.autoUpdateVRCX); + configRepository.setString( + 'VRCX_autoUpdateVRCX', + $app.data.autoUpdateVRCX + ); } if (!configRepository.getString('VRCX_branch')) { $app.data.branch = 'Stable'; @@ -7981,34 +8623,61 @@ speechSynthesis.getVoices(); MutedOnPlayerLeft: 'Off' } }; - configRepository.setString('sharedFeedFilters', JSON.stringify(sharedFeedFilters)); + configRepository.setString( + 'sharedFeedFilters', + JSON.stringify(sharedFeedFilters) + ); } - $app.data.sharedFeedFilters = JSON.parse(configRepository.getString('sharedFeedFilters')); + $app.data.sharedFeedFilters = JSON.parse( + configRepository.getString('sharedFeedFilters') + ); if (!configRepository.getString('VRCX_trustColor')) { - var trustColor = { - untrusted: '#CCCCCC', - basic: '#1778FF', - known: '#2BCF5C', - trusted: '#FF7B42', - veteran: '#B18FFF', - legend: '#FFD000', - legendary: '#FF69B4', - vip: '#FF2626', - troll: '#782F2F' - }; - configRepository.setString('VRCX_trustColor', JSON.stringify(trustColor)); + configRepository.setString( + 'VRCX_trustColor', + JSON.stringify({ + untrusted: '#CCCCCC', + basic: '#1778FF', + known: '#2BCF5C', + trusted: '#FF7B42', + veteran: '#B18FFF', + legend: '#FFD000', + legendary: '#FF69B4', + vip: '#FF2626', + troll: '#782F2F' + }) + ); } - $app.data.trustColor = JSON.parse(configRepository.getString('VRCX_trustColor')); + $app.data.trustColor = JSON.parse( + configRepository.getString('VRCX_trustColor') + ); - $app.data.trustColorSwatches = ['#CCCCCC', '#1778FF', '#2BCF5C', '#FF7B42', '#B18FFF', '#FFD000', '#FF69B4', '#ABCDEF', '#8143E6', '#B52626', '#FF2626', '#782F2F']; + $app.data.trustColorSwatches = [ + '#CCCCCC', + '#1778FF', + '#2BCF5C', + '#FF7B42', + '#B18FFF', + '#FFD000', + '#FF69B4', + '#ABCDEF', + '#8143E6', + '#B52626', + '#FF2626', + '#782F2F' + ]; $app.methods.updatetrustColor = function () { var trustColor = $app.trustColor; if (trustColor) { - configRepository.setString('VRCX_trustColor', JSON.stringify(trustColor)); + configRepository.setString( + 'VRCX_trustColor', + JSON.stringify(trustColor) + ); } else { - trustColor = JSON.parse(configRepository.getString('VRCX_trustColor')); + trustColor = JSON.parse( + configRepository.getString('VRCX_trustColor') + ); $app.trustColor = trustColor; } if (document.getElementById('trustColor') !== null) { @@ -8038,19 +8707,29 @@ speechSynthesis.getVoices(); $app.methods.saveSharedFeedFilters = function () { this.notyFeedFiltersDialog.visible = false; this.wristFeedFiltersDialog.visible = false; - configRepository.setString('sharedFeedFilters', JSON.stringify(this.sharedFeedFilters)); + configRepository.setString( + 'sharedFeedFilters', + JSON.stringify(this.sharedFeedFilters) + ); this.updateVRConfigVars(); }; $app.methods.cancelSharedFeedFilters = function () { this.notyFeedFiltersDialog.visible = false; this.wristFeedFiltersDialog.visible = false; - this.sharedFeedFilters = JSON.parse(configRepository.getString('sharedFeedFilters')); + this.sharedFeedFilters = JSON.parse( + configRepository.getString('sharedFeedFilters') + ); }; - $app.data.notificationPosition = configRepository.getString('VRCX_notificationPosition'); + $app.data.notificationPosition = configRepository.getString( + 'VRCX_notificationPosition' + ); $app.methods.changeNotificationPosition = function () { - configRepository.setString('VRCX_notificationPosition', this.notificationPosition); + configRepository.setString( + 'VRCX_notificationPosition', + this.notificationPosition + ); this.updateVRConfigVars(); }; @@ -8162,9 +8841,11 @@ speechSynthesis.getVoices(); }; $app.methods.updateOpenVR = function () { - if (this.openVR && + if ( + this.openVR && this.isGameNoVR === false && - (this.isGameRunning || this.openVRAlways)) { + (this.isGameRunning || this.openVRAlways) + ) { AppApi.StartVR(); } else { AppApi.StopVR(); @@ -8173,15 +8854,15 @@ speechSynthesis.getVoices(); $app.methods.changeTTSVoice = function (index) { this.notificationTTSVoice = index; - configRepository.setString('VRCX_notificationTTSVoice', this.notificationTTSVoice); + configRepository.setString( + 'VRCX_notificationTTSVoice', + this.notificationTTSVoice + ); var voices = speechSynthesis.getVoices(); if (voices.length === 0) { return; } - if (index > voices.length) { - index = 0; - } - var voiceName = voices[index].name; + var voiceName = voices[index < voices.length ? index : 0].name; speechSynthesis.cancel(); this.speak(voiceName); this.updateVRConfigVars(); @@ -8211,8 +8892,7 @@ speechSynthesis.getVoices(); inputPattern: /\S+/, inputErrorMessage: 'User URL/ID is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue) { + if (action === 'confirm' && instance.inputValue) { var testUrl = instance.inputValue.substring(0, 15); if (testUrl === 'https://vrchat.') { var userId = this.parseUserUrl(instance.inputValue); @@ -8223,7 +8903,6 @@ speechSynthesis.getVoices(); message: 'Invalid URL', type: 'error' }); - return; } } else { this.showUserDialog(instance.inputValue); @@ -8241,11 +8920,12 @@ speechSynthesis.getVoices(); inputPattern: /\S+/, inputErrorMessage: 'World URL/ID is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue) { + if (action === 'confirm' && instance.inputValue) { var testUrl = instance.inputValue.substring(0, 15); if (testUrl === 'https://vrchat.') { - var worldInstance = this.parseLocationUrl(instance.inputValue); + var worldInstance = this.parseLocationUrl( + instance.inputValue + ); if (worldInstance) { this.showWorldDialog(worldInstance); } else { @@ -8253,7 +8933,6 @@ speechSynthesis.getVoices(); message: 'Invalid URL', type: 'error' }); - return; } } else { this.showWorldDialog(instance.inputValue); @@ -8271,8 +8950,7 @@ speechSynthesis.getVoices(); inputPattern: /\S+/, inputErrorMessage: 'Avatar URL/ID is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue) { + if (action === 'confirm' && instance.inputValue) { var testUrl = instance.inputValue.substring(0, 15); if (testUrl === 'https://vrchat.') { var avatarId = this.parseAvatarUrl(instance.inputValue); @@ -8283,7 +8961,6 @@ speechSynthesis.getVoices(); message: 'Invalid URL', type: 'error' }); - return; } } else { this.showAvatarDialog(instance.inputValue); @@ -8294,60 +8971,65 @@ speechSynthesis.getVoices(); }; $app.methods.promptOmniDirectDialog = function () { - this.$prompt('Enter a User/World/Instance/Avatar URL or ID (UUID)', 'Direct Access', { - distinguishCancelAndClose: true, - confirmButtonText: 'OK', - cancelButtonText: 'Cancel', - inputPattern: /\S+/, - inputErrorMessage: 'URL/ID is required', - callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue) { - var input = instance.inputValue; - var testUrl = input.substring(0, 15); - if (testUrl === 'https://vrchat.') { - var url = new URL(input); - var urlPath = url.pathname; - if ('/user/' === urlPath.substring(5, 11)) { - var userId = urlPath.substring(11); - this.showUserDialog(userId); - } else if ('/avatar/' === urlPath.substring(5, 13)) { - var avatarId = urlPath.substring(13); - this.showAvatarDialog(avatarId); - } else if ('/world/' === urlPath.substring(5, 12)) { - var worldId = urlPath.substring(12); - this.showWorldDialog(worldId); - } else if ('/launch' === urlPath.substring(5, 12)) { - var urlParams = new URLSearchParams(url.search); - var worldId = urlParams.get('worldId'); - var instanceId = urlParams.get('instanceId'); - if (instanceId) { - var location = `${worldId}:${instanceId}`; - this.showWorldDialog(location); - } else if (worldId) { + this.$prompt( + 'Enter a User/World/Instance/Avatar URL or ID (UUID)', + 'Direct Access', + { + distinguishCancelAndClose: true, + confirmButtonText: 'OK', + cancelButtonText: 'Cancel', + inputPattern: /\S+/, + inputErrorMessage: 'URL/ID is required', + callback: (action, instance) => { + if (action === 'confirm' && instance.inputValue) { + var input = instance.inputValue; + var testUrl = input.substring(0, 15); + if (testUrl === 'https://vrchat.') { + var url = new URL(input); + var urlPath = url.pathname; + if (urlPath.substring(5, 11) === '/user/') { + var userId = urlPath.substring(11); + this.showUserDialog(userId); + } else if ( + urlPath.substring(5, 13) === '/avatar/' + ) { + var avatarId = urlPath.substring(13); + this.showAvatarDialog(avatarId); + } else if (urlPath.substring(5, 12) === '/world/') { + var worldId = urlPath.substring(12); this.showWorldDialog(worldId); + } else if (urlPath.substring(5, 12) === '/launch') { + var urlParams = new URLSearchParams(url.search); + var worldId = urlParams.get('worldId'); + var instanceId = urlParams.get('instanceId'); + if (instanceId) { + var location = `${worldId}:${instanceId}`; + this.showWorldDialog(location); + } else if (worldId) { + this.showWorldDialog(worldId); + } + } else { + this.$message({ + message: 'Invalid URL', + type: 'error' + }); } + } else if (input.substring(0, 4) === 'usr_') { + this.showUserDialog(input); + } else if (input.substring(0, 5) === 'wrld_') { + this.showWorldDialog(input); + } else if (input.substring(0, 5) === 'avtr_') { + this.showAvatarDialog(input); } else { this.$message({ - message: 'Invalid URL', + message: 'Invalid ID/URL', type: 'error' }); } - } else if (input.substring(0, 4) === 'usr_') { - this.showUserDialog(input); - } else if (input.substring(0, 5) === 'wrld_') { - this.showWorldDialog(input); - } else if (input.substring(0, 5) === 'avtr_') { - this.showAvatarDialog(input); - } else { - this.$message({ - message: 'Invalid ID/URL', - type: 'error' - }); } } } - }); + ); }; $app.methods.promptNotificationTimeout = function () { @@ -8359,11 +9041,18 @@ speechSynthesis.getVoices(); inputPattern: /\d+$/, inputErrorMessage: 'Valid number is required', callback: (action, instance) => { - if (action === 'confirm' && + if ( + action === 'confirm' && instance.inputValue && - !isNaN(instance.inputValue)) { - this.notificationTimeout = Math.trunc(Number(instance.inputValue) * 1000); - configRepository.setString('VRCX_notificationTimeout', this.notificationTimeout); + !isNaN(instance.inputValue) + ) { + this.notificationTimeout = Math.trunc( + Number(instance.inputValue) * 1000 + ); + configRepository.setString( + 'VRCX_notificationTimeout', + this.notificationTimeout + ); } } }); @@ -8377,8 +9066,10 @@ speechSynthesis.getVoices(); inputValue: avatar.ref.name, inputErrorMessage: 'Valid name is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue !== avatar.ref.name) { + if ( + action === 'confirm' && + instance.inputValue !== avatar.ref.name + ) { API.saveAvatar({ id: avatar.id, name: instance.inputValue @@ -8402,8 +9093,10 @@ speechSynthesis.getVoices(); inputValue: avatar.ref.description, inputErrorMessage: 'Valid description is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue !== avatar.ref.description) { + if ( + action === 'confirm' && + instance.inputValue !== avatar.ref.description + ) { API.saveAvatar({ id: avatar.id, description: instance.inputValue @@ -8427,8 +9120,10 @@ speechSynthesis.getVoices(); inputValue: world.ref.name, inputErrorMessage: 'Valid name is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue !== world.ref.name) { + if ( + action === 'confirm' && + instance.inputValue !== world.ref.name + ) { API.saveWorld({ id: world.id, name: instance.inputValue @@ -8452,8 +9147,10 @@ speechSynthesis.getVoices(); inputValue: world.ref.description, inputErrorMessage: 'Valid description is required', callback: (action, instance) => { - if (action === 'confirm' && - instance.inputValue !== world.ref.description) { + if ( + action === 'confirm' && + instance.inputValue !== world.ref.description + ) { API.saveWorld({ id: world.id, description: instance.inputValue @@ -8473,14 +9170,14 @@ speechSynthesis.getVoices(); var adjustDialogZ = (el) => { var z = 0; - document.querySelectorAll('.v-modal,.el-dialog__wrapper').forEach((v) => { - var _z = Number(v.style.zIndex) || 0; - if (_z && - _z > z && - v !== el) { - z = _z; - } - }); + document + .querySelectorAll('.v-modal,.el-dialog__wrapper') + .forEach((v) => { + var _z = Number(v.style.zIndex) || 0; + if (_z && _z > z && v !== el) { + z = _z; + } + }); if (z) { el.style.zIndex = z + 1; } @@ -8544,10 +9241,9 @@ speechSynthesis.getVoices(); }); API.$on('USER', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; - if (D.visible === false || - D.id !== ref.id) { + if (D.visible === false || D.id !== ref.id) { return; } D.ref = ref; @@ -8556,8 +9252,7 @@ speechSynthesis.getVoices(); API.$on('WORLD', function (args) { var D = $app.userDialog; - if (D.visible === false || - D.$location.worldId !== args.ref.id) { + if (D.visible === false || D.$location.worldId !== args.ref.id) { return; } $app.applyUserDialogLocation(); @@ -8565,11 +9260,10 @@ speechSynthesis.getVoices(); API.$on('FRIEND:STATUS', function (args) { var D = $app.userDialog; - if (D.visible === false || - D.id !== args.params.userId) { + if (D.visible === false || D.id !== args.params.userId) { return; } - var { json } = args; + var {json} = args; D.isFriend = json.isFriend; D.incomingRequest = json.incomingRequest; D.outgoingRequest = json.outgoingRequest; @@ -8577,8 +9271,7 @@ speechSynthesis.getVoices(); API.$on('FRIEND:REQUEST', function (args) { var D = $app.userDialog; - if (D.visible === false || - D.id !== args.params.userId) { + if (D.visible === false || D.id !== args.params.userId) { return; } if (args.json.success) { @@ -8590,45 +9283,50 @@ speechSynthesis.getVoices(); API.$on('FRIEND:REQUEST:CANCEL', function (args) { var D = $app.userDialog; - if (D.visible === false || - D.id !== args.params.userId) { + if (D.visible === false || D.id !== args.params.userId) { return; } D.outgoingRequest = false; }); API.$on('NOTIFICATION', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; - if (D.visible === false || + if ( + D.visible === false || ref.$isDeleted || ref.type !== 'friendRequest' || - ref.senderUserId !== D.id) { + ref.senderUserId !== D.id + ) { return; } D.incomingRequest = true; }); API.$on('NOTIFICATION:ACCEPT', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; // 얘는 @DELETE가 오고나서 ACCEPT가 옴 // 따라서 $isDeleted라면 ref가 undefined가 됨 - if (D.visible === false || + if ( + D.visible === false || typeof ref === 'undefined' || ref.type !== 'friendRequest' || - ref.senderUserId !== D.id) { + ref.senderUserId !== D.id + ) { return; } D.isFriend = true; }); API.$on('NOTIFICATION:@DELETE', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; - if (D.visible === false || + if ( + D.visible === false || ref.type !== 'friendRequest' || - ref.senderUserId !== D.id) { + ref.senderUserId !== D.id + ) { return; } D.incomingRequest = false; @@ -8636,20 +9334,21 @@ speechSynthesis.getVoices(); API.$on('FRIEND:DELETE', function (args) { var D = $app.userDialog; - if (D.visible === false || - D.id !== args.params.userId) { + if (D.visible === false || D.id !== args.params.userId) { return; } D.isFriend = false; }); API.$on('PLAYER-MODERATION:@SEND', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; - if (D.visible === false || + if ( + D.visible === false || ref.$isDeleted || - ref.targetUserId !== D.id && - ref.sourceUserId !== this.currentUser.id) { + (ref.targetUserId !== D.id && + ref.sourceUserId !== this.currentUser.id) + ) { return; } if (ref.type === 'block') { @@ -8666,11 +9365,13 @@ speechSynthesis.getVoices(); }); API.$on('PLAYER-MODERATION:@DELETE', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; - if (D.visible === false || + if ( + D.visible === false || ref.targetUserId !== D.id || - ref.sourceUserId !== this.currentUser.id) { + ref.sourceUserId !== this.currentUser.id + ) { return; } if (ref.type === 'block') { @@ -8683,11 +9384,9 @@ speechSynthesis.getVoices(); }); API.$on('FAVORITE', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.userDialog; - if (D.visible === false || - ref.$isDeleted || - ref.favoriteId !== D.id) { + if (D.visible === false || ref.$isDeleted || ref.favoriteId !== D.id) { return; } D.isFavorite = true; @@ -8695,8 +9394,7 @@ speechSynthesis.getVoices(); API.$on('FAVORITE:@DELETE', function (args) { var D = $app.userDialog; - if (D.visible === false || - D.id !== args.ref.favoriteId) { + if (D.visible === false || D.id !== args.ref.favoriteId) { return; } D.isFavorite = false; @@ -8723,81 +9421,87 @@ speechSynthesis.getVoices(); D.instance = {}; API.getCachedUser({ userId - }).catch((err) => { - D.loading = false; - D.visible = false; - throw err; - }).then((args) => { - if (args.ref.id === D.id) { + }) + .catch((err) => { D.loading = false; - D.ref = args.ref; - D.friend = this.friends.get(D.id); - D.isFriend = Boolean(D.friend); - D.incomingRequest = false; - D.outgoingRequest = false; - D.isBlock = false; - D.isMute = false; - D.isHideAvatar = false; - for (var ref of API.cachedPlayerModerations.values()) { - if (ref.$isDeleted === false && - ref.targetUserId === D.id && - ref.sourceUserId === API.currentUser.id) { - if (ref.type === 'block') { - D.isBlock = true; - } else if (ref.type === 'mute') { - D.isMute = true; - } else if (ref.type === 'hideAvatar') { - D.isHideAvatar = true; + D.visible = false; + throw err; + }) + .then((args) => { + if (args.ref.id === D.id) { + D.loading = false; + D.ref = args.ref; + D.friend = this.friends.get(D.id); + D.isFriend = Boolean(D.friend); + D.incomingRequest = false; + D.outgoingRequest = false; + D.isBlock = false; + D.isMute = false; + D.isHideAvatar = false; + for (var ref of API.cachedPlayerModerations.values()) { + if ( + ref.$isDeleted === false && + ref.targetUserId === D.id && + ref.sourceUserId === API.currentUser.id + ) { + if (ref.type === 'block') { + D.isBlock = true; + } else if (ref.type === 'mute') { + D.isMute = true; + } else if (ref.type === 'hideAvatar') { + D.isHideAvatar = true; + } } } - } - D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); - this.applyUserDialogLocation(); - if (this.$refs.userDialogTabs.currentName === '0') { - this.userDialogLastActiveTab = 'Info'; - } else if (this.$refs.userDialogTabs.currentName === '1') { - this.userDialogLastActiveTab = 'Worlds'; - this.setUserDialogWorlds(userId); - if (this.userDialogLastWorld !== userId) { - this.userDialogLastWorld = userId; - this.refreshUserDialogWorlds(); - } - } else if (this.$refs.userDialogTabs.currentName === '2') { - this.userDialogLastActiveTab = 'Favorite Worlds'; - if (this.userDialogLastFavoriteWorld !== userId) { - this.userDialogLastFavoriteWorld = userId; - this.getUserFavoriteWorlds(userId); - } - } else if (this.$refs.userDialogTabs.currentName === '3') { - this.userDialogLastActiveTab = 'Avatars'; - this.setUserDialogAvatars(userId); - if (this.userDialogLastAvatar !== userId) { - this.userDialogLastAvatar = userId; - if ((userId === API.currentUser.id) && (D.avatars.length === 0)) { - this.refreshUserDialogAvatars(); + D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); + this.applyUserDialogLocation(); + if (this.$refs.userDialogTabs.currentName === '0') { + this.userDialogLastActiveTab = 'Info'; + } else if (this.$refs.userDialogTabs.currentName === '1') { + this.userDialogLastActiveTab = 'Worlds'; + this.setUserDialogWorlds(userId); + if (this.userDialogLastWorld !== userId) { + this.userDialogLastWorld = userId; + this.refreshUserDialogWorlds(); } + } else if (this.$refs.userDialogTabs.currentName === '2') { + this.userDialogLastActiveTab = 'Favorite Worlds'; + if (this.userDialogLastFavoriteWorld !== userId) { + this.userDialogLastFavoriteWorld = userId; + this.getUserFavoriteWorlds(userId); + } + } else if (this.$refs.userDialogTabs.currentName === '3') { + this.userDialogLastActiveTab = 'Avatars'; + this.setUserDialogAvatars(userId); + if (this.userDialogLastAvatar !== userId) { + this.userDialogLastAvatar = userId; + if ( + userId === API.currentUser.id && + D.avatars.length === 0 + ) { + this.refreshUserDialogAvatars(); + } + } + } else if (this.$refs.userDialogTabs.currentName === '4') { + this.userDialogLastActiveTab = 'JSON'; + this.refreshUserDialogTreeData(); } - } else if (this.$refs.userDialogTabs.currentName === '4') { - this.userDialogLastActiveTab = 'JSON'; - this.refreshUserDialogTreeData(); - } - API.getFriendStatus({ - userId: D.id - }); - if (args.cache) { - API.getUser(args.params); - } - var L = API.parseLocation(D.ref.location); - if ((L.worldId) && - (this.lastLocation.location !== L.tag)) { - API.getInstance({ - worldId: L.worldId, - instanceId: L.instanceId + API.getFriendStatus({ + userId: D.id }); + if (args.cache) { + API.getUser(args.params); + } + var L = API.parseLocation(D.ref.location); + if (L.worldId && this.lastLocation.location !== L.tag) { + API.getInstance({ + worldId: L.worldId, + instanceId: L.instanceId + }); + } } - } - return args; - }); + return args; + }); }; $app.methods.applyUserDialogLocation = function () { @@ -8819,7 +9523,10 @@ speechSynthesis.getVoices(); } var users = []; var playersInInstance = this.lastLocation.playerList; - if ((this.lastLocation.location === L.tag) && (playersInInstance.length > 0)) { + if ( + this.lastLocation.location === L.tag && + playersInInstance.length > 0 + ) { var ref = API.cachedUsers.get(API.currentUser.id); if (typeof ref === 'undefined') { ref = API.currentUser; @@ -8849,9 +9556,14 @@ speechSynthesis.getVoices(); } } else if (L.isOffline === false) { for (var friend of this.friends.values()) { - if ((typeof friend.ref !== 'undefined') && - (friend.ref.location === L.tag)) { - if ((friend.state !== 'online') && (friend.ref.location === 'private')) { + if ( + typeof friend.ref !== 'undefined' && + friend.ref.location === L.tag + ) { + if ( + friend.state !== 'online' && + friend.ref.location === 'private' + ) { continue; } users.push(friend.ref); @@ -8860,16 +9572,13 @@ speechSynthesis.getVoices(); } users.sort(compareByLocationAt); D.users = users; - if ((L.worldId) && - (this.lastLocation.location === D.ref.location)) { + if (L.worldId && this.lastLocation.location === D.ref.location) { D.instance = { id: D.ref.location, occupants: this.lastLocation.playerList.length }; } - if ((L.isOffline) || - (L.isPrivate) || - (L.worldId === '')) { + if (L.isOffline || L.isPrivate || L.worldId === '') { D.instance = { id: D.ref.location, occupants: 0 @@ -8979,9 +9688,9 @@ speechSynthesis.getVoices(); sort: 'updated', order: 'descending', releaseStatus: 'all', - user: 'me', + user: 'me' }; - for (var ref of API.cachedAvatars.values()) { + for (let ref of API.cachedAvatars.values()) { if (ref.authorId === D.id) { API.cachedAvatars.delete(ref.id); } @@ -9005,7 +9714,7 @@ speechSynthesis.getVoices(); D.isAvatarsLoading = false; if (fileId) { D.loading = false; - for (var ref of array) { + for (let ref of array) { if (extractFileId(ref.imageUrl) === fileId) { this.showAvatarDialog(ref.id); return; @@ -9102,8 +9811,6 @@ speechSynthesis.getVoices(); userId }); break; - default: - break; } }; @@ -9116,50 +9823,53 @@ speechSynthesis.getVoices(); D.loading = true; API.getUser({ userId: D.id - }).catch((err) => { - D.loading = false; - D.visible = false; - throw err; - }).then((args) => { - if (D.id === args.ref.id) { + }) + .catch((err) => { D.loading = false; - D.ref = args.ref; - D.friend = this.friends.get(D.id); - D.isFriend = Boolean(D.friend); - D.incomingRequest = false; - D.outgoingRequest = false; - D.isBlock = false; - D.isMute = false; - D.isHideAvatar = false; - for (var ref of API.cachedPlayerModerations.values()) { - if (ref.$isDeleted === false && - ref.targetUserId === D.id && - ref.sourceUserId === API.currentUser.id) { - if (ref.type === 'block') { - D.isBlock = true; - } else if (ref.type === 'mute') { - D.isMute = true; - } else if (ref.type === 'hideAvatar') { - D.isHideAvatar = true; + D.visible = false; + throw err; + }) + .then((args) => { + if (D.id === args.ref.id) { + D.loading = false; + D.ref = args.ref; + D.friend = this.friends.get(D.id); + D.isFriend = Boolean(D.friend); + D.incomingRequest = false; + D.outgoingRequest = false; + D.isBlock = false; + D.isMute = false; + D.isHideAvatar = false; + for (var ref of API.cachedPlayerModerations.values()) { + if ( + ref.$isDeleted === false && + ref.targetUserId === D.id && + ref.sourceUserId === API.currentUser.id + ) { + if (ref.type === 'block') { + D.isBlock = true; + } else if (ref.type === 'mute') { + D.isMute = true; + } else if (ref.type === 'hideAvatar') { + D.isHideAvatar = true; + } } } - } - D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); - this.applyUserDialogLocation(); - API.getFriendStatus({ - userId: D.id - }); - var L = API.parseLocation(D.ref.location); - if ((L.worldId) && - (this.lastLocation.location !== L.tag)) { - API.getInstance({ - worldId: L.worldId, - instanceId: L.instanceId + D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); + this.applyUserDialogLocation(); + API.getFriendStatus({ + userId: D.id }); + var L = API.parseLocation(D.ref.location); + if (L.worldId && this.lastLocation.location !== L.tag) { + API.getInstance({ + worldId: L.worldId, + instanceId: L.instanceId + }); + } } - } - return args; - }); + return args; + }); } else if (command === 'Add Favorite') { this.showFavoriteDialog('friend', D.id); } else if (command === 'Edit Social Status') { @@ -9171,9 +9881,12 @@ speechSynthesis.getVoices(); } else if (command === 'Logout') { this.logout(); } else if (command === 'Request Invite') { - API.sendRequestInvite({ - platform: 'standalonewindows' - }, D.id).then((args) => { + API.sendRequestInvite( + { + platform: 'standalonewindows' + }, + D.id + ).then((args) => { this.$message('Request invite sent'); return args; }); @@ -9182,35 +9895,44 @@ speechSynthesis.getVoices(); API.getCachedWorld({ worldId: L.worldId }).then((args) => { - this.showSendInviteDialog({ - instanceId: this.lastLocation.location, - worldId: this.lastLocation.location, - worldName: args.ref.name - }, D.id); + this.showSendInviteDialog( + { + instanceId: this.lastLocation.location, + worldId: this.lastLocation.location, + worldName: args.ref.name + }, + D.id + ); }); } else if (command === 'Request Invite Message') { - this.showSendInviteRequestDialog({ - platform: 'standalonewindows' - }, D.id); + this.showSendInviteRequestDialog( + { + platform: 'standalonewindows' + }, + D.id + ); } else if (command === 'Invite') { var L = API.parseLocation(this.lastLocation.location); API.getCachedWorld({ worldId: L.worldId }).then((args) => { - API.sendInvite({ - instanceId: this.lastLocation.location, - worldId: this.lastLocation.location, - worldName: args.ref.name - }, D.id).then((_args) => { + API.sendInvite( + { + instanceId: this.lastLocation.location, + worldId: this.lastLocation.location, + worldName: args.ref.name + }, + D.id + ).then((_args) => { this.$message('Invite sent'); return _args; }); }); } else if (command === 'Show Avatar Author') { - var { currentAvatarImageUrl } = D.ref; + var {currentAvatarImageUrl} = D.ref; this.showAvatarAuthorDialog(D.id, currentAvatarImageUrl); } else if (command === 'Show Fallback Avatar Details') { - var { fallbackAvatar } = D.ref; + var {fallbackAvatar} = D.ref; if (fallbackAvatar) { this.showAvatarDialog(fallbackAvatar); } else { @@ -9253,10 +9975,14 @@ speechSynthesis.getVoices(); }; $app.computed.userDialogAvatars = function () { - var { avatars, avatarReleaseStatus } = this.userDialog; - if (avatarReleaseStatus === 'public' || - avatarReleaseStatus === 'private') { - return avatars.filter((avatar) => avatar.releaseStatus === avatarReleaseStatus); + var {avatars, avatarReleaseStatus} = this.userDialog; + if ( + avatarReleaseStatus === 'public' || + avatarReleaseStatus === 'private' + ) { + return avatars.filter( + (avatar) => avatar.releaseStatus === avatarReleaseStatus + ); } return avatars; }; @@ -9284,10 +10010,9 @@ speechSynthesis.getVoices(); }); API.$on('WORLD', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.worldDialog; - if (D.visible === false || - D.id !== ref.id) { + if (D.visible === false || D.id !== ref.id) { return; } D.ref = ref; @@ -9301,15 +10026,16 @@ speechSynthesis.getVoices(); } } D.rooms.sort(function (a, b) { - return b.users.length - a.users.length || - b.occupants - a.occupants; + return b.users.length - a.users.length || b.occupants - a.occupants; }); if (D.fileSize === 'Loading') { var assetUrl = ''; - for (var i = ref.unityPackages.length - 1; i > -1; i--) { + for (let i = ref.unityPackages.length - 1; i > -1; i--) { var unityPackage = ref.unityPackages[i]; - if ((unityPackage.platform === 'standalonewindows') && - ($app.compareUnityVersion(unityPackage.unityVersion))) { + if ( + unityPackage.platform === 'standalonewindows' && + $app.compareUnityVersion(unityPackage.unityVersion) + ) { assetUrl = unityPackage.assetUrl; break; } @@ -9317,30 +10043,31 @@ speechSynthesis.getVoices(); var fileId = extractFileId(assetUrl); var fileVersion = extractFileVersion(assetUrl); if (fileId) { - API.getBundles(fileId).then((args) => { - var { versions } = args.json; - var ctx = ''; - for (var i = versions.length - 1; i > -1; i--) { - var version = versions[i]; - if (version.version == fileVersion) { - D.fileCreatedAt = version.created_at; - D.fileSize = `${(version.file.sizeInBytes / 1048576).toFixed(2)} MiB`; - break; + API.getBundles(fileId) + .then((args2) => { + var {versions} = args2.json; + for (let i = versions.length - 1; i > -1; i--) { + var version = versions[i]; + if (version.version === fileVersion) { + D.fileCreatedAt = version.created_at; + D.fileSize = `${( + version.file.sizeInBytes / 1048576 + ).toFixed(2)} MiB`; + break; + } } - } - }).catch((err) => { - D.fileSize = 'Error'; - }); + }) + .catch(() => { + D.fileSize = 'Error'; + }); } } }); API.$on('FAVORITE', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.worldDialog; - if (D.visible === false || - ref.$isDeleted || - ref.favoriteId !== D.id) { + if (D.visible === false || ref.$isDeleted || ref.favoriteId !== D.id) { return; } D.isFavorite = true; @@ -9348,8 +10075,7 @@ speechSynthesis.getVoices(); API.$on('FAVORITE:@DELETE', function (args) { var D = $app.worldDialog; - if (D.visible === false || - D.id !== args.ref.favoriteId) { + if (D.visible === false || D.id !== args.ref.favoriteId) { return; } D.isFavorite = false; @@ -9375,22 +10101,24 @@ speechSynthesis.getVoices(); D.rooms = []; API.getCachedWorld({ worldId: L.worldId - }).catch((err) => { - D.loading = false; - D.visible = false; - throw err; - }).then((args) => { - if (D.id === args.ref.id) { + }) + .catch((err) => { D.loading = false; - D.ref = args.ref; - D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); - this.updateVRChatWorldCache(); - if (args.cache) { - API.getWorld(args.params); + D.visible = false; + throw err; + }) + .then((args) => { + if (D.id === args.ref.id) { + D.loading = false; + D.ref = args.ref; + D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); + this.updateVRChatWorldCache(); + if (args.cache) { + API.getWorld(args.params); + } } - } - return args; - }); + return args; + }); }; $app.methods.applyWorldDialogInstances = function () { @@ -9403,9 +10131,8 @@ speechSynthesis.getVoices(); users: [] }; } - var { instanceId } = D.$location; - if (instanceId && - typeof instances[instanceId] === 'undefined') { + var {instanceId} = D.$location; + if (instanceId && typeof instances[instanceId] === 'undefined') { instances[instanceId] = { id: instanceId, occupants: 0, @@ -9415,7 +10142,7 @@ speechSynthesis.getVoices(); var lastLocation$ = API.parseLocation(this.lastLocation.location); var playersInInstance = this.lastLocation.playerList; if (lastLocation$.worldId === D.id) { - instance = { + var instance = { id: lastLocation$.instanceId, occupants: playersInInstance.length, users: [] @@ -9449,14 +10176,16 @@ speechSynthesis.getVoices(); } } } - for (var { ref } of this.friends.values()) { - if (typeof ref === 'undefined' || + for (var {ref} of this.friends.values()) { + if ( + typeof ref === 'undefined' || typeof ref.$location === 'undefined' || ref.$location.worldId !== D.id || - ref.$location.instanceId === lastLocation$.instanceId) { + ref.$location.instanceId === lastLocation$.instanceId + ) { continue; } - var { instanceId } = ref.$location; + var {instanceId} = ref.$location; var instance = instances[instanceId]; if (typeof instance === 'undefined') { instance = { @@ -9504,8 +10233,7 @@ speechSynthesis.getVoices(); } // sort by more friends, occupants rooms.sort(function (a, b) { - return b.users.length - a.users.length || - b.occupants - a.occupants; + return b.users.length - a.users.length || b.occupants - a.occupants; }); D.rooms = rooms; }; @@ -9520,19 +10248,23 @@ speechSynthesis.getVoices(); D.loading = true; API.getWorld({ worldId: D.id - }).catch((err) => { - D.loading = false; - D.visible = false; - throw err; - }).then((args) => { - if (D.id === args.ref.id) { + }) + .catch((err) => { D.loading = false; - D.ref = args.ref; - D.isFavorite = API.cachedFavoritesByObjectId.has(D.id); - this.updateVRChatWorldCache(); - } - return args; - }); + D.visible = false; + throw err; + }) + .then((args) => { + if (D.id === args.ref.id) { + D.loading = false; + D.ref = args.ref; + D.isFavorite = API.cachedFavoritesByObjectId.has( + D.id + ); + this.updateVRChatWorldCache(); + } + return args; + }); break; case 'New Instance': this.showNewInstanceDialog(D.$location.tag); @@ -9604,8 +10336,6 @@ speechSynthesis.getVoices(); return args; }); break; - default: - break; } } }); @@ -9619,7 +10349,7 @@ speechSynthesis.getVoices(); }; $app.computed.worldDialogPlatform = function () { - var { ref } = this.worldDialog; + var {ref} = this.worldDialog; var platforms = []; if (ref.unityPackages) { for (var unityPackage of ref.unityPackages) { @@ -9629,7 +10359,7 @@ speechSynthesis.getVoices(); } else if (unityPackage.platform === 'android') { platform = 'Quest'; } else if (unityPackage.platform) { - ({ platform } = unityPackage); + ({platform} = unityPackage); } platforms.push(`${platform}/${unityPackage.unityVersion}`); } @@ -9659,11 +10389,9 @@ speechSynthesis.getVoices(); }); API.$on('FAVORITE', function (args) { - var { ref } = args; + var {ref} = args; var D = $app.avatarDialog; - if (D.visible === false || - ref.$isDeleted || - ref.favoriteId !== D.id) { + if (D.visible === false || ref.$isDeleted || ref.favoriteId !== D.id) { return; } D.isFavorite = true; @@ -9671,8 +10399,7 @@ speechSynthesis.getVoices(); API.$on('FAVORITE:@DELETE', function (args) { var D = $app.avatarDialog; - if (D.visible === false || - D.id !== args.ref.favoriteId) { + if (D.visible === false || D.id !== args.ref.favoriteId) { return; } D.isFavorite = false; @@ -9690,26 +10417,31 @@ speechSynthesis.getVoices(); D.cacheLocked = false; D.isQuestFallback = false; D.isFavorite = API.cachedFavoritesByObjectId.has(avatarId); - var ref = API.cachedAvatars.get(avatarId); - if (typeof ref !== 'undefined') { - D.ref = ref; + var ref2 = API.cachedAvatars.get(avatarId); + if (typeof ref2 !== 'undefined') { + D.ref = ref2; this.updateVRChatAvatarCache(); } - API.getAvatar({ avatarId }).then((args) => { - var { ref } = args; + API.getAvatar({avatarId}).then((args) => { + var {ref} = args; D.ref = ref; this.updateVRChatAvatarCache(); - if ((ref.imageUrl === API.currentUser.currentAvatarImageUrl) && (!ref.assetUrl)) { + if ( + ref.imageUrl === API.currentUser.currentAvatarImageUrl && + !ref.assetUrl + ) { D.ref.assetUrl = API.currentUser.currentAvatarAssetUrl; } if (/quest/.test(ref.tags)) { D.isQuestFallback = true; } var assetUrl = ''; - for (var i = ref.unityPackages.length - 1; i > -1; i--) { + for (let i = ref.unityPackages.length - 1; i > -1; i--) { var unityPackage = ref.unityPackages[i]; - if ((unityPackage.platform === 'standalonewindows') && - (this.compareUnityVersion(unityPackage.unityVersion))) { + if ( + unityPackage.platform === 'standalonewindows' && + this.compareUnityVersion(unityPackage.unityVersion) + ) { assetUrl = unityPackage.assetUrl; break; } @@ -9720,24 +10452,27 @@ speechSynthesis.getVoices(); var fileId = extractFileId(ref.assetUrl); var fileVersion = extractFileVersion(ref.assetUrl); } - var imageId = extractFileId(ref.imageUrl); + // var imageId = extractFileId(ref.imageUrl); D.fileSize = ''; if (fileId) { D.fileSize = 'Loading'; - API.getBundles(fileId).then((args) => { - var { versions } = args.json; - var ctx = ''; - for (var i = versions.length - 1; i > -1; i--) { - var version = versions[i]; - if (version.version == fileVersion) { - D.ref.created_at = version.created_at; - D.fileSize = `${(version.file.sizeInBytes / 1048576).toFixed(2)} MiB`; - break; + API.getBundles(fileId) + .then((args2) => { + var {versions} = args2.json; + for (let i = versions.length - 1; i > -1; i--) { + var version = versions[i]; + if (version.version === fileVersion) { + D.ref.created_at = version.created_at; + D.fileSize = `${( + version.file.sizeInBytes / 1048576 + ).toFixed(2)} MiB`; + break; + } } - } - }).catch((err) => { - D.fileSize = 'Error'; - }); + }) + .catch(() => { + D.fileSize = 'Error'; + }); } }); }; @@ -9842,8 +10577,6 @@ speechSynthesis.getVoices(); return args; }); break; - default: - break; } } }); @@ -9851,7 +10584,10 @@ speechSynthesis.getVoices(); } }; - $app.methods.showAvatarAuthorDialog = function (refUserId, currentAvatarImageUrl) { + $app.methods.showAvatarAuthorDialog = function ( + refUserId, + currentAvatarImageUrl + ) { var fileId = extractFileId(currentAvatarImageUrl); if (!fileId) { this.$message({ @@ -9871,14 +10607,14 @@ speechSynthesis.getVoices(); } } if (API.cachedAvatarNames.has(fileId)) { - var { ownerId } = API.cachedAvatarNames.get(fileId); + let {ownerId} = API.cachedAvatarNames.get(fileId); if (ownerId === API.currentUser.id) { this.refreshUserDialogAvatars(fileId); return; } if (ownerId === refUserId) { this.$message({ - message: 'It\'s personal (own) avatar', + message: "It's personal (own) avatar", type: 'warning' }); return; @@ -9886,10 +10622,10 @@ speechSynthesis.getVoices(); this.showUserDialog(ownerId); } else { API.getAvatarImages({fileId}).then((args) => { - var ownerId = args.json.ownerId; + let ownerId = args.json.ownerId; if (ownerId === refUserId) { this.$message({ - message: 'It\'s personal (own) avatar', + message: "It's personal (own) avatar", type: 'warning' }); return; @@ -9905,7 +10641,7 @@ speechSynthesis.getVoices(); }; $app.computed.avatarDialogPlatform = function () { - var { ref } = this.avatarDialog; + var {ref} = this.avatarDialog; var platforms = []; if (ref.unityPackages) { for (var unityPackage of ref.unityPackages) { @@ -9915,7 +10651,7 @@ speechSynthesis.getVoices(); } else if (unityPackage.platform === 'android') { platform = 'Quest'; } else if (unityPackage.platform) { - ({ platform } = unityPackage); + ({platform} = unityPackage); } platforms.push(`${platform}/${unityPackage.unityVersion}`); } @@ -9944,12 +10680,14 @@ speechSynthesis.getVoices(); type: D.type, favoriteId: D.objectId, tags: group.name - }).finally(() => { - D.loading = false; - }).then((args) => { - D.visible = false; - return args; - }); + }) + .finally(() => { + D.loading = false; + }) + .then((args) => { + D.visible = false; + return args; + }); }; $app.methods.addFavoriteAvatar = function (ref, group) { @@ -10010,14 +10748,16 @@ speechSynthesis.getVoices(); type: 'info', callback: (action) => { var D = this.inviteDialog; - if (action !== 'confirm' || - D.loading === true) { + if (action !== 'confirm' || D.loading === true) { return; } - if (this.API.currentUser.status === 'busy' && - D.userIds.includes(this.API.currentUser.id) === true) { + if ( + this.API.currentUser.status === 'busy' && + D.userIds.includes(this.API.currentUser.id) === true + ) { this.$message({ - message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', + message: + "You can't invite yourself in 'Do Not Disturb' mode", type: 'error' }); return; @@ -10026,11 +10766,14 @@ speechSynthesis.getVoices(); var inviteLoop = () => { if (D.userIds.length > 0) { var receiverUserId = D.userIds.shift(); - API.sendInvite({ - instanceId: D.worldId, - worldId: D.worldId, - worldName: D.worldName - }, receiverUserId).finally(inviteLoop); + API.sendInvite( + { + instanceId: D.worldId, + worldId: D.worldId, + worldName: D.worldName + }, + receiverUserId + ).finally(inviteLoop); } else { D.loading = false; D.visible = false; @@ -10048,9 +10791,7 @@ speechSynthesis.getVoices(); $app.methods.showInviteDialog = function (tag) { this.$nextTick(() => adjustDialogZ(this.$refs.inviteDialog.$el)); var L = API.parseLocation(tag); - if (L.isOffline || - L.isPrivate || - L.worldId === '') { + if (L.isOffline || L.isPrivate || L.worldId === '') { return; } API.getCachedWorld({ @@ -10086,28 +10827,30 @@ speechSynthesis.getVoices(); API.saveCurrentUser({ status: D.status, statusDescription: D.statusDescription - }).finally(() => { - D.loading = false; - }).then((args) => { - D.visible = false; - this.$message({ - message: 'Status updated', - type: 'success' + }) + .finally(() => { + D.loading = false; + }) + .then((args) => { + D.visible = false; + this.$message({ + message: 'Status updated', + type: 'success' + }); + return args; }); - return args; - }); }; $app.methods.showSocialStatusDialog = function () { this.$nextTick(() => adjustDialogZ(this.$refs.socialStatusDialog.$el)); var D = this.socialStatusDialog; - var { statusHistory } = API.currentUser; + var {statusHistory} = API.currentUser; var statusHistoryArray = []; for (var i = 0; i < statusHistory.length; ++i) { var addStatus = { no: i + 1, status: statusHistory[i] - } + }; statusHistoryArray.push(addStatus); } this.socialStatusHistoryTable.data = statusHistoryArray; @@ -10141,7 +10884,7 @@ speechSynthesis.getVoices(); }); } return data; - }()) + })() }; API.$on('LOGOUT', function () { @@ -10202,16 +10945,18 @@ speechSynthesis.getVoices(); API.saveCurrentUser({ bio: D.bio, bioLinks: D.bioLinks - }).finally(() => { - D.loading = false; - }).then((args) => { - D.visible = false; - this.$message({ - message: 'Bio updated', - type: 'success' + }) + .finally(() => { + D.loading = false; + }) + .then((args) => { + D.visible = false; + this.$message({ + message: 'Bio updated', + type: 'success' + }); + return args; }); - return args; - }); }; $app.methods.showBioDialog = function () { @@ -10283,14 +11028,12 @@ speechSynthesis.getVoices(); $app.methods.selfInvite = function (location) { var L = API.parseLocation(location); - if (L.isOffline || - L.isPrivate || - L.worldId === '') { + if (L.isOffline || L.isPrivate || L.worldId === '') { return; } if (API.currentUser.status === 'busy') { this.$message({ - message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', + message: "You can't invite yourself in 'Do Not Disturb' mode", type: 'error' }); return; @@ -10303,9 +11046,13 @@ speechSynthesis.getVoices(); var getLaunchURL = function (worldId, instanceId) { if (instanceId) { - return `https://vrchat.com/home/launch?worldId=${encodeURIComponent(worldId)}&instanceId=${encodeURIComponent(instanceId)}`; + return `https://vrchat.com/home/launch?worldId=${encodeURIComponent( + worldId + )}&instanceId=${encodeURIComponent(instanceId)}`; } - return `https://vrchat.com/home/launch?worldId=${encodeURIComponent(worldId)}`; + return `https://vrchat.com/home/launch?worldId=${encodeURIComponent( + worldId + )}`; }; var updateLocationURL = function () { @@ -10318,13 +11065,25 @@ speechSynthesis.getVoices(); D.url = getLaunchURL(D.worldId, D.instanceId); }; var saveNewInstanceDialog = function () { - configRepository.setString('instanceDialogAccessType', this.newInstanceDialog.accessType); - configRepository.setString('instanceRegion', this.newInstanceDialog.region); - configRepository.setString('instanceDialogInstanceName', this.newInstanceDialog.instanceName); + configRepository.setString( + 'instanceDialogAccessType', + this.newInstanceDialog.accessType + ); + configRepository.setString( + 'instanceRegion', + this.newInstanceDialog.region + ); + configRepository.setString( + 'instanceDialogInstanceName', + this.newInstanceDialog.instanceName + ); if (this.newInstanceDialog.userId === API.currentUser.id) { configRepository.setString('instanceDialogUserId', ''); } else { - configRepository.setString('instanceDialogUserId', this.newInstanceDialog.userId); + configRepository.setString( + 'instanceDialogUserId', + this.newInstanceDialog.userId + ); } $app.buildInstance(); updateLocationURL(); @@ -10338,16 +11097,16 @@ speechSynthesis.getVoices(); $app.methods.showNewInstanceDialog = function (tag) { this.$nextTick(() => adjustDialogZ(this.$refs.newInstanceDialog.$el)); var L = API.parseLocation(tag); - if (L.isOffline || - L.isPrivate || - L.worldId === '') { + if (L.isOffline || L.isPrivate || L.worldId === '') { return; } var D = this.newInstanceDialog; D.worldId = L.worldId; D.accessType = 'public'; if (configRepository.getString('instanceDialogAccessType') !== null) { - D.accessType = configRepository.getString('instanceDialogAccessType'); + D.accessType = configRepository.getString( + 'instanceDialogAccessType' + ); } D.region = 'USA'; if (configRepository.getString('instanceRegion') !== null) { @@ -10355,7 +11114,9 @@ speechSynthesis.getVoices(); } D.instanceName = ''; if (configRepository.getString('instanceDialogInstanceName') !== null) { - D.instanceName = configRepository.getString('instanceDialogInstanceName'); + D.instanceName = configRepository.getString( + 'instanceDialogInstanceName' + ); } D.userId = ''; if (configRepository.getString('instanceDialogUserId') !== null) { @@ -10428,7 +11189,9 @@ speechSynthesis.getVoices(); }; $app.methods.showNotificationPositionDialog = function () { - this.$nextTick(() => adjustDialogZ(this.$refs.notificationPositionDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.notificationPositionDialog.$el) + ); this.notificationPositionDialog.visible = true; }; @@ -10439,7 +11202,9 @@ speechSynthesis.getVoices(); }; $app.methods.showNotyFeedFiltersDialog = function () { - this.$nextTick(() => adjustDialogZ(this.$refs.notyFeedFiltersDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.notyFeedFiltersDialog.$el) + ); this.notyFeedFiltersDialog.visible = true; }; @@ -10450,7 +11215,9 @@ speechSynthesis.getVoices(); }; $app.methods.showWristFeedFiltersDialog = function () { - this.$nextTick(() => adjustDialogZ(this.$refs.wristFeedFiltersDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.wristFeedFiltersDialog.$el) + ); this.wristFeedFiltersDialog.visible = true; }; @@ -10475,9 +11242,7 @@ speechSynthesis.getVoices(); $app.methods.showLaunchDialog = function (tag) { this.$nextTick(() => adjustDialogZ(this.$refs.launchDialog.$el)); var L = API.parseLocation(tag); - if (L.isOffline || - L.isPrivate || - L.worldId === '') { + if (L.isOffline || L.isPrivate || L.worldId === '') { return; } var D = this.launchDialog; @@ -10509,7 +11274,7 @@ speechSynthesis.getVoices(); // App: Copy To Clipboard $app.methods.copyToClipboard = function (text) { - var textArea = document.createElement("textarea"); + var textArea = document.createElement('textarea'); textArea.id = 'copy_to_clipboard'; textArea.value = text; textArea.style.top = '0'; @@ -10543,9 +11308,11 @@ speechSynthesis.getVoices(); }; $app.methods.copyLocationCheck = function (location) { - if ((location === '') || - (location === 'offline') || - (location === 'private')) { + if ( + location === '' || + location === 'offline' || + location === 'private' + ) { return false; } return true; @@ -10631,7 +11398,7 @@ speechSynthesis.getVoices(); API.$on('VRCPLUSICON:DELETE', function (args) { var array = $app.VRCPlusIconsTable; - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (args.fileId === array[i].id) { array.splice(i, 1); @@ -10670,7 +11437,8 @@ speechSynthesis.getVoices(); if (!files.length) { return; } - if (files[0].size >= 10000000) { //10MB + if (files[0].size >= 10000000) { + // 10MB $app.$message({ message: 'File size too large', type: 'error' @@ -10680,7 +11448,7 @@ speechSynthesis.getVoices(); } if (!files[0].type.match(/image.*/)) { $app.$message({ - message: 'File isn\'t an image', + message: "File isn't an image", type: 'error' }); clearFile(); @@ -10732,7 +11500,8 @@ speechSynthesis.getVoices(); if (!files.length) { return; } - if (files[0].size >= 10000000) { //10MB + if (files[0].size >= 10000000) { + // 10MB $app.$message({ message: 'File size too large', type: 'error' @@ -10742,7 +11511,7 @@ speechSynthesis.getVoices(); } if (!files[0].type.match(/image.png/)) { $app.$message({ - message: 'File isn\'t a png', + message: "File isn't a png", type: 'error' }); this.clearInviteImageUpload(); @@ -10757,12 +11526,12 @@ speechSynthesis.getVoices(); $app.methods.clearInviteImageUpload = function () { var buttonList = document.querySelectorAll('.inviteImageUploadButton'); - buttonList.forEach(button => button.value = ''); + buttonList.forEach((button) => (button.value = '')); this.uploadImage = ''; }; $app.methods.userOnlineFor = function (ctx) { - if ((ctx.ref.state === 'online') && (ctx.ref.$online_for)) { + if (ctx.ref.state === 'online' && ctx.ref.$online_for) { return timeToText(Date.now() - ctx.ref.$online_for); } else if (ctx.ref.$offline_for) { return timeToText(Date.now() - ctx.ref.$offline_for); @@ -10785,7 +11554,7 @@ speechSynthesis.getVoices(); $app.methods.refreshInviteMessageTable = function (messageType) { API.refreshInviteMessageTableData(messageType); - } + }; API.refreshInviteMessageTableData = function (messageType) { return this.call(`message/${this.currentUser.id}/${messageType}`, { @@ -10817,10 +11586,13 @@ speechSynthesis.getVoices(); }); API.editInviteMessage = function (params, messageType, slot) { - return this.call(`message/${this.currentUser.id}/${messageType}/${slot}`, { - method: 'PUT', - params - }).then((json) => { + return this.call( + `message/${this.currentUser.id}/${messageType}/${slot}`, + { + method: 'PUT', + params + } + ).then((json) => { var args = { json, params, @@ -10840,8 +11612,13 @@ speechSynthesis.getVoices(); newMessage: '' }; - $app.methods.showEditInviteMessageDialog = function (messageType, inviteMessage) { - this.$nextTick(() => adjustDialogZ(this.$refs.editInviteMessageDialog.$el)); + $app.methods.showEditInviteMessageDialog = function ( + messageType, + inviteMessage + ) { + this.$nextTick(() => + adjustDialogZ(this.$refs.editInviteMessageDialog.$el) + ); var D = this.editInviteMessageDialog; D.newMessage = inviteMessage.message; D.visible = true; @@ -10858,21 +11635,26 @@ speechSynthesis.getVoices(); var params = { message: D.newMessage }; - API.editInviteMessage(params, messageType, slot).catch((err) => { - throw err; - }).then((args) => { - API.$emit(`INVITE:${messageType.toUpperCase()}`, args); - if (args.json[slot].message === D.inviteMessage.message) { - this.$message({ - message: 'VRChat API didn\'t update message, try again', - type: 'error' - }); - throw new Error('VRChat API didn\'t update message, try again'); - } else { - this.$message('Invite message updated'); - } - return args; - }); + API.editInviteMessage(params, messageType, slot) + .catch((err) => { + throw err; + }) + .then((args) => { + API.$emit(`INVITE:${messageType.toUpperCase()}`, args); + if (args.json[slot].message === D.inviteMessage.message) { + this.$message({ + message: + "VRChat API didn't update message, try again", + type: 'error' + }); + throw new Error( + "VRChat API didn't update message, try again" + ); + } else { + this.$message('Invite message updated'); + } + return args; + }); } }; @@ -10889,8 +11671,13 @@ speechSynthesis.getVoices(); newMessage: '' }; - $app.methods.showEditAndSendInviteResponseDialog = function (messageType, inviteMessage) { - this.$nextTick(() => adjustDialogZ(this.$refs.editAndSendInviteResponseDialog.$el)); + $app.methods.showEditAndSendInviteResponseDialog = function ( + messageType, + inviteMessage + ) { + this.$nextTick(() => + adjustDialogZ(this.$refs.editAndSendInviteResponseDialog.$el) + ); this.editAndSendInviteResponseDialog = { newMessage: inviteMessage.message, visible: true, @@ -10908,21 +11695,26 @@ speechSynthesis.getVoices(); var params = { message: D.newMessage }; - await API.editInviteMessage(params, messageType, slot).catch((err) => { - throw err; - }).then((args) => { - API.$emit(`INVITE:${messageType.toUpperCase()}`, args); - if (args.json[slot].message === D.inviteMessage.message) { - this.$message({ - message: 'VRChat API didn\'t update message, try again', - type: 'error' - }); - throw new Error('VRChat API didn\'t update message, try again'); - } else { - this.$message('Invite message updated'); - } - return args; - }); + await API.editInviteMessage(params, messageType, slot) + .catch((err) => { + throw err; + }) + .then((args) => { + API.$emit(`INVITE:${messageType.toUpperCase()}`, args); + if (args.json[slot].message === D.inviteMessage.message) { + this.$message({ + message: + "VRChat API didn't update message, try again", + type: 'error' + }); + throw new Error( + "VRChat API didn't update message, try again" + ); + } else { + this.$message('Invite message updated'); + } + return args; + }); } var I = this.sendInviteResponseDialog; var params = { @@ -10930,35 +11722,39 @@ speechSynthesis.getVoices(); rsvp: true }; if ($app.uploadImage) { - API.sendInviteResponsePhoto(params, I.invite.id).catch((err) => { - throw err; - }).then((args) => { - API.hideNotification({ - notificationId: I.invite.id + API.sendInviteResponsePhoto(params, I.invite.id) + .catch((err) => { + throw err; + }) + .then((args) => { + API.hideNotification({ + notificationId: I.invite.id + }); + this.$message({ + message: 'Invite response message sent', + type: 'success' + }); + this.sendInviteResponseDialogVisible = false; + this.sendInviteRequestResponseDialogVisible = false; + return args; }); - this.$message({ - message: 'Invite response message sent', - type: 'success' - }); - this.sendInviteResponseDialogVisible = false; - this.sendInviteRequestResponseDialogVisible = false; - return args; - }); } else { - API.sendInviteResponse(params, I.invite.id).catch((err) => { - throw err; - }).then((args) => { - API.hideNotification({ - notificationId: I.invite.id + API.sendInviteResponse(params, I.invite.id) + .catch((err) => { + throw err; + }) + .then((args) => { + API.hideNotification({ + notificationId: I.invite.id + }); + this.$message({ + message: 'Invite response message sent', + type: 'success' + }); + this.sendInviteResponseDialogVisible = false; + this.sendInviteRequestResponseDialogVisible = false; + return args; }); - this.$message({ - message: 'Invite response message sent', - type: 'success' - }); - this.sendInviteResponseDialogVisible = false; - this.sendInviteRequestResponseDialogVisible = false; - return args; - }); } }; @@ -10988,16 +11784,23 @@ speechSynthesis.getVoices(); invite }; API.refreshInviteMessageTableData('response'); - this.$nextTick(() => adjustDialogZ(this.$refs.sendInviteResponseDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.sendInviteResponseDialog.$el) + ); this.clearInviteImageUpload(); this.sendInviteResponseDialogVisible = true; }; $app.methods.showSendInviteResponseConfirmDialog = function (val) { - if (this.editAndSendInviteResponseDialog.visible === true || val === null) { + if ( + this.editAndSendInviteResponseDialog.visible === true || + val === null + ) { return; } - this.$nextTick(() => adjustDialogZ(this.$refs.sendInviteResponseConfirmDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.sendInviteResponseConfirmDialog.$el) + ); this.sendInviteResponseConfirmDialog.visible = true; this.sendInviteResponseDialog.messageSlot = val.slot; }; @@ -11017,31 +11820,35 @@ speechSynthesis.getVoices(); rsvp: true }; if ($app.uploadImage) { - API.sendInviteResponsePhoto(params, D.invite.id, D.messageType).catch((err) => { - throw err; - }).then((args) => { - API.hideNotification({ - notificationId: D.invite.id + API.sendInviteResponsePhoto(params, D.invite.id, D.messageType) + .catch((err) => { + throw err; + }) + .then((args) => { + API.hideNotification({ + notificationId: D.invite.id + }); + this.$message({ + message: 'Invite response photo message sent', + type: 'success' + }); + return args; }); - this.$message({ - message: 'Invite response photo message sent', - type: 'success' - }); - return args; - }); } else { - API.sendInviteResponse(params, D.invite.id, D.messageType).catch((err) => { - throw err; - }).then((args) => { - API.hideNotification({ - notificationId: D.invite.id + API.sendInviteResponse(params, D.invite.id, D.messageType) + .catch((err) => { + throw err; + }) + .then((args) => { + API.hideNotification({ + notificationId: D.invite.id + }); + this.$message({ + message: 'Invite response message sent', + type: 'success' + }); + return args; }); - this.$message({ - message: 'Invite response message sent', - type: 'success' - }); - return args; - }); } this.sendInviteResponseDialogVisible = false; this.sendInviteRequestResponseDialogVisible = false; @@ -11066,7 +11873,9 @@ speechSynthesis.getVoices(); invite }; API.refreshInviteMessageTableData('requestResponse'); - this.$nextTick(() => adjustDialogZ(this.$refs.sendInviteRequestResponseDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.sendInviteRequestResponseDialog.$el) + ); this.clearInviteImageUpload(); this.sendInviteRequestResponseDialogVisible = true; }; @@ -11080,8 +11889,13 @@ speechSynthesis.getVoices(); inviteMessage: {} }; - $app.methods.showEditAndSendInviteDialog = function (messageType, inviteMessage) { - this.$nextTick(() => adjustDialogZ(this.$refs.editAndSendInviteDialog.$el)); + $app.methods.showEditAndSendInviteDialog = function ( + messageType, + inviteMessage + ) { + this.$nextTick(() => + adjustDialogZ(this.$refs.editAndSendInviteDialog.$el) + ); this.editAndSendInviteDialog = { newMessage: inviteMessage.message, visible: true, @@ -11099,29 +11913,37 @@ speechSynthesis.getVoices(); var params = { message: D.newMessage }; - await API.editInviteMessage(params, messageType, slot).catch((err) => { - throw err; - }).then((args) => { - API.$emit(`INVITE:${messageType.toUpperCase()}`, args); - if (args.json[slot].message === D.inviteMessage.message) { - this.$message({ - message: 'VRChat API didn\'t update message, try again', - type: 'error' - }); - throw new Error('VRChat API didn\'t update message, try again'); - } else { - this.$message('Invite message updated'); - } - return args; - }); + await API.editInviteMessage(params, messageType, slot) + .catch((err) => { + throw err; + }) + .then((args) => { + API.$emit(`INVITE:${messageType.toUpperCase()}`, args); + if (args.json[slot].message === D.inviteMessage.message) { + this.$message({ + message: + "VRChat API didn't update message, try again", + type: 'error' + }); + throw new Error( + "VRChat API didn't update message, try again" + ); + } else { + this.$message('Invite message updated'); + } + return args; + }); } var I = this.sendInviteDialog; var J = this.inviteDialog; if (J.visible) { - if (this.API.currentUser.status === 'busy' && - J.userIds.includes(this.API.currentUser.id) === true) { + if ( + this.API.currentUser.status === 'busy' && + J.userIds.includes(this.API.currentUser.id) === true + ) { this.$message({ - message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', + message: + "You can't invite yourself in 'Do Not Disturb' mode", type: 'error' }); return; @@ -11130,19 +11952,25 @@ speechSynthesis.getVoices(); if (J.userIds.length > 0) { var receiverUserId = J.userIds.shift(); if ($app.uploadImage) { - API.sendInvitePhoto({ - instanceId: J.worldId, - worldId: J.worldId, - worldName: J.worldName, - messageSlot: slot - }, receiverUserId).finally(inviteLoop); + API.sendInvitePhoto( + { + instanceId: J.worldId, + worldId: J.worldId, + worldName: J.worldName, + messageSlot: slot + }, + receiverUserId + ).finally(inviteLoop); } else { - API.sendInvite({ - instanceId: J.worldId, - worldId: J.worldId, - worldName: J.worldName, - messageSlot: slot - }, receiverUserId).finally(inviteLoop); + API.sendInvite( + { + instanceId: J.worldId, + worldId: J.worldId, + worldName: J.worldName, + messageSlot: slot + }, + receiverUserId + ).finally(inviteLoop); } } else { J.loading = false; @@ -11154,54 +11982,60 @@ speechSynthesis.getVoices(); } }; inviteLoop(); - } else { - if (I.messageType === 'invite') { - I.params.messageSlot = slot; - if ($app.uploadImage) { - API.sendInvitePhoto(I.params, I.userId).catch((err) => { + } else if (I.messageType === 'invite') { + I.params.messageSlot = slot; + if ($app.uploadImage) { + API.sendInvitePhoto(I.params, I.userId) + .catch((err) => { throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Invite photo message sent', type: 'success' }); return args; }); - } else { - API.sendInvite(I.params, I.userId).catch((err) => { + } else { + API.sendInvite(I.params, I.userId) + .catch((err) => { throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Invite message sent', type: 'success' }); return args; }); - } - } else if (I.messageType === 'requestInvite') { - I.params.requestSlot = slot; - if ($app.uploadImage) { - API.sendRequestInvitePhoto(I.params, I.userId).catch((err) => { + } + } else if (I.messageType === 'requestInvite') { + I.params.requestSlot = slot; + if ($app.uploadImage) { + API.sendRequestInvitePhoto(I.params, I.userId) + .catch((err) => { this.clearInviteImageUpload(); throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Request invite photo message sent', type: 'success' }); return args; }); - } else { - API.sendRequestInvite(I.params, I.userId).catch((err) => { + } else { + API.sendRequestInvite(I.params, I.userId) + .catch((err) => { throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Request invite message sent', type: 'success' }); return args; }); - } } } this.sendInviteDialogVisible = false; @@ -11247,7 +12081,9 @@ speechSynthesis.getVoices(); if (this.editAndSendInviteDialog.visible === true || val === null) { return; } - this.$nextTick(() => adjustDialogZ(this.$refs.sendInviteConfirmDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.sendInviteConfirmDialog.$el) + ); this.sendInviteConfirmDialog.visible = true; this.sendInviteDialog.messageSlot = val.slot; }; @@ -11264,10 +12100,13 @@ speechSynthesis.getVoices(); var D = this.sendInviteDialog; var J = this.inviteDialog; if (J.visible) { - if (this.API.currentUser.status === 'busy' && - J.userIds.includes(this.API.currentUser.id) === true) { + if ( + this.API.currentUser.status === 'busy' && + J.userIds.includes(this.API.currentUser.id) === true + ) { this.$message({ - message: 'You can\'t invite yourself in \'Do Not Disturb\' mode', + message: + "You can't invite yourself in 'Do Not Disturb' mode", type: 'error' }); return; @@ -11276,19 +12115,25 @@ speechSynthesis.getVoices(); if (J.userIds.length > 0) { var receiverUserId = J.userIds.shift(); if ($app.uploadImage) { - API.sendInvitePhoto({ - instanceId: J.worldId, - worldId: J.worldId, - worldName: J.worldName, - messageSlot: D.messageSlot - }, receiverUserId).finally(inviteLoop); + API.sendInvitePhoto( + { + instanceId: J.worldId, + worldId: J.worldId, + worldName: J.worldName, + messageSlot: D.messageSlot + }, + receiverUserId + ).finally(inviteLoop); } else { - API.sendInvite({ - instanceId: J.worldId, - worldId: J.worldId, - worldName: J.worldName, - messageSlot: D.messageSlot - }, receiverUserId).finally(inviteLoop); + API.sendInvite( + { + instanceId: J.worldId, + worldId: J.worldId, + worldName: J.worldName, + messageSlot: D.messageSlot + }, + receiverUserId + ).finally(inviteLoop); } } else { J.loading = false; @@ -11300,54 +12145,60 @@ speechSynthesis.getVoices(); } }; inviteLoop(); - } else { - if (D.messageType === 'invite') { - D.params.messageSlot = D.messageSlot; - if ($app.uploadImage) { - API.sendInvitePhoto(D.params, D.userId).catch((err) => { + } else if (D.messageType === 'invite') { + D.params.messageSlot = D.messageSlot; + if ($app.uploadImage) { + API.sendInvitePhoto(D.params, D.userId) + .catch((err) => { throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Invite photo message sent', type: 'success' }); return args; }); - } else { - API.sendInvite(D.params, D.userId).catch((err) => { + } else { + API.sendInvite(D.params, D.userId) + .catch((err) => { throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Invite message sent', type: 'success' }); return args; }); - } - } else if (D.messageType === 'requestInvite') { - D.params.requestSlot = D.messageSlot; - if ($app.uploadImage) { - API.sendRequestInvitePhoto(D.params, D.userId).catch((err) => { + } + } else if (D.messageType === 'requestInvite') { + D.params.requestSlot = D.messageSlot; + if ($app.uploadImage) { + API.sendRequestInvitePhoto(D.params, D.userId) + .catch((err) => { this.clearInviteImageUpload(); throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Request invite photo message sent', type: 'success' }); return args; }); - } else { - API.sendRequestInvite(D.params, D.userId).catch((err) => { + } else { + API.sendRequestInvite(D.params, D.userId) + .catch((err) => { throw err; - }).then((args) => { + }) + .then((args) => { this.$message({ message: 'Request invite message sent', type: 'success' }); return args; }); - } } } this.sendInviteDialogVisible = false; @@ -11375,7 +12226,9 @@ speechSynthesis.getVoices(); messageType: 'requestInvite' }; API.refreshInviteMessageTableData('request'); - this.$nextTick(() => adjustDialogZ(this.$refs.sendInviteRequestDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.sendInviteRequestDialog.$el) + ); this.clearInviteImageUpload(); this.sendInviteRequestDialogVisible = true; }; @@ -11400,7 +12253,14 @@ speechSynthesis.getVoices(); $app.methods.friendsListSearchChange = function () { var filters = [...this.friendsListSearchFilters]; if (filters.length === 0) { - filters = ['Display Name', 'User Name', 'Rank', 'Status', 'Bio', 'Memo']; + filters = [ + 'Display Name', + 'User Name', + 'Rank', + 'Status', + 'Bio', + 'Memo' + ]; } var results = []; if (this.friendsListSearch) { @@ -11410,42 +12270,45 @@ speechSynthesis.getVoices(); if (typeof ctx.ref === 'undefined') { continue; } - if (this.friendsListSearchFilterVIP && - !ctx.isVIP) { + if (this.friendsListSearchFilterVIP && !ctx.isVIP) { continue; } if (query && filters) { var match = false; - if (!match && - filters.includes('User Name')) { + if (!match && filters.includes('User Name')) { var uname = String(ctx.ref.username); - match = uname.toUpperCase().includes(query) && + match = + uname.toUpperCase().includes(query) && !uname.startsWith('steam_'); } - if (!match && + if ( + !match && filters.includes('Display Name') && - ctx.ref.displayName) { - match = String(ctx.ref.displayName).toUpperCase().includes(query); + ctx.ref.displayName + ) { + match = String(ctx.ref.displayName) + .toUpperCase() + .includes(query); } - if (!match && - filters.includes('Memo') && - ctx.memo) { + if (!match && filters.includes('Memo') && ctx.memo) { match = String(ctx.memo).toUpperCase().includes(query); } - if (!match && - filters.includes('Bio') && - ctx.ref.bio) { + if (!match && filters.includes('Bio') && ctx.ref.bio) { match = String(ctx.ref.bio).toUpperCase().includes(query); } - if (!match && + if ( + !match && filters.includes('Status') && - ctx.ref.statusDescription) { - match = String(ctx.ref.statusDescription).toUpperCase().includes(query); + ctx.ref.statusDescription + ) { + match = String(ctx.ref.statusDescription) + .toUpperCase() + .includes(query); } - if (!match && - filters.includes('Rank') && - ctx.ref.$friendNum) { - match = String(ctx.ref.$trustLevel).toUpperCase().includes(query); + if (!match && filters.includes('Rank') && ctx.ref.$friendNum) { + match = String(ctx.ref.$trustLevel) + .toUpperCase() + .includes(query); } if (!match) { continue; @@ -11479,9 +12342,11 @@ speechSynthesis.getVoices(); i++; this.friendsListLoadingProgress = `${i}/${length}`; await API.getUser({ - userId: userId + userId + }); + await new Promise((resolve) => { + setTimeout(resolve, 1000); }); - await new Promise(resolve => setTimeout(resolve, 1000)); } this.friendsListLoadingProgress = ''; this.friendsListLoading = false; @@ -11529,11 +12394,16 @@ speechSynthesis.getVoices(); } }; var files = e.target.files || e.dataTransfer.files; - if ((!files.length) || (!this.avatarDialog.visible) || (this.avatarDialog.loading)) { + if ( + !files.length || + !this.avatarDialog.visible || + this.avatarDialog.loading + ) { clearFile(); return; } - if (files[0].size >= 10000000) { //10MB + if (files[0].size >= 10000000) { + // 10MB $app.$message({ message: 'File size too large', type: 'error' @@ -11543,7 +12413,7 @@ speechSynthesis.getVoices(); } if (!files[0].type.match(/image.png/)) { $app.$message({ - message: 'File isn\'t a png', + message: "File isn't a png", type: 'error' }); clearFile(); @@ -11557,9 +12427,11 @@ speechSynthesis.getVoices(); var fileSizeInBytes = file.total; var base64SignatureFile = await $app.genSig(base64File); var signatureMd5 = await $app.genMd5(base64SignatureFile); - var signatureSizeInBytes = await $app.genLength(base64SignatureFile); + var signatureSizeInBytes = await $app.genLength( + base64SignatureFile + ); var avatarId = $app.avatarDialog.id; - var { imageUrl } = $app.avatarDialog.ref; + var {imageUrl} = $app.avatarDialog.ref; var fileId = extractFileId(imageUrl); if (!fileId) { $app.$message({ @@ -11607,13 +12479,12 @@ speechSynthesis.getVoices(); console.error(err); this.uploadAvatarFailCleanup(fileId); } + return void 0; }; API.uploadAvatarFailCleanup = async function (fileId) { var json = await this.call(`file/${fileId}`, { method: 'GET' - }).then((json) => { - return json; }); var fileId = json.id; var fileVersion = json.versions[json.versions.length - 1].version; @@ -11628,7 +12499,8 @@ speechSynthesis.getVoices(); API.$on('AVATARIMAGE:INIT', function (args) { var fileId = args.json.id; - var fileVersion = args.json.versions[args.json.versions.length - 1].version; + var fileVersion = + args.json.versions[args.json.versions.length - 1].version; var params = { fileId, fileVersion @@ -11638,9 +12510,12 @@ speechSynthesis.getVoices(); API.uploadAvatarImageFileStart = async function (params) { try { - return await this.call(`file/${params.fileId}/${params.fileVersion}/file/start`, { - method: 'PUT' - }).then((json) => { + return await this.call( + `file/${params.fileId}/${params.fileVersion}/file/start`, + { + method: 'PUT' + } + ).then((json) => { var args = { json, params @@ -11652,11 +12527,12 @@ speechSynthesis.getVoices(); console.error(err); this.uploadAvatarFailCleanup(params.fileId); } + return void 0; }; API.$on('AVATARIMAGE:FILESTART', function (args) { - var { url } = args.json; - var { fileId, fileVersion } = args.params; + var {url} = args.json; + var {fileId, fileVersion} = args.params; var params = { url, fileId, @@ -11666,30 +12542,32 @@ speechSynthesis.getVoices(); }); API.uploadAvatarImageFileAWS = function (params) { - return webApiService.execute({ - url: params.url, - uploadFilePUT: true, - fileData: $app.avatarImage.base64File, - fileMIME: 'image/png', - headers: { - 'Content-MD5': $app.avatarImage.fileMd5 - } - }).then((json) => { - if (json.status !== 200) { - $app.avatarDialog.loading = false; - this.$throw('Avatar image upload failed', json); - } - var args = { - json, - params - }; - this.$emit('AVATARIMAGE:FILEAWS', args); - return args; - }); + return webApiService + .execute({ + url: params.url, + uploadFilePUT: true, + fileData: $app.avatarImage.base64File, + fileMIME: 'image/png', + headers: { + 'Content-MD5': $app.avatarImage.fileMd5 + } + }) + .then((json) => { + if (json.status !== 200) { + $app.avatarDialog.loading = false; + this.$throw('Avatar image upload failed', json); + } + var args = { + json, + params + }; + this.$emit('AVATARIMAGE:FILEAWS', args); + return args; + }); }; API.$on('AVATARIMAGE:FILEAWS', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var params = { fileId, fileVersion @@ -11698,13 +12576,16 @@ speechSynthesis.getVoices(); }); API.uploadAvatarImageFileFinish = function (params) { - return this.call(`file/${params.fileId}/${params.fileVersion}/file/finish`, { - method: 'PUT', - params: { - maxParts: 0, - nextPartNumber: 0 + return this.call( + `file/${params.fileId}/${params.fileVersion}/file/finish`, + { + method: 'PUT', + params: { + maxParts: 0, + nextPartNumber: 0 + } } - }).then((json) => { + ).then((json) => { var args = { json, params @@ -11715,7 +12596,7 @@ speechSynthesis.getVoices(); }; API.$on('AVATARIMAGE:FILEFINISH', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var params = { fileId, fileVersion @@ -11725,9 +12606,12 @@ speechSynthesis.getVoices(); API.uploadAvatarImageSigStart = async function (params) { try { - return await this.call(`file/${params.fileId}/${params.fileVersion}/signature/start`, { - method: 'PUT' - }).then((json) => { + return await this.call( + `file/${params.fileId}/${params.fileVersion}/signature/start`, + { + method: 'PUT' + } + ).then((json) => { var args = { json, params @@ -11739,11 +12623,12 @@ speechSynthesis.getVoices(); console.error(err); this.uploadAvatarFailCleanup(params.fileId); } + return void 0; }; API.$on('AVATARIMAGE:SIGSTART', function (args) { - var { url } = args.json; - var { fileId, fileVersion } = args.params; + var {url} = args.json; + var {fileId, fileVersion} = args.params; var params = { url, fileId, @@ -11753,30 +12638,32 @@ speechSynthesis.getVoices(); }); API.uploadAvatarImageSigAWS = function (params) { - return webApiService.execute({ - url: params.url, - uploadFilePUT: true, - fileData: $app.avatarImage.base64SignatureFile, - fileMIME: 'application/x-rsync-signature', - headers: { - 'Content-MD5': $app.avatarImage.signatureMd5 - } - }).then((json) => { - if (json.status !== 200) { - $app.avatarDialog.loading = false; - this.$throw('Avatar image upload failed', json); - } - var args = { - json, - params - }; - this.$emit('AVATARIMAGE:SIGAWS', args); - return args; - }); + return webApiService + .execute({ + url: params.url, + uploadFilePUT: true, + fileData: $app.avatarImage.base64SignatureFile, + fileMIME: 'application/x-rsync-signature', + headers: { + 'Content-MD5': $app.avatarImage.signatureMd5 + } + }) + .then((json) => { + if (json.status !== 200) { + $app.avatarDialog.loading = false; + this.$throw('Avatar image upload failed', json); + } + var args = { + json, + params + }; + this.$emit('AVATARIMAGE:SIGAWS', args); + return args; + }); }; API.$on('AVATARIMAGE:SIGAWS', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var params = { fileId, fileVersion @@ -11785,13 +12672,16 @@ speechSynthesis.getVoices(); }); API.uploadAvatarImageSigFinish = function (params) { - return this.call(`file/${params.fileId}/${params.fileVersion}/signature/finish`, { - method: 'PUT', - params: { - maxParts: 0, - nextPartNumber: 0 + return this.call( + `file/${params.fileId}/${params.fileVersion}/signature/finish`, + { + method: 'PUT', + params: { + maxParts: 0, + nextPartNumber: 0 + } } - }).then((json) => { + ).then((json) => { var args = { json, params @@ -11802,7 +12692,7 @@ speechSynthesis.getVoices(); }; API.$on('AVATARIMAGE:SIGFINISH', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var parmas = { id: $app.avatarImage.avatarId, imageUrl: `https://api.vrchat.cloud/api/1/file/${fileId}/${fileVersion}/file` @@ -11834,11 +12724,16 @@ speechSynthesis.getVoices(); } }; var files = e.target.files || e.dataTransfer.files; - if ((!files.length) || (!this.worldDialog.visible) || (this.worldDialog.loading)) { + if ( + !files.length || + !this.worldDialog.visible || + this.worldDialog.loading + ) { clearFile(); return; } - if (files[0].size >= 10000000) { //10MB + if (files[0].size >= 10000000) { + // 10MB $app.$message({ message: 'File size too large', type: 'error' @@ -11848,7 +12743,7 @@ speechSynthesis.getVoices(); } if (!files[0].type.match(/image.png/)) { $app.$message({ - message: 'File isn\'t a png', + message: "File isn't a png", type: 'error' }); clearFile(); @@ -11862,9 +12757,11 @@ speechSynthesis.getVoices(); var fileSizeInBytes = file.total; var base64SignatureFile = await $app.genSig(base64File); var signatureMd5 = await $app.genMd5(base64SignatureFile); - var signatureSizeInBytes = await $app.genLength(base64SignatureFile); + var signatureSizeInBytes = await $app.genLength( + base64SignatureFile + ); var worldId = $app.worldDialog.id; - var { imageUrl } = $app.worldDialog.ref; + var {imageUrl} = $app.worldDialog.ref; var fileId = extractFileId(imageUrl); if (!fileId) { $app.$message({ @@ -11912,13 +12809,12 @@ speechSynthesis.getVoices(); console.error(err); this.uploadWorldFailCleanup(fileId); } + return void 0; }; API.uploadWorldFailCleanup = async function (fileId) { var json = await this.call(`file/${fileId}`, { method: 'GET' - }).then((json) => { - return json; }); var fileId = json.id; var fileVersion = json.versions[json.versions.length - 1].version; @@ -11933,7 +12829,8 @@ speechSynthesis.getVoices(); API.$on('WORLDIMAGE:INIT', function (args) { var fileId = args.json.id; - var fileVersion = args.json.versions[args.json.versions.length - 1].version; + var fileVersion = + args.json.versions[args.json.versions.length - 1].version; var params = { fileId, fileVersion @@ -11943,9 +12840,12 @@ speechSynthesis.getVoices(); API.uploadWorldImageFileStart = async function (params) { try { - return await this.call(`file/${params.fileId}/${params.fileVersion}/file/start`, { - method: 'PUT' - }).then((json) => { + return await this.call( + `file/${params.fileId}/${params.fileVersion}/file/start`, + { + method: 'PUT' + } + ).then((json) => { var args = { json, params @@ -11957,11 +12857,12 @@ speechSynthesis.getVoices(); console.error(err); this.uploadWorldFailCleanup(params.fileId); } + return void 0; }; API.$on('WORLDIMAGE:FILESTART', function (args) { - var { url } = args.json; - var { fileId, fileVersion } = args.params; + var {url} = args.json; + var {fileId, fileVersion} = args.params; var params = { url, fileId, @@ -11971,30 +12872,32 @@ speechSynthesis.getVoices(); }); API.uploadWorldImageFileAWS = function (params) { - return webApiService.execute({ - url: params.url, - uploadFilePUT: true, - fileData: $app.worldImage.base64File, - fileMIME: 'image/png', - headers: { - 'Content-MD5': $app.worldImage.fileMd5 - } - }).then((json) => { - if (json.status !== 200) { - $app.worldDialog.loading = false; - this.$throw('World image upload failed', json); - } - var args = { - json, - params - }; - this.$emit('WORLDIMAGE:FILEAWS', args); - return args; - }); + return webApiService + .execute({ + url: params.url, + uploadFilePUT: true, + fileData: $app.worldImage.base64File, + fileMIME: 'image/png', + headers: { + 'Content-MD5': $app.worldImage.fileMd5 + } + }) + .then((json) => { + if (json.status !== 200) { + $app.worldDialog.loading = false; + this.$throw('World image upload failed', json); + } + var args = { + json, + params + }; + this.$emit('WORLDIMAGE:FILEAWS', args); + return args; + }); }; API.$on('WORLDIMAGE:FILEAWS', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var params = { fileId, fileVersion @@ -12003,13 +12906,16 @@ speechSynthesis.getVoices(); }); API.uploadWorldImageFileFinish = function (params) { - return this.call(`file/${params.fileId}/${params.fileVersion}/file/finish`, { - method: 'PUT', - params: { - maxParts: 0, - nextPartNumber: 0 + return this.call( + `file/${params.fileId}/${params.fileVersion}/file/finish`, + { + method: 'PUT', + params: { + maxParts: 0, + nextPartNumber: 0 + } } - }).then((json) => { + ).then((json) => { var args = { json, params @@ -12020,7 +12926,7 @@ speechSynthesis.getVoices(); }; API.$on('WORLDIMAGE:FILEFINISH', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var params = { fileId, fileVersion @@ -12030,9 +12936,12 @@ speechSynthesis.getVoices(); API.uploadWorldImageSigStart = async function (params) { try { - return await this.call(`file/${params.fileId}/${params.fileVersion}/signature/start`, { - method: 'PUT' - }).then((json) => { + return await this.call( + `file/${params.fileId}/${params.fileVersion}/signature/start`, + { + method: 'PUT' + } + ).then((json) => { var args = { json, params @@ -12044,11 +12953,12 @@ speechSynthesis.getVoices(); console.error(err); this.uploadWorldFailCleanup(params.fileId); } + return void 0; }; API.$on('WORLDIMAGE:SIGSTART', function (args) { - var { url } = args.json; - var { fileId, fileVersion } = args.params; + var {url} = args.json; + var {fileId, fileVersion} = args.params; var params = { url, fileId, @@ -12058,30 +12968,32 @@ speechSynthesis.getVoices(); }); API.uploadWorldImageSigAWS = function (params) { - return webApiService.execute({ - url: params.url, - uploadFilePUT: true, - fileData: $app.worldImage.base64SignatureFile, - fileMIME: 'application/x-rsync-signature', - headers: { - 'Content-MD5': $app.worldImage.signatureMd5 - } - }).then((json) => { - if (json.status !== 200) { - $app.worldDialog.loading = false; - this.$throw('World image upload failed', json); - } - var args = { - json, - params - }; - this.$emit('WORLDIMAGE:SIGAWS', args); - return args; - }); + return webApiService + .execute({ + url: params.url, + uploadFilePUT: true, + fileData: $app.worldImage.base64SignatureFile, + fileMIME: 'application/x-rsync-signature', + headers: { + 'Content-MD5': $app.worldImage.signatureMd5 + } + }) + .then((json) => { + if (json.status !== 200) { + $app.worldDialog.loading = false; + this.$throw('World image upload failed', json); + } + var args = { + json, + params + }; + this.$emit('WORLDIMAGE:SIGAWS', args); + return args; + }); }; API.$on('WORLDIMAGE:SIGAWS', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var params = { fileId, fileVersion @@ -12090,13 +13002,16 @@ speechSynthesis.getVoices(); }); API.uploadWorldImageSigFinish = function (params) { - return this.call(`file/${params.fileId}/${params.fileVersion}/signature/finish`, { - method: 'PUT', - params: { - maxParts: 0, - nextPartNumber: 0 + return this.call( + `file/${params.fileId}/${params.fileVersion}/signature/finish`, + { + method: 'PUT', + params: { + maxParts: 0, + nextPartNumber: 0 + } } - }).then((json) => { + ).then((json) => { var args = { json, params @@ -12107,7 +13022,7 @@ speechSynthesis.getVoices(); }; API.$on('WORLDIMAGE:SIGFINISH', function (args) { - var { fileId, fileVersion } = args.params; + var {fileId, fileVersion} = args.params; var parmas = { id: $app.worldImage.worldId, imageUrl: `https://api.vrchat.cloud/api/1/file/${fileId}/${fileVersion}/file` @@ -12176,9 +13091,9 @@ speechSynthesis.getVoices(); this.previousImagesTable = ''; var imageUrl = ''; if (type === 'Avatar') { - var { imageUrl } = this.avatarDialog.ref; + var {imageUrl} = this.avatarDialog.ref; } else if (type === 'World') { - var { imageUrl } = this.worldDialog.ref; + var {imageUrl} = this.worldDialog.ref; } else if (type === 'User') { imageUrl = this.userDialog.ref.currentAvatarImageUrl; } @@ -12191,55 +13106,61 @@ speechSynthesis.getVoices(); }; if (command === 'Display') { this.previousImagesDialogVisible = true; - this.$nextTick(() => adjustDialogZ(this.$refs.previousImagesDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.previousImagesDialog.$el) + ); } if (type === 'Avatar') { if (command === 'Change') { this.changeAvatarImageDialogVisible = true; - this.$nextTick(() => adjustDialogZ(this.$refs.changeAvatarImageDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.changeAvatarImageDialog.$el) + ); } API.getAvatarImages(params).then((args) => { this.previousImagesTableFileId = args.json.id; var images = args.json.versions.reverse(); - this.checkPreviousImageAvailable(images, command); + this.checkPreviousImageAvailable(images); }); } else if (type === 'World') { if (command === 'Change') { this.changeWorldImageDialogVisible = true; - this.$nextTick(() => adjustDialogZ(this.$refs.changeWorldImageDialog.$el)); + this.$nextTick(() => + adjustDialogZ(this.$refs.changeWorldImageDialog.$el) + ); } API.getWorldImages(params).then((args) => { this.previousImagesTableFileId = args.json.id; var images = args.json.versions.reverse(); - this.checkPreviousImageAvailable(images, command); + this.checkPreviousImageAvailable(images); }); } else if (type === 'User') { API.getAvatarImages(params).then((args) => { this.previousImagesTableFileId = args.json.id; var images = args.json.versions.reverse(); - this.checkPreviousImageAvailable(images, command); + this.checkPreviousImageAvailable(images); }); } }; - $app.methods.checkPreviousImageAvailable = async function (images, command) { + $app.methods.checkPreviousImageAvailable = async function (images) { this.previousImagesTable = []; for (var image of images) { - if ((image.file) && (image.file.url)) { + if (image.file && image.file.url) { var response = await fetch(image.file.url, { method: 'HEAD', redirect: 'follow', headers: { 'User-Agent': appVersion } - }).catch(error => { + }).catch((error) => { console.log(error); }); if (response.status === 200) { this.previousImagesTable.push(image); } } - }; + } }; $app.data.previousImagesDialogVisible = false; @@ -12255,8 +13176,8 @@ speechSynthesis.getVoices(); $app.previousImagesDialogVisible = false; }); - API.getAvatarImages = async function (params) { - return await this.call(`file/${params.fileId}`, { + API.getAvatarImages = function (params) { + return this.call(`file/${params.fileId}`, { method: 'GET', params }).then((json) => { @@ -12269,8 +13190,8 @@ speechSynthesis.getVoices(); }); }; - API.getWorldImages = async function (params) { - return await this.call(`file/${params.fileId}`, { + API.getWorldImages = function (params) { + return this.call(`file/${params.fileId}`, { method: 'GET', params }).then((json) => { @@ -12290,7 +13211,6 @@ speechSynthesis.getVoices(); $app.methods.storeAvatarImage = function (args) { var refCreatedAt = args.json.versions[0]; var fileCreatedAt = refCreatedAt.created_at; - var ref = args.json.versions[args.json.versions.length - 1]; var fileId = args.params.fileId; var avatarName = ''; var imageName = args.json.name; @@ -12333,7 +13253,10 @@ speechSynthesis.getVoices(); }; $app.methods.compareCurrentImage = function (image) { - if (`https://api.vrchat.cloud/api/1/file/${this.previousImagesTableFileId}/${image.version}/file` === this.avatarDialog.ref.imageUrl) { + if ( + `https://api.vrchat.cloud/api/1/file/${this.previousImagesTableFileId}/${image.version}/file` === + this.avatarDialog.ref.imageUrl + ) { return true; } return false; @@ -12354,7 +13277,7 @@ speechSynthesis.getVoices(); if (API.cachedAvatarNames.has(fileId)) { return API.cachedAvatarNames.get(fileId); } - var args = await API.getAvatarImages({ fileId }); + var args = await API.getAvatarImages({fileId}); return this.storeAvatarImage(args); }; @@ -12362,34 +13285,38 @@ speechSynthesis.getVoices(); $app.data.discordNamesContent = ''; $app.methods.showDiscordNamesDialog = function () { - var { friends } = API.currentUser; + var {friends} = API.currentUser; if (Array.isArray(friends) === false) { return; } - var lines = [ - 'DisplayName,DiscordName' - ]; + var lines = ['DisplayName,DiscordName']; var _ = function (str) { if (/[\x00-\x1f,"]/.test(str) === true) { - str = `"${str.replace(/"/g, '""')}"`; + return `"${str.replace(/"/g, '""')}"`; } return str; }; for (var userId of friends) { - var { ref } = this.friends.get(userId); + var {ref} = this.friends.get(userId); var discord = ''; if (typeof ref === 'undefined') { continue; } var name = ref.displayName; if (ref.statusDescription) { - var statusRegex = /(?:^|\n*)(?:(?:[^\n:]|\|)*(?::|˸|discord)[\t\v\f\r]*)?([^\n]*(#|#)(?: )?\d{4})/gi.exec(ref.statusDescription); + var statusRegex = + /(?:^|\n*)(?:(?:[^\n:]|\|)*(?::|˸|discord)[\t\v\f\r]*)?([^\n]*(#|#)(?: )?\d{4})/gi.exec( + ref.statusDescription + ); if (statusRegex) { discord = statusRegex[1]; } } - if ((!discord) && (ref.bio)) { - var bioRegex = /(?:^|\n*)(?:(?:[^\n:]|\|)*(?::|˸|discord)[\t\v\f\r]*)?([^\n]*(#|#)(?: )?\d{4})/gi.exec(ref.bio); + if (!discord && ref.bio) { + var bioRegex = + /(?:^|\n*)(?:(?:[^\n:]|\|)*(?::|˸|discord)[\t\v\f\r]*)?([^\n]*(#|#)(?: )?\d{4})/gi.exec( + ref.bio + ); if (bioRegex) { discord = bioRegex[1]; } @@ -12423,7 +13350,10 @@ speechSynthesis.getVoices(); this.setUserDialogAvatars(userId); if (this.userDialogLastAvatar !== userId) { this.userDialogLastAvatar = userId; - if ((userId === API.currentUser.id) && (this.userDialog.avatars.length === 0)) { + if ( + userId === API.currentUser.id && + this.userDialog.avatars.length === 0 + ) { this.refreshUserDialogAvatars(); } } @@ -12449,11 +13379,34 @@ speechSynthesis.getVoices(); $app.data.VRChatConfigFile = {}; $app.data.VRChatConfigList = { - cache_size: { name: 'Max Cache Size [GB] (minimum 20)', default: '20', type: 'number', min: 20 }, - cache_expiry_delay: { name: 'Cache Expiry [Days] (minimum 30)', default: '30', type: 'number', min: 30 }, - cache_directory: { name: 'Custom Cache Folder Location', default: '%AppData%\\..\\LocalLow\\VRChat\\vrchat' }, - dynamic_bone_max_affected_transform_count: { name: 'Dynamic Bones Limit Max Transforms (0 always disable transforms)', default: '32', type: 'number', min: 0 }, - dynamic_bone_max_collider_check_count: { name: 'Dynamic Bones Limit Max Collider Collisions (0 always disable colliders)', default: '8', type: 'number', min: 0 } + cache_size: { + name: 'Max Cache Size [GB] (minimum 20)', + default: '20', + type: 'number', + min: 20 + }, + cache_expiry_delay: { + name: 'Cache Expiry [Days] (minimum 30)', + default: '30', + type: 'number', + min: 30 + }, + cache_directory: { + name: 'Custom Cache Folder Location', + default: '%AppData%\\..\\LocalLow\\VRChat\\vrchat' + }, + dynamic_bone_max_affected_transform_count: { + name: 'Dynamic Bones Limit Max Transforms (0 always disable transforms)', + default: '32', + type: 'number', + min: 0 + }, + dynamic_bone_max_collider_check_count: { + name: 'Dynamic Bones Limit Max Collider Collisions (0 always disable colliders)', + default: '8', + type: 'number', + min: 0 + } }; $app.methods.readVRChatConfigFile = async function () { @@ -12472,8 +13425,8 @@ speechSynthesis.getVoices(); } }; - $app.methods.WriteVRChatConfigFile = async function () { - var json = JSON.stringify(this.VRChatConfigFile, null, "\t"); + $app.methods.WriteVRChatConfigFile = function () { + var json = JSON.stringify(this.VRChatConfigFile, null, '\t'); AppApi.WriteConfigFile(json); }; @@ -12498,10 +13451,19 @@ speechSynthesis.getVoices(); for (var item in this.VRChatConfigFile) { if (this.VRChatConfigFile[item] === '') { delete this.VRChatConfigFile[item]; - } else if ((typeof this.VRChatConfigFile[item] === 'boolean') && (this.VRChatConfigFile[item] === false)) { + } else if ( + typeof this.VRChatConfigFile[item] === 'boolean' && + this.VRChatConfigFile[item] === false + ) { delete this.VRChatConfigFile[item]; - } else if ((typeof this.VRChatConfigFile[item] === 'string') && (!isNaN(this.VRChatConfigFile[item]))) { - this.VRChatConfigFile[item] = parseInt(this.VRChatConfigFile[item]); + } else if ( + typeof this.VRChatConfigFile[item] === 'string' && + !isNaN(this.VRChatConfigFile[item]) + ) { + this.VRChatConfigFile[item] = parseInt( + this.VRChatConfigFile[item], + 10 + ); } } this.VRChatConfigDialog.visible = false; @@ -12518,49 +13480,46 @@ speechSynthesis.getVoices(); }; $app.data.VRChatResolutions = [ - { name: '1280x720 (720p)', width: 1280, height: 720 }, - { name: '1920x1080 (Default 1080p)', width: '', height: '' }, - { name: '2560x1440 (2K)', width: 2560, height: 1440 }, - { name: '3840x2160 (4K)', width: 3840, height: 2160 } + {name: '1280x720 (720p)', width: 1280, height: 720}, + {name: '1920x1080 (Default 1080p)', width: '', height: ''}, + {name: '2560x1440 (2K)', width: 2560, height: 1440}, + {name: '3840x2160 (4K)', width: 3840, height: 2160} ]; $app.methods.getVRChatResolution = function (res) { switch (res) { case '1280x720': return '1280x720 (720p)'; - break; case '1920x1080': return '1920x1080 (1080p)'; - break; case '2560x1440': return '2560x1440 (2K)'; - break; case '3840x2160': return '3840x2160 (4K)'; - break; - default: - return `${res} (Custom)`; } + return `${res} (Custom)`; }; $app.methods.getVRChatCameraResolution = function () { - if ((this.VRChatConfigFile.camera_res_height) && - (this.VRChatConfigFile.camera_res_width)) { + if ( + this.VRChatConfigFile.camera_res_height && + this.VRChatConfigFile.camera_res_width + ) { var res = `${this.VRChatConfigFile.camera_res_width}x${this.VRChatConfigFile.camera_res_height}`; return this.getVRChatResolution(res); - } else { - return '1920x1080 (1080p)'; } + return '1920x1080 (1080p)'; }; $app.methods.getVRChatScreenshotResolution = function () { - if ((this.VRChatConfigFile.screenshot_res_height) && - (this.VRChatConfigFile.screenshot_res_width)) { + if ( + this.VRChatConfigFile.screenshot_res_height && + this.VRChatConfigFile.screenshot_res_width + ) { var res = `${this.VRChatConfigFile.screenshot_res_width}x${this.VRChatConfigFile.screenshot_res_height}`; return this.getVRChatResolution(res); - } else { - return '1920x1080 (1080p)'; } + return '1920x1080 (1080p)'; }; $app.methods.setVRChatCameraResolution = function (res) { @@ -12613,7 +13572,11 @@ speechSynthesis.getVoices(); $app.methods.checkVRChatCache = async function (ref) { var cacheDir = await this.getVRChatCacheDir(); - return await AssetBundleCacher.CheckVRChatCache(ref.id, ref.version, cacheDir); + return AssetBundleCacher.CheckVRChatCache( + ref.id, + ref.version, + cacheDir + ); }; $app.methods.queueCacheDownload = function (ref, type) { @@ -12621,15 +13584,17 @@ speechSynthesis.getVoices(); var date = new Date().toJSON(); var userId = ''; var location = ref.id; - this.downloadQueue.set(ref.id, { ref, type, date, userId, location }); - this.downloadQueueTable.data = Array.from(this.downloadQueue.values()); + this.downloadQueue.set(ref.id, {ref, type, date, userId, location}); + this.downloadQueueTable.data = Array.from( + this.downloadQueue.values() + ); } if (!this.downloadInProgress) { this.downloadVRChatCache(); } }; - API.getBundles = async function (fileId) { + API.getBundles = function (fileId) { return this.call(`file/${fileId}`, { method: 'GET' }).then((json) => { @@ -12649,20 +13614,31 @@ speechSynthesis.getVoices(); this.downloadInProgress = true; this.downloadCurrent = this.downloadQueue.values().next().value; this.downloadCurrent.id = this.downloadQueue.keys().next().value; - var { ref, type } = this.downloadCurrent; + var {ref} = this.downloadCurrent; this.downloadQueue.delete(ref.id); this.downloadQueueTable.data = Array.from(this.downloadQueue.values()); if (this.downloadCurrent.id === 'VRCXUpdate') { var url = this.downloadCurrent.updateZipUrl; - await AssetBundleCacher.DownloadCacheFile('', url, '', 0, 0, '', appVersion, true); + await AssetBundleCacher.DownloadCacheFile( + '', + url, + '', + 0, + 0, + '', + appVersion, + true + ); this.downloadVRChatCacheProgress(); return; } var assetUrl = ''; for (var i = ref.unityPackages.length - 1; i > -1; i--) { var unityPackage = ref.unityPackages[i]; - if ((unityPackage.platform === 'standalonewindows') && - (this.compareUnityVersion(unityPackage.unityVersion))) { + if ( + unityPackage.platform === 'standalonewindows' && + this.compareUnityVersion(unityPackage.unityVersion) + ) { assetUrl = unityPackage.assetUrl; break; } @@ -12689,11 +13665,11 @@ speechSynthesis.getVoices(); this.downloadVRChatCache(); return; } - var { versions } = args.json; + var {versions} = args.json; var file = ''; for (var i = versions.length - 1; i > -1; i--) { var version = versions[i]; - if (version.version == fileVersion) { + if (version.version === fileVersion) { file = version.file; break; } @@ -12707,9 +13683,18 @@ speechSynthesis.getVoices(); this.downloadVRChatCache(); return; } - var { url, md5, sizeInBytes } = file; + var {url, md5, sizeInBytes} = file; var cacheDir = await this.getVRChatCacheDir(); - await AssetBundleCacher.DownloadCacheFile(cacheDir, url, ref.id, ref.version, sizeInBytes, md5, appVersion, false); + await AssetBundleCacher.DownloadCacheFile( + cacheDir, + url, + ref.id, + ref.version, + sizeInBytes, + md5, + appVersion, + false + ); this.downloadVRChatCacheProgress(); }; @@ -12718,11 +13703,11 @@ speechSynthesis.getVoices(); if (L.worldId) { if (this.downloadCurrent.id === L.worldId) { this.cancelVRChatCacheDownload(L.worldId); - } else { - if (this.downloadQueue.has(L.worldId)) { - this.downloadQueue.delete(L.worldId); - this.downloadQueueTable.data = Array.from(this.downloadQueue.values()); - } + } else if (this.downloadQueue.has(L.worldId)) { + this.downloadQueue.delete(L.worldId); + this.downloadQueueTable.data = Array.from( + this.downloadQueue.values() + ); } } }; @@ -12733,7 +13718,9 @@ speechSynthesis.getVoices(); } if (this.downloadQueue.has(worldId)) { this.downloadQueue.delete(worldId); - this.downloadQueueTable.data = Array.from(this.downloadQueue.values()); + this.downloadQueueTable.data = Array.from( + this.downloadQueue.values() + ); } }; @@ -12747,33 +13734,46 @@ speechSynthesis.getVoices(); }; API.$on('NOTIFICATION', function (args) { - var { json } = args; + var {json} = args; if (json.type === 'invite') { $app.inviteDownloadWorldCache(json); } }); $app.methods.inviteDownloadWorldCache = function (invite) { - if ((this.worldAutoCacheInvite === 'Always') || - ((this.worldAutoCacheInvite === 'Game Closed') && (!this.isGameRunning)) || - ((this.worldAutoCacheInvite === 'Game Running') && (this.isGameRunning))) { - if ((!this.worldAutoCacheInviteFilter) && - (!API.cachedFavoritesByObjectId.has(invite.senderUserId))) { + if ( + this.worldAutoCacheInvite === 'Always' || + (this.worldAutoCacheInvite === 'Game Closed' && + !this.isGameRunning) || + (this.worldAutoCacheInvite === 'Game Running' && this.isGameRunning) + ) { + if ( + !this.worldAutoCacheInviteFilter && + !API.cachedFavoritesByObjectId.has(invite.senderUserId) + ) { return; } - this.autoDownloadWorldCache(invite.details.worldId, 'Invite', invite.senderUserId); + this.autoDownloadWorldCache( + invite.details.worldId, + 'Invite', + invite.senderUserId + ); } }; $app.methods.feedDownloadWorldCache = function (id, location) { - if ((this.worldAutoCacheGPS === 'Always') || - ((this.worldAutoCacheGPS === 'Game Closed') && (!this.isGameRunning)) || - ((this.worldAutoCacheGPS === 'Game Running') && (this.isGameRunning))) { - if ((location === '') || - (location === 'offline') || - (location === 'private') || - ((!this.worldAutoCacheGPSFilter) && - (!API.cachedFavoritesByObjectId.has(id)))) { + if ( + this.worldAutoCacheGPS === 'Always' || + (this.worldAutoCacheGPS === 'Game Closed' && !this.isGameRunning) || + (this.worldAutoCacheGPS === 'Game Running' && this.isGameRunning) + ) { + if ( + location === '' || + location === 'offline' || + location === 'private' || + (!this.worldAutoCacheGPSFilter && + !API.cachedFavoritesByObjectId.has(id)) + ) { return; } this.autoDownloadWorldCache(location, 'GPS', id); @@ -12782,19 +13782,28 @@ speechSynthesis.getVoices(); $app.methods.autoDownloadWorldCache = function (location, type, userId) { var L = API.parseLocation(location); - if ((!L.worldId) || - (this.downloadQueue.has(L.worldId)) || - (this.downloadCurrent.id === L.worldId)) { + if ( + !L.worldId || + this.downloadQueue.has(L.worldId) || + this.downloadCurrent.id === L.worldId + ) { return; } API.getWorld({ worldId: L.worldId }).then((args) => { - var { ref } = args; + var {ref} = args; this.checkVRChatCache(ref).then((cacheInfo) => { - if ((cacheInfo[0] === -1) && (cacheInfo[1] === 0)) { - this.downloadQueue.set(ref.id, { ref, type, userId, location }); - this.downloadQueueTable.data = Array.from(this.downloadQueue.values()); + if (cacheInfo[0] === -1 && cacheInfo[1] === 0) { + this.downloadQueue.set(ref.id, { + ref, + type, + userId, + location + }); + this.downloadQueueTable.data = Array.from( + this.downloadQueue.values() + ); if (!this.downloadInProgress) { this.downloadVRChatCache(); } @@ -12862,7 +13871,7 @@ speechSynthesis.getVoices(); return; case -10: this.$message({ - message: 'AssetBundleCacher can\'t be located', + message: "AssetBundleCacher can't be located", type: 'error' }); this.downloadCurrent = {}; @@ -12873,7 +13882,8 @@ speechSynthesis.getVoices(); return; case -11: this.$message({ - message: 'Delete \'data.unity3d\' file from AssetBundleCacher_Data folder', + message: + "Delete 'data.unity3d' file from AssetBundleCacher_Data folder", type: 'error' }); this.downloadCurrent = {}; @@ -12977,7 +13987,7 @@ speechSynthesis.getVoices(); return 'Processing'; } if (this.downloadProgress >= 0) { - return this.downloadProgress + '%'; + return `${this.downloadProgress}%`; } return ''; }; @@ -13059,19 +14069,22 @@ speechSynthesis.getVoices(); $app.methods.parseLocationUrl = function (location) { var url = new URL(location); var urlPath = url.pathname; - if ('/world/' === urlPath.substring(5, 12)) { + if (urlPath.substring(5, 12) === '/world/') { var worldId = urlPath.substring(12); return worldId; - } else if ('/launch' === urlPath.substring(5, 12)) { + } + if (urlPath.substring(5, 12) === '/launch') { var urlParams = new URLSearchParams(url.search); var worldId = urlParams.get('worldId'); var instanceId = urlParams.get('instanceId'); if (instanceId) { return `${worldId}:${instanceId}`; - } else if (worldId) { + } + if (worldId) { return worldId; } } + return void 0; }; // Parse User URL @@ -13079,10 +14092,11 @@ speechSynthesis.getVoices(); $app.methods.parseUserUrl = function (user) { var url = new URL(user); var urlPath = url.pathname; - if ('/user/' === urlPath.substring(5, 11)) { + if (urlPath.substring(5, 11) === '/user/') { var userId = urlPath.substring(11); return userId; } + return void 0; }; // Parse Avatar URL @@ -13090,10 +14104,11 @@ speechSynthesis.getVoices(); $app.methods.parseAvatarUrl = function (avatar) { var url = new URL(avatar); var urlPath = url.pathname; - if ('/avatar/' === urlPath.substring(5, 13)) { + if (urlPath.substring(5, 13) === '/avatar/') { var avatarId = urlPath.substring(13); return avatarId; } + return void 0; }; // userDialog Favorite Worlds @@ -13125,8 +14140,7 @@ speechSynthesis.getVoices(); try { var args = await API.getFavoriteWorlds(params); worldLists.push([list.displayName, list.visibility, args.json]); - } catch (err) { - } + } catch (err) {} } this.userFavoriteWorlds = worldLists; this.userDialog.isFavoriteWorldsLoading = false; @@ -13232,7 +14246,7 @@ speechSynthesis.getVoices(); API.$on('GALLERYIMAGE:DELETE', function (args) { var array = $app.galleryTable; - var { length } = array; + var {length} = array; for (var i = 0; i < length; ++i) { if (args.fileId === array[i].id) { array.splice(i, 1); @@ -13242,7 +14256,9 @@ speechSynthesis.getVoices(); }); $app.methods.compareCurrentProfilePic = function (fileId) { - var currentProfilePicOverride = extractFileId(API.currentUser.profilePicOverride); + var currentProfilePicOverride = extractFileId( + API.currentUser.profilePicOverride + ); if (fileId === currentProfilePicOverride) { return true; } @@ -13259,7 +14275,8 @@ speechSynthesis.getVoices(); if (!files.length) { return; } - if (files[0].size >= 10000000) { //10MB + if (files[0].size >= 10000000) { + // 10MB $app.$message({ message: 'File size too large', type: 'error' @@ -13269,7 +14286,7 @@ speechSynthesis.getVoices(); } if (!files[0].type.match(/image.*/)) { $app.$message({ - message: 'File isn\'t an image', + message: "File isn't an image", type: 'error' }); clearFile(); @@ -13316,12 +14333,12 @@ speechSynthesis.getVoices(); $app.methods.replaceBioSymbols = function (text) { if (!text) { - return; + return void 0; } var symbolList = { '@': '@', '#': '#', - '$': '$', + $: '$', '%': '%', '&': '&', '=': '=', @@ -13347,17 +14364,17 @@ speechSynthesis.getVoices(); '|': '|', '*': '∗' }; + var newText = text; for (var key in symbolList) { - var regex = new RegExp(symbolList[key], "g"); - text = text.replace(regex, key); + var regex = new RegExp(symbolList[key], 'g'); + newText = newText.replace(regex, key); } - text = text.replace(/ {1,}/g, ' '); - return text; + return newText.replace(/ {1,}/g, ' '); }; $app.methods.checkCanInvite = function (location) { var L = API.parseLocation(location); - if ((L.accessType === 'invite') || (L.accessType === 'friends')) { + if (L.accessType === 'invite' || L.accessType === 'friends') { if (L.userId === API.currentUser.id) { return false; } @@ -13367,7 +14384,7 @@ speechSynthesis.getVoices(); }; $app.methods.setAsideWidth = function () { - document.getElementById('aside').style.width = this.asideWidth + 'px'; + document.getElementById('aside').style.width = `${this.asideWidth}px`; configRepository.setInt('VRCX_asidewidth', this.asideWidth); }; @@ -13383,8 +14400,16 @@ speechSynthesis.getVoices(); $app.data.checkingForVRCXUpdate = false; $app.data.branches = { - Stable: { name: 'Stable', urlReleases: 'https://vrcx.pypy.moe/releases/pypy-vrc.json', urlLatest: 'https://vrcx.pypy.moe/releases/latest/pypy-vrc.json' }, - Beta: { name: 'Beta', urlReleases: 'https://vrcx.pypy.moe/releases/natsumi-sama.json', urlLatest: 'https://vrcx.pypy.moe/releases/latest/natsumi-sama.json' } + Stable: { + name: 'Stable', + urlReleases: 'https://vrcx.pypy.moe/releases/pypy-vrc.json', + urlLatest: 'https://vrcx.pypy.moe/releases/latest/pypy-vrc.json' + }, + Beta: { + name: 'Beta', + urlReleases: 'https://vrcx.pypy.moe/releases/natsumi-sama.json', + urlLatest: 'https://vrcx.pypy.moe/releases/latest/natsumi-sama.json' + } }; $app.methods.showVRCXUpdateDialog = async function () { @@ -13395,12 +14420,22 @@ speechSynthesis.getVoices(); this.loadBranchVersions(); }; - $app.methods.downloadVRCXUpdate = function (updateZipUrl, name, type, autoInstall) { + $app.methods.downloadVRCXUpdate = function ( + updateZipUrl, + name, + type, + autoInstall + ) { var ref = { id: 'VRCXUpdate', name }; - this.downloadQueue.set('VRCXUpdate', { ref, type, updateZipUrl, autoInstall }); + this.downloadQueue.set('VRCXUpdate', { + ref, + type, + updateZipUrl, + autoInstall + }); this.downloadQueueTable.data = Array.from(this.downloadQueue.values()); if (!this.downloadInProgress) { this.downloadVRChatCache(); @@ -13441,7 +14476,10 @@ speechSynthesis.getVoices(); var releases = []; for (var release of json) { for (var asset of release.assets) { - if ((asset.content_type === 'application/x-msdownload') && (asset.state === 'uploaded')) { + if ( + asset.content_type === 'application/x-msdownload' && + asset.state === 'uploaded' + ) { releases.push(release); } } @@ -13472,13 +14510,17 @@ speechSynthesis.getVoices(); }); this.checkingForVRCXUpdate = false; var json = JSON.parse(response.data); - if (json === Object(json) && - json.name && - json.published_at) { - this.latestAppVersion = `${json.name} (${formatDate(json.published_at, 'YYYY-MM-DD HH24:MI:SS')})`; + if (json === Object(json) && json.name && json.published_at) { + this.latestAppVersion = `${json.name} (${formatDate( + json.published_at, + 'YYYY-MM-DD HH24:MI:SS' + )})`; if (json.name > this.appVersion) { for (var asset of json.assets) { - if ((asset.content_type === 'application/octet-stream') && (asset.state === 'uploaded')) { + if ( + asset.content_type === 'application/octet-stream' && + asset.state === 'uploaded' + ) { var downloadUrl = asset.browser_download_url; break; } @@ -13493,10 +14535,20 @@ speechSynthesis.getVoices(); this.showVRCXUpdateDialog(); } else if (this.autoUpdateVRCX === 'Auto Download') { var autoInstall = false; - this.downloadVRCXUpdate(downloadUrl, name, type, autoInstall); + this.downloadVRCXUpdate( + downloadUrl, + name, + type, + autoInstall + ); } else if (this.autoUpdateVRCX === 'Auto Install') { var autoInstall = true; - this.downloadVRCXUpdate(downloadUrl, name, type, autoInstall); + this.downloadVRCXUpdate( + downloadUrl, + name, + type, + autoInstall + ); } } } else { @@ -13505,9 +14557,12 @@ speechSynthesis.getVoices(); }; $app.methods.compareUnityVersion = function (version) { - var currentUnityVersion = API.cachedConfig.sdkUnityVersion.replace(/\D/g, ''); + var currentUnityVersion = API.cachedConfig.sdkUnityVersion.replace( + /\D/g, + '' + ); var assetVersion = version.replace(/\D/g, ''); - if (parseInt(assetVersion) <= parseInt(currentUnityVersion)) { + if (parseInt(assetVersion, 10) <= parseInt(currentUnityVersion, 10)) { return true; } return false; @@ -13515,4 +14570,4 @@ speechSynthesis.getVoices(); $app = new Vue($app); window.$app = $app; -}()); +})(); diff --git a/html/src/app.scss b/html/src/app.scss index 32ee30c5..01bdc707 100644 --- a/html/src/app.scss +++ b/html/src/app.scss @@ -8,11 +8,12 @@ // For a copy, see . // -@import "~normalize.css/normalize.css"; -@import "~animate.css/animate.min.css"; -@import "~noty/lib/noty.css"; -@import "~element-ui/lib/theme-chalk/index.css"; -@import "~famfamfam-flags/dist/sprite/famfamfam-flags.min.css"; +@import '~normalize.css/normalize.css'; +@import '~animate.css/animate.min.css'; +@import '~noty/lib/noty.css'; +@import '~element-ui/lib/theme-chalk/index.css'; +@import '~famfamfam-flags/dist/sprite/famfamfam-flags.min.css'; +@import '~vue-swatches/dist/vue-swatches.css'; .color-palettes { background: #409eff; @@ -113,7 +114,8 @@ input, textarea, select, button { - font-family: "Noto Sans JP", "Noto Sans KR", "Meiryo UI", "Malgun Gothic", "Segoe UI", sans-serif; + font-family: 'Noto Sans JP', 'Noto Sans KR', 'Meiryo UI', 'Malgun Gothic', + 'Segoe UI', sans-serif; line-height: normal; } @@ -179,7 +181,7 @@ a { left: 1px; width: 2px; height: 48px; - content: ""; + content: ''; background: #dcdfe6; } @@ -189,7 +191,7 @@ a { right: 4px; width: 4px; height: 4px; - content: ""; + content: ''; background: #ebeef5; border-radius: 50%; } @@ -317,7 +319,7 @@ img.friends-list-avatar { bottom: 0; width: 8px; height: 8px; - content: ""; + content: ''; background: #909399; border: 2px solid #fff; border-radius: 50%; @@ -497,7 +499,7 @@ i.x-user-status.busy { margin-right: -85px; } -.el-progress__text{ +.el-progress__text { color: #c8c8c8; } diff --git a/html/src/repository/config.js b/html/src/repository/config.js index 923e01df..c3fcf00a 100644 --- a/html/src/repository/config.js +++ b/html/src/repository/config.js @@ -1,5 +1,5 @@ import sqliteService from '../service/sqlite.js'; -import sharedRepository, { SharedRepository } from './shared.js'; +import sharedRepository, {SharedRepository} from './shared.js'; var dirtyKeySet = new Set(); @@ -55,28 +55,25 @@ class ConfigRepository extends SharedRepository { } remove(key) { - key = transformKey(key); - sharedRepository.remove(key); - dirtyKeySet.add(key); + var _key = transformKey(key); + sharedRepository.remove(_key); + dirtyKeySet.add(_key); } getString(key, defaultValue = null) { - key = transformKey(key); - return sharedRepository.getString(key, defaultValue); + var _key = transformKey(key); + return sharedRepository.getString(_key, defaultValue); } setString(key, value) { - key = transformKey(key); - value = String(value); - sharedRepository.setString(key, value); - dirtyKeySet.add(key); + var _key = transformKey(key); + var _value = String(value); + sharedRepository.setString(_key, _value); + dirtyKeySet.add(_key); } } var self = new ConfigRepository(); window.configRepository = self; -export { - self as default, - ConfigRepository -}; +export {self as default, ConfigRepository}; diff --git a/html/src/repository/database.js b/html/src/repository/database.js index 059e30a8..0ec42f4a 100644 --- a/html/src/repository/database.js +++ b/html/src/repository/database.js @@ -29,7 +29,7 @@ class Database { async getFeedDatabase() { var feedDatabase = []; var date = new Date(); - date.setDate(date.getDate() - 3); // 3 day limit + date.setDate(date.getDate() - 3); // 3 day limit var dateOffset = date.toJSON(); await sqliteService.execute((dbRow) => { var row = { @@ -113,7 +113,7 @@ class Database { async getMemo(userId) { var row = {}; - await sqliteService.execute((dbRow, userId) => { + await sqliteService.execute((dbRow) => { row = { userId: dbRow[0], editedAt: dbRow[1], @@ -177,7 +177,7 @@ class Database { var field = {}; for (var item of items) { if (typeof line[item] === 'string') { - field[item] = line[item].replace(/'/g, "\''"); + field[item] = line[item].replace(/'/g, "''"); } else { field[item] = ''; } @@ -240,15 +240,23 @@ class Database { return; } var sqlValues = ''; - var items = ['created_at', 'type', 'userId', 'displayName', 'previousDisplayName', 'trustLevel', 'previousTrustLevel']; + var items = [ + 'created_at', + 'type', + 'userId', + 'displayName', + 'previousDisplayName', + 'trustLevel', + 'previousTrustLevel' + ]; for (var i = 0; i < inputData.length; ++i) { var line = inputData[i]; - sqlValues += '('; + sqlValues += '('; for (var k = 0; k < items.length; ++k) { var item = items[k]; var field = ''; if (typeof line[item] === 'string') { - field = `'${line[item].replace(/'/g, "\''")}'`; + field = `'${line[item].replace(/'/g, "''")}'`; } else { field = null; } @@ -257,11 +265,11 @@ class Database { sqlValues += ', '; } } - sqlValues += ')'; + sqlValues += ')'; if (i < inputData.length - 1) { sqlValues += ', '; } - //sqlValues `('${line.created_at}', '${line.type}', '${line.userId}', '${line.displayName}', '${line.previousDisplayName}', '${line.trustLevel}', '${line.previousTrustLevel}'), ` + // sqlValues `('${line.created_at}', '${line.type}', '${line.userId}', '${line.displayName}', '${line.previousDisplayName}', '${line.trustLevel}', '${line.previousTrustLevel}'), ` } sqliteService.executeNonQuery( `INSERT OR IGNORE INTO ${Database.userId}_friend_log_history (created_at, type, user_id, display_name, previous_display_name, trust_level, previous_trust_level) VALUES ${sqlValues}` @@ -317,9 +325,12 @@ class Database { '@owner_id': entry.ownerId, '@avatar_name': entry.avatarName, '@current_avatar_image_url': entry.currentAvatarImageUrl, - '@current_avatar_thumbnail_image_url': entry.currentAvatarThumbnailImageUrl, - '@previous_current_avatar_image_url': entry.previousCurrentAvatarImageUrl, - '@previous_current_avatar_thumbnail_image_url': entry.previousCurrentAvatarThumbnailImageUrl + '@current_avatar_thumbnail_image_url': + entry.currentAvatarThumbnailImageUrl, + '@previous_current_avatar_image_url': + entry.previousCurrentAvatarImageUrl, + '@previous_current_avatar_thumbnail_image_url': + entry.previousCurrentAvatarThumbnailImageUrl } ); } @@ -343,7 +354,4 @@ class Database { var self = new Database(); window.database = self; -export { - self as default, - Database -}; +export {self as default, Database}; diff --git a/html/src/repository/shared.js b/html/src/repository/shared.js index 8b2837ef..2d86c9ce 100644 --- a/html/src/repository/shared.js +++ b/html/src/repository/shared.js @@ -6,13 +6,13 @@ function transformKey(key) { class SharedRepository { remove(key) { - key = transformKey(key); - return SharedVariable.Remove(key); + var _key = transformKey(key); + return SharedVariable.Remove(_key); } getString(key, defaultValue = null) { - key = transformKey(key); - var value = SharedVariable.Get(key); + var _key = transformKey(key); + var value = SharedVariable.Get(_key); if (value === null) { return defaultValue; } @@ -20,9 +20,9 @@ class SharedRepository { } setString(key, value) { - key = transformKey(key); - value = String(value); - SharedVariable.Set(key, value); + var _key = transformKey(key); + var _value = String(value); + SharedVariable.Set(_key, _value); } getBool(key, defaultValue = null) { @@ -76,8 +76,7 @@ class SharedRepository { } try { value = JSON.parse(value); - } catch (err) { - } + } catch (err) {} if (value !== Object(value)) { return defaultValue; } @@ -104,7 +103,4 @@ class SharedRepository { var self = new SharedRepository(); window.sharedRepository = self; -export { - self as default, - SharedRepository -}; +export {self as default, SharedRepository}; diff --git a/html/src/security.js b/html/src/security.js index 268eb0eb..d42cb17e 100644 --- a/html/src/security.js +++ b/html/src/security.js @@ -1,67 +1,67 @@ const defaultAESKey = new TextEncoder().encode( - 'https://github.com/pypy-vrc/VRCX' -) + 'https://github.com/pypy-vrc/VRCX' +); const hexToUint8Array = (hexStr) => { - const r = hexStr.match(/.{1,2}/g) - if (!r) return null - return new Uint8Array(r.map((b) => parseInt(b, 16))) -} + const r = hexStr.match(/.{1,2}/g); + if (!r) return null; + return new Uint8Array(r.map((b) => parseInt(b, 16))); +}; const uint8ArrayToHex = (arr) => - arr.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '') + arr.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), ''); function stdAESKey(key) { - const tKey = new TextEncoder().encode(key) - let sk = tKey - if (key.length < 32) { - sk = new Uint8Array(32) - sk.set(tKey) - sk.set(defaultAESKey.slice(key.length, 32), key.length) - } - return sk.slice(0, 32) + const tKey = new TextEncoder().encode(key); + let sk = tKey; + if (key.length < 32) { + sk = new Uint8Array(32); + sk.set(tKey); + sk.set(defaultAESKey.slice(key.length, 32), key.length); + } + return sk.slice(0, 32); } async function encrypt(plaintext, key) { - let iv = window.crypto.getRandomValues(new Uint8Array(12)) - let sharedKey = await window.crypto.subtle.importKey( - 'raw', - stdAESKey(key), - { name: 'AES-GCM', length: 256 }, - true, - ['encrypt'] - ) - let cipher = await window.crypto.subtle.encrypt( - { name: 'AES-GCM', iv }, - sharedKey, - new TextEncoder().encode(plaintext) - ) - let ciphertext = new Uint8Array(cipher) - let encrypted = new Uint8Array(iv.length + ciphertext.byteLength) - encrypted.set(iv, 0) - encrypted.set(ciphertext, iv.length) - return uint8ArrayToHex(encrypted) + let iv = window.crypto.getRandomValues(new Uint8Array(12)); + let sharedKey = await window.crypto.subtle.importKey( + 'raw', + stdAESKey(key), + {name: 'AES-GCM', length: 256}, + true, + ['encrypt'] + ); + let cipher = await window.crypto.subtle.encrypt( + {name: 'AES-GCM', iv}, + sharedKey, + new TextEncoder().encode(plaintext) + ); + let ciphertext = new Uint8Array(cipher); + let encrypted = new Uint8Array(iv.length + ciphertext.byteLength); + encrypted.set(iv, 0); + encrypted.set(ciphertext, iv.length); + return uint8ArrayToHex(encrypted); } async function decrypt(ciphertext, key) { - let text = hexToUint8Array(ciphertext) - if (!text) return '' - let sharedKey = await window.crypto.subtle.importKey( - 'raw', - stdAESKey(key), - { name: 'AES-GCM', length: 256 }, - true, - ['decrypt'] - ) - let plaintext = await window.crypto.subtle.decrypt( - { name: 'AES-GCM', iv: text.slice(0, 12) }, - sharedKey, - text.slice(12) - ) - return new TextDecoder().decode(new Uint8Array(plaintext)) + let text = hexToUint8Array(ciphertext); + if (!text) return ''; + let sharedKey = await window.crypto.subtle.importKey( + 'raw', + stdAESKey(key), + {name: 'AES-GCM', length: 256}, + true, + ['decrypt'] + ); + let plaintext = await window.crypto.subtle.decrypt( + {name: 'AES-GCM', iv: text.slice(0, 12)}, + sharedKey, + text.slice(12) + ); + return new TextDecoder().decode(new Uint8Array(plaintext)); } export default { - decrypt, - encrypt, -} + decrypt, + encrypt +}; diff --git a/html/src/service/gamelog.js b/html/src/service/gamelog.js index 7fe29fe2..598e435d 100644 --- a/html/src/service/gamelog.js +++ b/html/src/service/gamelog.js @@ -94,7 +94,4 @@ class GameLogService { var self = new GameLogService(); window.gameLogService = self; -export { - self as default, - GameLogService as LogWatcherService -}; +export {self as default, GameLogService as LogWatcherService}; diff --git a/html/src/service/sqlite.js b/html/src/service/sqlite.js index 14877fe2..d01ab5bb 100644 --- a/html/src/service/sqlite.js +++ b/html/src/service/sqlite.js @@ -3,15 +3,19 @@ class SQLiteService { execute(callback, sql, args = null) { return new Promise((resolve, reject) => { - SQLite.Execute((err, data) => { - if (err !== null) { - reject(err); - } else if (data === null) { - resolve(); - } else { - callback(data); - } - }, sql, args); + SQLite.Execute( + (err, data) => { + if (err !== null) { + reject(err); + } else if (data === null) { + resolve(); + } else { + callback(data); + } + }, + sql, + args + ); }); } @@ -23,7 +27,4 @@ class SQLiteService { var self = new SQLiteService(); window.sqliteService = self; -export { - self as default, - SQLiteService -}; +export {self as default, SQLiteService}; diff --git a/html/src/service/webapi.js b/html/src/service/webapi.js index 39767770..3af43383 100644 --- a/html/src/service/webapi.js +++ b/html/src/service/webapi.js @@ -21,7 +21,4 @@ class WebApiService { var self = new WebApiService(); window.webApiService = self; -export { - self as default, - WebApiService -}; +export {self as default, WebApiService}; diff --git a/html/src/vr.js b/html/src/vr.js index 01c9e8de..84684d3e 100644 --- a/html/src/vr.js +++ b/html/src/vr.js @@ -42,10 +42,12 @@ speechSynthesis.getVoices(); locale }); - var escapeTag = (s) => String(s).replace(/["&'<>]/gu, (c) => `&#${c.charCodeAt(0)};`); + var escapeTag = (s) => + String(s).replace(/["&'<>]/gu, (c) => `&#${c.charCodeAt(0)};`); Vue.filter('escapeTag', escapeTag); - var commaNumber = (n) => String(Number(n) || 0).replace(/(\d)(?=(\d{3})+(?!\d))/gu, '$1,'); + var commaNumber = (n) => + String(Number(n) || 0).replace(/(\d)(?=(\d{3})+(?!\d))/gu, '$1,'); Vue.filter('commaNumber', commaNumber); var formatDate = (s, format) => { @@ -55,24 +57,27 @@ speechSynthesis.getVoices(); } var hours = dt.getHours(); var map = { - 'YYYY': String(10000 + dt.getFullYear()).substr(-4), - 'MM': String(101 + dt.getMonth()).substr(-2), - 'DD': String(100 + dt.getDate()).substr(-2), - 'HH24': String(100 + hours).substr(-2), - 'HH': String(100 + (hours > 12 - ? hours - 12 - : hours)).substr(-2), - 'MI': String(100 + dt.getMinutes()).substr(-2), - 'SS': String(100 + dt.getSeconds()).substr(-2), - 'AMPM': hours >= 12 - ? 'PM' - : 'AM' + YYYY: String(10000 + dt.getFullYear()).substr(-4), + MM: String(101 + dt.getMonth()).substr(-2), + DD: String(100 + dt.getDate()).substr(-2), + HH24: String(100 + hours).substr(-2), + HH: String(100 + (hours > 12 ? hours - 12 : hours)).substr(-2), + MI: String(100 + dt.getMinutes()).substr(-2), + SS: String(100 + dt.getSeconds()).substr(-2), + AMPM: hours >= 12 ? 'PM' : 'AM' }; - return format.replace(/YYYY|MM|DD|HH24|HH|MI|SS|AMPM/gu, (c) => map[c] || c); + return format.replace( + /YYYY|MM|DD|HH24|HH|MI|SS|AMPM/gu, + (c) => map[c] || c + ); }; Vue.filter('formatDate', formatDate); - var textToHex = (s) => String(s).split('').map((c) => c.charCodeAt(0).toString(16)).join(' '); + var textToHex = (s) => + String(s) + .split('') + .map((c) => c.charCodeAt(0).toString(16)) + .join(' '); Vue.filter('textToHex', textToHex); var timeToText = (t) => { @@ -97,8 +102,7 @@ speechSynthesis.getVoices(); arr.push(`${Math.floor(sec / 60)}m`); sec %= 60; } - if (sec || - !arr.length) { + if (sec || !arr.length) { arr.push(`${sec}s`); } return arr.join(' '); @@ -142,7 +146,7 @@ speechSynthesis.getVoices(); if (typeof handlers === 'undefined') { return; } - var { length } = handlers; + var {length} = handlers; for (var i = 0; i < length; ++i) { if (handlers[i] === handler) { if (length > 1) { @@ -163,13 +167,13 @@ speechSynthesis.getVoices(); method: 'GET', ...options }; - var { params } = init; + var {params} = init; var isGetRequest = init.method === 'GET'; if (isGetRequest === true) { // transform body to url if (params === Object(params)) { var url = new URL(init.url); - var { searchParams } = url; + var {searchParams} = url; for (var key in params) { searchParams.set(key, params[key]); } @@ -185,54 +189,53 @@ speechSynthesis.getVoices(); 'Content-Type': 'application/json;charset=utf-8', ...init.headers }; - init.body = params === Object(params) - ? JSON.stringify(params) - : '{}'; + init.body = + params === Object(params) ? JSON.stringify(params) : '{}'; } init.headers = { 'User-Agent': appVersion, ...init.headers }; - var req = webApiService.execute(init).catch((err) => { - this.$throw(0, err); - }).then((response) => { - try { - response.data = JSON.parse(response.data); - return response; - } catch (e) { - } - if (response.status === 200) { - this.$throw(0, 'Invalid JSON response'); - } - this.$throw(response.status); - return {}; - }).then(({ data, status }) => { - if (data === Object(data)) { - if (status === 200) { - if (data.success === Object(data.success)) { - new Noty({ - type: 'success', - text: escapeTag(data.success.message) - }).show(); + var req = webApiService + .execute(init) + .catch((err) => { + this.$throw(0, err); + }) + .then((response) => { + try { + response.data = JSON.parse(response.data); + return response; + } catch (e) {} + if (response.status === 200) { + this.$throw(0, 'Invalid JSON response'); + } + this.$throw(response.status); + return {}; + }) + .then(({data, status}) => { + if (data === Object(data)) { + if (status === 200) { + if (data.success === Object(data.success)) { + new Noty({ + type: 'success', + text: escapeTag(data.success.message) + }).show(); + } + return data; + } + if (data.error === Object(data.error)) { + this.$throw( + data.error.status_code || status, + data.error.message, + data.error.data + ); + } else if (typeof data.error === 'string') { + this.$throw(data.status_code || status, data.error); } - return data; } - if (data.error === Object(data.error)) { - this.$throw( - data.error.status_code || status, - data.error.message, - data.error.data - ); - } else if (typeof data.error === 'string') { - this.$throw( - data.status_code || status, - data.error - ); - } - } - this.$throw(status, data); - return data; - }); + this.$throw(status, data); + return data; + }); if (isGetRequest === true) { req.finally(() => { this.pendingGetRequests.delete(init.url); @@ -373,9 +376,9 @@ speechSynthesis.getVoices(); // API: Location API.parseLocation = function (tag) { - tag = String(tag || ''); + var _tag = String(tag || ''); var ctx = { - tag, + tag: _tag, isOffline: false, isPrivate: false, worldId: '', @@ -389,27 +392,21 @@ speechSynthesis.getVoices(); friendsId: null, canRequestInvite: false }; - if (tag === 'offline') { + if (_tag === 'offline') { ctx.isOffline = true; - } else if (tag === 'private') { + } else if (_tag === 'private') { ctx.isPrivate = true; - } else if (tag.startsWith('local') === false) { - var sep = tag.indexOf(':'); + } else if (_tag.startsWith('local') === false) { + var sep = _tag.indexOf(':'); if (sep >= 0) { - ctx.worldId = tag.substr(0, sep); - ctx.instanceId = tag.substr(sep + 1); + ctx.worldId = _tag.substr(0, sep); + ctx.instanceId = _tag.substr(sep + 1); ctx.instanceId.split('~').forEach((s, i) => { if (i) { var A = s.indexOf('('); - var Z = A >= 0 - ? s.lastIndexOf(')') - : -1; - var key = Z >= 0 - ? s.substr(0, A) - : s; - var value = A < Z - ? s.substr(A + 1, Z - A - 1) - : ''; + var Z = A >= 0 ? s.lastIndexOf(')') : -1; + var key = Z >= 0 ? s.substr(0, A) : s; + var value = A < Z ? s.substr(A + 1, Z - A - 1) : ''; if (key === 'hidden') { ctx.hiddenId = value; } else if (key === 'private') { @@ -445,14 +442,15 @@ speechSynthesis.getVoices(); ctx.userId = ctx.hiddenId; } } else { - ctx.worldId = tag; + ctx.worldId = _tag; } } return ctx; }; Vue.component('location', { - template: '{{ text }}', + template: + '{{ text }}', props: { location: String, hint: { @@ -488,7 +486,12 @@ speechSynthesis.getVoices(); } } this.region = ''; - if ((this.location !== '') && (L.instanceId) && (!L.isOffline) && (!L.isPrivate)) { + if ( + this.location !== '' && + L.instanceId && + !L.isOffline && + !L.isPrivate + ) { if (L.region === 'eu') { this.region = 'europeanunion'; } else if (L.region === 'jp') { @@ -626,7 +629,7 @@ speechSynthesis.getVoices(); props[prop] = true; } } - var $ref = { ...ref }; + var $ref = {...ref}; Object.assign(ref, json); for (var prop in ref) { if (ref[prop] !== Object(ref[prop])) { @@ -639,10 +642,7 @@ speechSynthesis.getVoices(); if (asis === tobe) { delete props[prop]; } else { - props[prop] = [ - tobe, - asis - ]; + props[prop] = [tobe, asis]; } } } @@ -734,21 +734,25 @@ speechSynthesis.getVoices(); // OO has muted you // OO has hidden you // -- - API.getConfig().catch((err) => { - // FIXME: 어케 복구하냐 이건 - throw err; - }).then((args) => { - if (this.appType === '1') { - this.updateCpuUsageLoop(); - } - this.initLoop(); - return args; - }); + API.getConfig() + .catch((err) => { + // FIXME: 어케 복구하냐 이건 + throw err; + }) + .then((args) => { + if (this.appType === '1') { + this.updateCpuUsageLoop(); + } + this.initLoop(); + return args; + }); } }; $app.methods.updateVRConfigVars = function () { - this.currentUserStatus = sharedRepository.getString('current_user_status'); + this.currentUserStatus = sharedRepository.getString( + 'current_user_status' + ); this.isGameRunning = sharedRepository.getBool('is_game_running'); this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR'); this.downloadProgress = sharedRepository.getInt('downloadProgress'); @@ -756,7 +760,9 @@ speechSynthesis.getVoices(); if (lastLocation) { this.lastLocation = lastLocation; if (this.lastLocation.date !== 0) { - this.lastLocationTimer = timeToText(Date.now() - this.lastLocation.date); + this.lastLocationTimer = timeToText( + Date.now() - this.lastLocation.date + ); } else { this.lastLocationTimer = ''; } @@ -794,14 +800,16 @@ speechSynthesis.getVoices(); } else { console.error('missing displayName'); } - if ((displayName) && (!this.notyMap[displayName]) || - (this.notyMap[displayName] < feed.created_at)) { + if ( + (displayName && !this.notyMap[displayName]) || + this.notyMap[displayName] < feed.created_at + ) { this.notyMap[displayName] = feed.created_at; } }); }; - $app.methods.initLoop = async function () { + $app.methods.initLoop = function () { if (!sharedRepository.getBool('VRInit')) { setTimeout(this.initLoop, 500); } else { @@ -813,7 +821,7 @@ speechSynthesis.getVoices(); try { this.currentTime = new Date().toJSON(); await this.updateVRConfigVars(); - if ((!this.config.hideDevicesFromFeed) && (this.appType === '1')) { + if (!this.config.hideDevicesFromFeed && this.appType === '1') { AppApi.GetVRDevices().then((devices) => { devices.forEach((device) => { device[2] = parseInt(device[2], 10); @@ -865,8 +873,10 @@ speechSynthesis.getVoices(); } else { console.error('missing displayName'); } - if ((displayName) && (!this.notyMap[displayName]) || - (this.notyMap[displayName] < feed.created_at)) { + if ( + (displayName && !this.notyMap[displayName]) || + this.notyMap[displayName] < feed.created_at + ) { this.notyMap[displayName] = feed.created_at; notyToPlay.push(feed); } @@ -877,7 +887,11 @@ speechSynthesis.getVoices(); } var bias = new Date(Date.now() - 60000).toJSON(); var noty = {}; - var messageList = ['inviteMessage', 'requestMessage', 'responseMessage']; + var messageList = [ + 'inviteMessage', + 'requestMessage', + 'responseMessage' + ]; for (var i = 0; i < notyToPlay.length; i++) { noty = notyToPlay[i]; if (noty.created_at < bias) { @@ -885,14 +899,21 @@ speechSynthesis.getVoices(); } var message = ''; for (var k = 0; k < messageList.length; k++) { - if (typeof noty.details !== 'undefined' && typeof noty.details[messageList[k]] !== 'undefined') { + if ( + typeof noty.details !== 'undefined' && + typeof noty.details[messageList[k]] !== 'undefined' + ) { message = noty.details[messageList[k]]; } } if (message) { message = `, ${message}`; } - if ((this.config.overlayNotifications) && (!this.isGameNoVR) && (this.isGameRunning)) { + if ( + this.config.overlayNotifications && + !this.isGameNoVR && + this.isGameRunning + ) { var text = ''; switch (noty.type) { case 'OnPlayerJoined': @@ -905,7 +926,12 @@ speechSynthesis.getVoices(); text = `${noty.displayName} is joining`; break; case 'GPS': - text = `${noty.displayName} is in ${this.displayLocation(noty.location, noty.worldName)}`; + text = `${ + noty.displayName + } is in ${this.displayLocation( + noty.location, + noty.worldName + )}`; break; case 'Online': text = `${noty.displayName} has logged in`; @@ -917,7 +943,12 @@ speechSynthesis.getVoices(); text = `${noty.displayName} status is now ${noty.status} ${noty.statusDescription}`; break; case 'invite': - text = `${noty.senderUsername} has invited you to ${this.displayLocation(noty.details.worldId, noty.details.worldName)}${message}`; + text = `${ + noty.senderUsername + } has invited you to ${this.displayLocation( + noty.details.worldId, + noty.details.worldName + )}${message}`; break; case 'requestInvite': text = `${noty.senderUsername} has requested an invite ${message}`; @@ -1028,4 +1059,4 @@ speechSynthesis.getVoices(); $app = new Vue($app); window.$app = $app; -}()); +})(); diff --git a/html/src/vr.scss b/html/src/vr.scss index 106a9ef3..ad8fd3b2 100644 --- a/html/src/vr.scss +++ b/html/src/vr.scss @@ -8,11 +8,11 @@ // For a copy, see . // -@import "~normalize.css/normalize.css"; -@import "~animate.css/animate.min.css"; -@import "~noty/lib/noty.css"; -@import "~element-ui/lib/theme-chalk/index.css"; -@import "~famfamfam-flags/dist/sprite/famfamfam-flags.min.css"; +@import '~normalize.css/normalize.css'; +@import '~animate.css/animate.min.css'; +@import '~noty/lib/noty.css'; +@import '~element-ui/lib/theme-chalk/index.css'; +@import '~famfamfam-flags/dist/sprite/famfamfam-flags.min.css'; /* 마지노선인듯 @@ -163,9 +163,11 @@ input, textarea, select, button { - font-family: "Noto Sans JP", "Noto Sans KR", "Meiryo UI", "Malgun Gothic", "Segoe UI", sans-serif; + font-family: 'Noto Sans JP', 'Noto Sans KR', 'Meiryo UI', 'Malgun Gothic', + 'Segoe UI', sans-serif; line-height: normal; - text-shadow: #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px; + text-shadow: #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px, + #000 0px 0px 1px, #000 0px 0px 1px, #000 0px 0px 1px; } .x-app {