Misc fixes

This commit is contained in:
Natsumi
2025-01-20 21:56:33 +13:00
parent 95d5486cdb
commit 555d4adf60
8 changed files with 60 additions and 49 deletions
+5 -8
View File
@@ -116,14 +116,11 @@ public partial class AppApi
var path = GetVRChatPhotosLocation();
if (!Directory.Exists(path))
return null;
var lastDirectory = Directory.GetDirectories(path).OrderByDescending(Directory.GetCreationTime).FirstOrDefault();
if (lastDirectory == null)
return null;
var lastScreenshot = Directory.GetFiles(lastDirectory, "*.png").OrderByDescending(File.GetCreationTime).FirstOrDefault();
if (lastScreenshot == null)
return null;
// exclude folder names that contain "Prints" or "Stickers"
var imageFiles = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories)
.Where(x => !Regex.IsMatch(x, @"\\Prints\\|\\Stickers\\", RegexOptions.IgnoreCase));
var lastScreenshot = imageFiles.OrderByDescending(Directory.GetCreationTime).FirstOrDefault();
return lastScreenshot;
}
+6 -10
View File
@@ -76,16 +76,17 @@ namespace VRCX
if (metadata == null || metadata.Error != null)
{
addToCache.Add(dbEntry);
metadataCache.Add(file, null);
metadataCache.TryAdd(file, null);
continue;
}
dbEntry.Metadata = JsonConvert.SerializeObject(metadata);
addToCache.Add(dbEntry);
metadataCache.Add(file, metadata);
metadataCache.TryAdd(file, metadata);
}
if (metadata == null) continue;
if (metadata == null)
continue;
switch (searchType)
{
@@ -121,18 +122,13 @@ namespace VRCX
return result;
}
/// <summary>
/// Retrieves metadata from a PNG screenshot file and attempts to parse it.
/// </summary>
/// <param name="path">The path to the PNG screenshot file.</param>
/// <returns>A JObject containing the metadata or null if no metadata was found.</returns>
public static ScreenshotMetadata GetScreenshotMetadata(string path, bool includeJSON = false)
public static ScreenshotMetadata? GetScreenshotMetadata(string path, bool includeJSON = false)
{
// Early return if file doesn't exist, or isn't a PNG(Check both extension and file header)
if (!File.Exists(path) || !path.EndsWith(".png") || !IsPNGFile(path))
return null;
///if (metadataCache.TryGetValue(path, out var cachedMetadata))
// if (metadataCache.TryGetValue(path, out var cachedMetadata))
// return cachedMetadata;
string metadataString;
@@ -57,7 +57,7 @@ namespace VRCX
/// Any error that occurred while parsing the file. This being true implies nothing else is set.
/// </summary>
[JsonIgnore]
internal string Error;
internal string? Error;
[JsonIgnore]
internal string JSON;
+13 -24
View File
@@ -17,11 +17,12 @@ if (!isDotNetInstalled()) {
app.quit();
return;
}
console.log('DOTNET_ROOT:', process.env.DOTNET_ROOT);
// get launch arguments
const args = process.argv.slice(1);
const noInstall = args.some((val) => val === '--no-install');
const homePath = getHomePath();
tryCopyFromWinePrefix();
const rootDir = app.getAppPath();
@@ -261,7 +262,7 @@ async function installVRCXappImageLauncher() {
let targetIconName;
const desktopFiles = fs.readdirSync(
path.join(app.getPath('home'), '.local/share/applications')
path.join(homePath, '.local/share/applications')
);
for (const file of desktopFiles) {
if (file.includes('appimagekit_') && file.includes('VRCX')) {
@@ -284,8 +285,7 @@ async function installVRCXappImageLauncher() {
*/
async function installVRCX() {
let homePath = getHomePath();
console.log('True Home path:', homePath);
console.log('Home path:', homePath);
console.log('AppImage path:', appImagePath);
if (!appImagePath) {
console.error('AppImage path is not available!');
@@ -302,10 +302,8 @@ async function installVRCX() {
appImageLauncherInstalled = true;
}
*/
if (
appImagePath.startsWith(path.join(homePath, 'Applications'))
) {
if (appImagePath.startsWith(path.join(homePath, 'Applications'))) {
/*
if (appImageLauncherInstalled) {
installVRCXappImageLauncher();
@@ -332,9 +330,7 @@ async function installVRCX() {
}
if (
process.env.APPIMAGE.startsWith(
path.join(homePath, 'Applications')
) &&
process.env.APPIMAGE.startsWith(path.join(homePath, 'Applications')) &&
path.basename(process.env.APPIMAGE) === 'VRCX.AppImage'
) {
interopApi.getDotNetObject('Update').Init(appImagePath);
@@ -369,10 +365,7 @@ async function installVRCX() {
// Download the icon and save it to the target directory
const iconUrl =
'https://raw.githubusercontent.com/vrcx-team/VRCX/master/VRCX.png';
const iconPath = path.join(
homePath,
'.local/share/icons/VRCX.png'
);
const iconPath = path.join(homePath, '.local/share/icons/VRCX.png');
await downloadIcon(iconUrl, iconPath)
.then(() => {
console.log('Icon downloaded and saved to:', iconPath);
@@ -448,17 +441,13 @@ function getVRCXPath() {
}
function getHomePath() {
let relativeHomePath = path.join(app.getPath('home'));
// console.log('Relative Home Path: ' + relativeHomePath);
const relativeHomePath = path.join(app.getPath('home'));
try {
let absoluteHomePath = fs.realpathSync(relativeHomePath);
// console.log('readlink output: ' + absoluteHomePath);
return absoluteHomePath;
}
catch (err) {
const absoluteHomePath = fs.realpathSync(relativeHomePath);
return absoluteHomePath;
} catch (err) {
return relativeHomePath;
}
}
function getVersion() {
@@ -488,7 +477,7 @@ function tryCopyFromWinePrefix() {
// try copy from old wine path
const userName = process.env.USER || process.env.USERNAME;
const oldPath = path.join(
app.getPath('home'),
homePath,
'.local/share/vrcx/drive_c/users',
userName,
'AppData/Roaming/VRCX'
+13 -4
View File
@@ -8126,7 +8126,7 @@ console.log(`isLinux: ${LINUX}`);
'[ "https://avtr.just-h.party/vrcx_search.php" ]'
)
);
$app.data.pendingOfflineDelay = 130000;
$app.data.pendingOfflineDelay = 180000;
if (await configRepository.getString('VRCX_avatarRemoteDatabaseProvider')) {
// move existing provider to new list
var avatarRemoteDatabaseProvider = await configRepository.getString(
@@ -16769,9 +16769,12 @@ console.log(`isLinux: ${LINUX}`);
$app.methods.getAndDisplayLastScreenshot = function () {
this.screenshotMetadataResetSearch();
AppApi.GetLastScreenshot().then((path) =>
this.getAndDisplayScreenshot(path)
);
AppApi.GetLastScreenshot().then((path) => {
if (!path) {
return;
}
this.getAndDisplayScreenshot(path);
});
};
/**
@@ -17054,6 +17057,9 @@ console.log(`isLinux: ${LINUX}`);
};
$app.methods.copyImageToClipboard = function (path) {
if (!path) {
return;
}
AppApi.CopyImageToClipboard(path).then(() => {
this.$message({
message: 'Image copied to clipboard',
@@ -17063,6 +17069,9 @@ console.log(`isLinux: ${LINUX}`);
};
$app.methods.openImageFolder = function (path) {
if (!path) {
return;
}
AppApi.OpenFolderAndSelectItem(path).then(() => {
this.$message({
message: 'Opened image folder',
+18
View File
@@ -15,6 +15,7 @@ export default class extends baseClass {
async init() {
API.isLoggedIn = false;
API.attemptingAutoLogin = false;
API.autoLoginAttempts = new Set();
/**
* @param {{ username: string, password: string }} params credential to login
@@ -126,9 +127,25 @@ export default class extends baseClass {
return;
}
if ($app.enablePrimaryPassword) {
console.error(
'Primary password is enabled, this disables auto login.'
);
this.attemptingAutoLogin = false;
this.logout();
return;
}
var attemptsInLastHour = Array.from(this.autoLoginAttempts).filter(
(timestamp) => timestamp > new Date().getTime() - 3600000
).length;
if (attemptsInLastHour >= 3) {
console.error(
'More than 3 auto login attempts within the past hour, logging out instead of attempting auto login.'
);
this.attemptingAutoLogin = false;
this.logout();
return;
}
this.autoLoginAttempts.add(new Date().getTime());
$app.relogin(user)
.then(() => {
if (this.errorNoty) {
@@ -167,6 +184,7 @@ export default class extends baseClass {
API.$on('LOGOUT', function () {
this.attemptingAutoLogin = false;
this.autoLoginAttempts.clear();
});
API.logout = function () {
+2 -1
View File
@@ -165,7 +165,8 @@
"unmute": "Unmute",
"interactOn": "Interact On",
"interactOff": "Interact Off",
"muteChat": "Mute chat"
"muteChat": "Mute chat",
"unmuteChat": "Unmute chat"
}
},
"notification": {
+2 -1
View File
@@ -171,7 +171,8 @@
'unmute',
'interactOn',
'interactOff',
'muteChat'
'muteChat',
'unmuteChat'
],
tableProps: {
stripe: true,