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