Fix up PRs

This commit is contained in:
Natsumi
2025-01-09 13:31:14 +13:00
parent 60f59b9baa
commit a39eb9d5ed
3 changed files with 219 additions and 156 deletions
+201 -135
View File
@@ -192,8 +192,8 @@ speechSynthesis.getVoices();
this.loginForm.savedCredentials = this.loginForm.savedCredentials =
(await configRepository.getString('savedCredentials')) !== null (await configRepository.getString('savedCredentials')) !== null
? JSON.parse( ? JSON.parse(
await configRepository.getString('savedCredentials') await configRepository.getString('savedCredentials')
) )
: {}; : {};
this.loginForm.lastUserLoggedIn = this.loginForm.lastUserLoggedIn =
await configRepository.getString('lastUserLoggedIn'); await configRepository.getString('lastUserLoggedIn');
@@ -202,11 +202,11 @@ speechSynthesis.getVoices();
if ( if (
!this.enablePrimaryPassword && !this.enablePrimaryPassword &&
(await configRepository.getString('lastUserLoggedIn')) !== (await configRepository.getString('lastUserLoggedIn')) !==
null null
) { ) {
var user = var user =
this.loginForm.savedCredentials[ this.loginForm.savedCredentials[
this.loginForm.lastUserLoggedIn this.loginForm.lastUserLoggedIn
]; ];
if (user?.loginParmas?.endpoint) { if (user?.loginParmas?.endpoint) {
API.endpointDomain = user.loginParmas.endpoint; API.endpointDomain = user.loginParmas.endpoint;
@@ -1892,7 +1892,10 @@ speechSynthesis.getVoices();
}; };
API.$on('AVATAR:IMPOSTER:DELETE', function (args) { API.$on('AVATAR:IMPOSTER:DELETE', function (args) {
if (args.json && $app.avatarDialog.visible) { if (
$app.avatarDialog.visible &&
args.params.avatarId === $app.avatarDialog.id
) {
$app.showAvatarDialog($app.avatarDialog.id); $app.showAvatarDialog($app.avatarDialog.id);
} }
}); });
@@ -2035,7 +2038,7 @@ speechSynthesis.getVoices();
if (object === Object(object)) { if (object === Object(object)) {
details = object; details = object;
} }
} catch (err) { } } catch (err) {}
} }
ref.details = details; ref.details = details;
} }
@@ -3844,7 +3847,7 @@ speechSynthesis.getVoices();
if (this.loginForm.lastUserLoggedIn) { if (this.loginForm.lastUserLoggedIn) {
var user = var user =
this.loginForm.savedCredentials[ this.loginForm.savedCredentials[
this.loginForm.lastUserLoggedIn this.loginForm.lastUserLoggedIn
]; ];
if (typeof user !== 'undefined') { if (typeof user !== 'undefined') {
await webApiService.clearCookies(); await webApiService.clearCookies();
@@ -4746,7 +4749,7 @@ speechSynthesis.getVoices();
}); });
worldName = args.ref.name; worldName = args.ref.name;
} }
} catch (err) { } } catch (err) {}
} }
return worldName; return worldName;
}; };
@@ -4769,7 +4772,7 @@ speechSynthesis.getVoices();
groupId groupId
}); });
groupName = args.ref.name; groupName = args.ref.name;
} catch (err) { } } catch (err) {}
return groupName; return groupName;
}; };
@@ -5677,7 +5680,7 @@ speechSynthesis.getVoices();
props.currentAvatarThumbnailImageUrl[0] && props.currentAvatarThumbnailImageUrl[0] &&
props.currentAvatarThumbnailImageUrl[1] && props.currentAvatarThumbnailImageUrl[1] &&
props.currentAvatarThumbnailImageUrl[0] === props.currentAvatarThumbnailImageUrl[0] ===
props.currentAvatarThumbnailImageUrl[1] props.currentAvatarThumbnailImageUrl[1]
) { ) {
imageMatches = true; imageMatches = true;
} }
@@ -5736,7 +5739,7 @@ speechSynthesis.getVoices();
avatarInfo = await $app.getAvatarName( avatarInfo = await $app.getAvatarName(
currentAvatarImageUrl currentAvatarImageUrl
); );
} catch (err) { } } catch (err) {}
var previousAvatarInfo = { var previousAvatarInfo = {
ownerId: '', ownerId: '',
avatarName: '' avatarName: ''
@@ -5745,7 +5748,7 @@ speechSynthesis.getVoices();
previousAvatarInfo = await $app.getAvatarName( previousAvatarInfo = await $app.getAvatarName(
previousCurrentAvatarImageUrl previousCurrentAvatarImageUrl
); );
} catch (err) { } } catch (err) {}
var feed = { var feed = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
type: 'Avatar', type: 'Avatar',
@@ -5859,7 +5862,10 @@ speechSynthesis.getVoices();
* @param {string} str2 * @param {string} str2
* @returns {number[][]} A matrix that contains the longest common subsequence between both strings * @returns {number[][]} A matrix that contains the longest common subsequence between both strings
*/ */
$app.methods.longestCommonSubsequence = function longestCommonSubsequence(str1, str2) { $app.methods.longestCommonSubsequence = function longestCommonSubsequence(
str1,
str2
) {
let lcs = []; let lcs = [];
for (let i = 0; i <= str1.length; i++) { for (let i = 0; i <= str1.length; i++) {
lcs.push(new Array(str2.length + 1).fill(0)); lcs.push(new Array(str2.length + 1).fill(0));
@@ -5874,7 +5880,7 @@ speechSynthesis.getVoices();
} }
} }
return lcs; return lcs;
} };
/** /**
* Merge differences in both strings to get the longest common subsequence * Merge differences in both strings to get the longest common subsequence
@@ -5883,8 +5889,8 @@ speechSynthesis.getVoices();
*/ */
$app.methods.regoupDifferences = function regoupDifferences(res) { $app.methods.regoupDifferences = function regoupDifferences(res) {
let regrouped = []; let regrouped = [];
let text = ""; let text = '';
let type = ""; let type = '';
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
if (i == 0) { if (i == 0) {
text = res[i].text; text = res[i].text;
@@ -5899,7 +5905,7 @@ speechSynthesis.getVoices();
} }
regrouped.push({ text: text, type: type }); regrouped.push({ text: text, type: type });
return regrouped; return regrouped;
} };
/** /**
* Function that format the differences between two strings with HTML tags * Function that format the differences between two strings with HTML tags
@@ -5916,112 +5922,138 @@ speechSynthesis.getVoices();
markerAddition = '<span class="x-text-added">{{text}}</span>', markerAddition = '<span class="x-text-added">{{text}}</span>',
markerDeletion = '<span class="x-text-removed">{{text}}</span>' markerDeletion = '<span class="x-text-removed">{{text}}</span>'
) { ) {
[oldString, newString] = [oldString, newString].map((s) => s [oldString, newString] = [oldString, newString].map((s) =>
.replaceAll(/&/g, '&amp;') s
.replaceAll(/</g, '&lt;') .replaceAll(/&/g, '&amp;')
.replaceAll(/>/g, '&gt;') .replaceAll(/</g, '&lt;')
.replaceAll(/"/g, '&quot;') .replaceAll(/>/g, '&gt;')
.replaceAll(/'/g, '&#039;') .replaceAll(/"/g, '&quot;')
.replaceAll(/\n/g, '<br>') .replaceAll(/'/g, '&#039;')
.replaceAll(/\n/g, '<br>')
); );
const oldWords = oldString.split(/\s+/).flatMap((word) => word.split(/(<br>)/)); const oldWords = oldString
const newWords = newString.split(/\s+/).flatMap((word) => word.split(/(<br>)/)); .split(/\s+/)
.flatMap((word) => word.split(/(<br>)/));
const newWords = newString
.split(/\s+/)
.flatMap((word) => word.split(/(<br>)/));
function findLongestMatch(oldStart, oldEnd, newStart, newEnd) { function findLongestMatch(oldStart, oldEnd, newStart, newEnd) {
let bestOldStart = oldStart; let bestOldStart = oldStart;
let bestNewStart = newStart; let bestNewStart = newStart;
let bestSize = 0; let bestSize = 0;
const lookup = new Map(); const lookup = new Map();
for (let i = oldStart; i < oldEnd; i++) { for (let i = oldStart; i < oldEnd; i++) {
const word = oldWords[i]; const word = oldWords[i];
if (!lookup.has(word)) lookup.set(word, []); if (!lookup.has(word)) lookup.set(word, []);
lookup.get(word).push(i); lookup.get(word).push(i);
}
for (let j = newStart; j < newEnd; j++) {
const word = newWords[j];
if (!lookup.has(word)) continue;
for (const i of lookup.get(word)) {
let size = 0;
while (
i + size < oldEnd &&
j + size < newEnd &&
oldWords[i + size] === newWords[j + size]
) {
size++;
}
if (size > bestSize) {
bestOldStart = i;
bestNewStart = j;
bestSize = size;
}
} }
}
return { oldStart: bestOldStart, newStart: bestNewStart, size: bestSize }; for (let j = newStart; j < newEnd; j++) {
const word = newWords[j];
if (!lookup.has(word)) continue;
for (const i of lookup.get(word)) {
let size = 0;
while (
i + size < oldEnd &&
j + size < newEnd &&
oldWords[i + size] === newWords[j + size]
) {
size++;
}
if (size > bestSize) {
bestOldStart = i;
bestNewStart = j;
bestSize = size;
}
}
}
return {
oldStart: bestOldStart,
newStart: bestNewStart,
size: bestSize
};
} }
function buildDiff(oldStart, oldEnd, newStart, newEnd) { function buildDiff(oldStart, oldEnd, newStart, newEnd) {
const result = []; const result = [];
const match = findLongestMatch(oldStart, oldEnd, newStart, newEnd); const match = findLongestMatch(oldStart, oldEnd, newStart, newEnd);
if (match.size > 0) { if (match.size > 0) {
// Handle differences before the match // Handle differences before the match
if (oldStart < match.oldStart || newStart < match.newStart) { if (oldStart < match.oldStart || newStart < match.newStart) {
result.push( result.push(
...buildDiff(oldStart, match.oldStart, newStart, match.newStart) ...buildDiff(
); oldStart,
} match.oldStart,
newStart,
// Add the matched words match.newStart
result.push(oldWords.slice(match.oldStart, match.oldStart + match.size).join(" ")); )
);
// Handle differences after the match
if (match.oldStart + match.size < oldEnd || match.newStart + match.size < newEnd) {
result.push(
...buildDiff(
match.oldStart + match.size,
oldEnd,
match.newStart + match.size,
newEnd
)
);
}
} else {
function build(words, start, end, pattern) {
let r = [];
let ts = words.slice(start, end)
.filter((w) => w.length > 0)
.join(" ")
.split("<br>");
for (let i = 0; i < ts.length; i++) {
if (i > 0) r.push("<br>");
if (ts[i].length < 1) continue;
r.push(pattern.replace("{{text}}", ts[i]));
} }
return r;
// Add the matched words
result.push(
oldWords
.slice(match.oldStart, match.oldStart + match.size)
.join(' ')
);
// Handle differences after the match
if (
match.oldStart + match.size < oldEnd ||
match.newStart + match.size < newEnd
) {
result.push(
...buildDiff(
match.oldStart + match.size,
oldEnd,
match.newStart + match.size,
newEnd
)
);
}
} else {
function build(words, start, end, pattern) {
let r = [];
let ts = words
.slice(start, end)
.filter((w) => w.length > 0)
.join(' ')
.split('<br>');
for (let i = 0; i < ts.length; i++) {
if (i > 0) r.push('<br>');
if (ts[i].length < 1) continue;
r.push(pattern.replace('{{text}}', ts[i]));
}
return r;
}
// Add deletions
if (oldStart < oldEnd)
result.push(
...build(oldWords, oldStart, oldEnd, markerDeletion)
);
// Add insertions
if (newStart < newEnd)
result.push(
...build(newWords, newStart, newEnd, markerAddition)
);
} }
// Add deletions return result;
if (oldStart < oldEnd)
result.push(...build(oldWords, oldStart, oldEnd, markerDeletion));
// Add insertions
if (newStart < newEnd)
result.push(...build(newWords, newStart, newEnd, markerAddition));
}
return result;
} }
return buildDiff(0, oldWords.length, 0, newWords.length) return buildDiff(0, oldWords.length, 0, newWords.length)
.join(" ") .join(' ')
.replace(/<br>[ ]+<br>/g, "<br><br>") .replace(/<br>[ ]+<br>/g, '<br><br>')
.replace(/<br> /g, "<br>"); .replace(/<br> /g, '<br>');
} };
// #endregion // #endregion
// #region | App: gameLog // #region | App: gameLog
@@ -6271,8 +6303,8 @@ speechSynthesis.getVoices();
$app.methods.formatSeconds = function (duration) { $app.methods.formatSeconds = function (duration) {
var pad = function (num, size) { var pad = function (num, size) {
return `000${num}`.slice(size * -1); return `000${num}`.slice(size * -1);
}, },
time = parseFloat(duration).toFixed(3), time = parseFloat(duration).toFixed(3),
hours = Math.floor(time / 60 / 60), hours = Math.floor(time / 60 / 60),
minutes = Math.floor(time / 60) % 60, minutes = Math.floor(time / 60) % 60,
@@ -8441,7 +8473,7 @@ speechSynthesis.getVoices();
speechSynthesis.cancel(); speechSynthesis.cancel();
if ( if (
(await configRepository.getString('VRCX_notificationTTS')) === (await configRepository.getString('VRCX_notificationTTS')) ===
'Never' && 'Never' &&
this.notificationTTS !== 'Never' this.notificationTTS !== 'Never'
) { ) {
this.speak('Notification text-to-speech enabled'); this.speak('Notification text-to-speech enabled');
@@ -8599,6 +8631,10 @@ speechSynthesis.getVoices();
case 'VRCX_saveInstancePrints': case 'VRCX_saveInstancePrints':
this.saveInstancePrints = !this.saveInstancePrints; this.saveInstancePrints = !this.saveInstancePrints;
break; break;
case 'VRCX_cropInstancePrints':
this.cropInstancePrints = !this.cropInstancePrints;
this.cropPrintsChanged();
break;
case 'VRCX_saveInstanceStickers': case 'VRCX_saveInstanceStickers':
this.saveInstanceStickers = !this.saveInstanceStickers; this.saveInstanceStickers = !this.saveInstanceStickers;
break; break;
@@ -8636,6 +8672,7 @@ speechSynthesis.getVoices();
'VRCX_cropInstancePrints', 'VRCX_cropInstancePrints',
this.cropInstancePrints this.cropInstancePrints
); );
await configRepository.setBool( await configRepository.setBool(
'VRCX_saveInstanceStickers', 'VRCX_saveInstanceStickers',
this.saveInstanceStickers this.saveInstanceStickers
@@ -10716,8 +10753,9 @@ speechSynthesis.getVoices();
if (type === 'search') { if (type === 'search') {
try { try {
var response = await webApiService.execute({ var response = await webApiService.execute({
url: `${this.avatarRemoteDatabaseProvider url: `${
}?${type}=${encodeURIComponent(search)}&n=5000`, this.avatarRemoteDatabaseProvider
}?${type}=${encodeURIComponent(search)}&n=5000`,
method: 'GET', method: 'GET',
headers: { headers: {
Referer: 'https://vrcx.app' Referer: 'https://vrcx.app'
@@ -12343,17 +12381,22 @@ speechSynthesis.getVoices();
case 'Regenerate Imposter': case 'Regenerate Imposter':
API.deleteImposter({ API.deleteImposter({
avatarId: D.id avatarId: D.id
}).then((args) => {return args;}); })
API.createImposter({ .then((args) => {
avatarId: D.id return args;
}).then((args) => { })
this.$message({ .finally(() => {
message: 'Imposter deleted and queued for creation', API.createImposter({
type: 'success' avatarId: D.id
}).then((args) => {
this.$message({
message:
'Imposter deleted and queued for creation',
type: 'success'
});
return args;
});
}); });
this.showAvatarDialog(D.id);
return args;
});
break; break;
} }
} }
@@ -17570,7 +17613,7 @@ speechSynthesis.getVoices();
try { try {
var args = await API.getFavoriteWorlds(params); var args = await API.getFavoriteWorlds(params);
worldLists.push([list.displayName, list.visibility, args.json]); worldLists.push([list.displayName, list.visibility, args.json]);
} catch (err) { } } catch (err) {}
} }
this.userFavoriteWorlds = worldLists; this.userFavoriteWorlds = worldLists;
this.userDialog.isFavoriteWorldsLoading = false; this.userDialog.isFavoriteWorldsLoading = false;
@@ -17742,7 +17785,7 @@ speechSynthesis.getVoices();
$app.methods.sortCurrentUserGroups = async function () { $app.methods.sortCurrentUserGroups = async function () {
var D = this.userDialog; var D = this.userDialog;
var sortMethod = function () { }; var sortMethod = function () {};
switch (D.groupSorting.value) { switch (D.groupSorting.value) {
case 'alphabetical': case 'alphabetical':
@@ -18152,24 +18195,47 @@ speechSynthesis.getVoices();
// #endregion // #endregion
// #region | Prints // #region | Prints
$app.methods.cropPrintsChanged = function () { $app.methods.cropPrintsChanged = function () {
if (!this.cropInstancePrints) if (!this.cropInstancePrints) return;
return;
this.$confirm( this.$confirm(
$t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old'), $t(
'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old'
),
{ {
confirmButtonText: $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_confirm'), confirmButtonText: $t(
cancelButtonText: $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'), 'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_confirm'
),
cancelButtonText: $t(
'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'
),
type: 'info', type: 'info',
showInput: false, showInput: false,
callback: (action) => { callback: async (action) => {
if (action === 'confirm') { if (action === 'confirm') {
AppApi.CropAllPrints(this.ugcFolderPath); var msgBox = this.$message({
message: 'Batch print cropping in progress...',
type: 'warning',
duration: 0
});
try {
await AppApi.CropAllPrints(this.ugcFolderPath);
this.$message({
message: 'Batch print cropping complete',
type: 'success'
});
} catch (err) {
console.error(err);
this.$message({
message: `Batch print cropping failed: ${err}`,
type: 'error'
});
} finally {
msgBox.close();
}
} }
} }
}); }
);
this.saveVRCXWindowOption(); };
}
API.$on('LOGIN', function () { API.$on('LOGIN', function () {
$app.printTable = []; $app.printTable = [];
@@ -18406,7 +18472,7 @@ speechSynthesis.getVoices();
} }
}, 2_500); }, 2_500);
} }
} };
$app.methods.trySavePrintToFile = async function (printId) { $app.methods.trySavePrintToFile = async function (printId) {
var args = await API.getPrint({ printId }); var args = await API.getPrint({ printId });
+2 -2
View File
@@ -508,8 +508,8 @@
"header": "Save Instance Prints To File", "header": "Save Instance Prints To File",
"header_tooltip": "Requires \"--enable-sdk-log-levels\" VRC launch option", "header_tooltip": "Requires \"--enable-sdk-log-levels\" VRC launch option",
"description": "Save spawned prints to your VRChat Pictures folder", "description": "Save spawned prints to your VRChat Pictures folder",
"crop": "Automatically crop saved prints to remove the white border", "crop": "Automatically remove white border from prints",
"crop_convert_old": "Do you want to crop all prints that have already been saved?", "crop_convert_old": "Would you like to crop all prints that have already been saved?",
"crop_convert_old_confirm": "Yes", "crop_convert_old_confirm": "Yes",
"crop_convert_old_cancel": "No" "crop_convert_old_cancel": "No"
}, },
+1 -4
View File
@@ -465,11 +465,8 @@ mixin settingsTab()
el-tooltip(placement="top" style="margin-left:5px" :content="$t('view.settings.advanced.advanced.save_instance_prints_to_file.header_tooltip')") el-tooltip(placement="top" style="margin-left:5px" :content="$t('view.settings.advanced.advanced.save_instance_prints_to_file.header_tooltip')")
i.el-icon-info i.el-icon-info
simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_prints_to_file.description")' :value='saveInstancePrints' @change='saveVRCXWindowOption("VRCX_saveInstancePrints")' :long-label='true') simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_prints_to_file.description")' :value='saveInstancePrints' @change='saveVRCXWindowOption("VRCX_saveInstancePrints")' :long-label='true')
simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_prints_to_file.crop")' :value='cropInstancePrints' @change='saveVRCXWindowOption("VRCX_cropInstancePrints")' :long-label='true')
br br
span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop') }}
el-switch(v-model="cropInstancePrints" @change="cropPrintsChanged")
br
span.sub-header {{ $t('view.settings.advanced.advanced.save_instance_stickers_to_file.header') }} span.sub-header {{ $t('view.settings.advanced.advanced.save_instance_stickers_to_file.header') }}
simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_stickers_to_file.description")' :value='saveInstanceStickers' @change='saveVRCXWindowOption("VRCX_saveInstanceStickers")' :long-label='true') simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_stickers_to_file.description")' :value='saveInstanceStickers' @change='saveVRCXWindowOption("VRCX_saveInstanceStickers")' :long-label='true')
//- Advanced | Remote Avatar Database //- Advanced | Remote Avatar Database