mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-18 06:13:52 +02:00
Remove userdialog playtime & fix screenshot search worldName
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Drawing.Processing;
|
||||
@@ -16,6 +18,12 @@ namespace VRCX
|
||||
{
|
||||
public partial class AppApi
|
||||
{
|
||||
public void PopulateImageHosts(string json)
|
||||
{
|
||||
var hosts = JsonSerializer.Deserialize<List<string>>(json);
|
||||
ImageCache.PopulateImageHosts(hosts);
|
||||
}
|
||||
|
||||
public async Task<string> GetImage(string url, string fileId, string version)
|
||||
{
|
||||
return await ImageCache.GetImage(url, fileId, version);
|
||||
|
||||
@@ -12,7 +12,7 @@ internal static class ImageCache
|
||||
{
|
||||
private static readonly string cacheLocation;
|
||||
private static readonly HttpClient httpClient;
|
||||
private static readonly List<string> _imageHosts =
|
||||
private static readonly List<string> ImageHosts =
|
||||
[
|
||||
"api.vrchat.cloud",
|
||||
"files.vrchat.cloud",
|
||||
@@ -30,6 +30,22 @@ internal static class ImageCache
|
||||
httpClient = new HttpClient(httpClientHandler);
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", Program.Version);
|
||||
}
|
||||
|
||||
public static void PopulateImageHosts(List<string> hosts)
|
||||
{
|
||||
foreach (var host in hosts)
|
||||
{
|
||||
if (string.IsNullOrEmpty(host))
|
||||
continue;
|
||||
|
||||
var uri = new Uri(host);
|
||||
if (string.IsNullOrEmpty(uri.Host))
|
||||
continue;
|
||||
|
||||
if (!ImageHosts.Contains(uri.Host))
|
||||
ImageHosts.Add(uri.Host);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<string> GetImage(string url, string fileId, string version)
|
||||
{
|
||||
@@ -47,7 +63,7 @@ internal static class ImageCache
|
||||
Directory.CreateDirectory(directoryLocation);
|
||||
|
||||
var uri = new Uri(url);
|
||||
if (!_imageHosts.Contains(uri.Host))
|
||||
if (!ImageHosts.Contains(uri.Host))
|
||||
throw new ArgumentException("Invalid image host", url);
|
||||
|
||||
var cookieString = string.Empty;
|
||||
@@ -91,7 +107,7 @@ internal static class ImageCache
|
||||
public static async Task<bool> SaveImageToFile(string url, string path)
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
if (!_imageHosts.Contains(uri.Host))
|
||||
if (!ImageHosts.Contains(uri.Host))
|
||||
throw new ArgumentException("Invalid image host", url);
|
||||
|
||||
var cookieString = string.Empty;
|
||||
|
||||
@@ -101,7 +101,10 @@ namespace VRCX
|
||||
|
||||
break;
|
||||
case ScreenshotSearchType.WorldName:
|
||||
if (metadata.World.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) != -1)
|
||||
if (metadata.World.Name == null)
|
||||
continue;
|
||||
|
||||
if (metadata.World.Name.Contains(query, StringComparison.OrdinalIgnoreCase))
|
||||
result.Add(metadata);
|
||||
|
||||
break;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace VRCX
|
||||
/// <summary>
|
||||
/// The display name of the user.
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
}
|
||||
|
||||
public class WorldDetail
|
||||
@@ -120,7 +120,7 @@ namespace VRCX
|
||||
/// <summary>
|
||||
/// The name of the world.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full ID of the game instance.
|
||||
|
||||
@@ -22,6 +22,15 @@ export default class extends baseClass {
|
||||
args.ref = this.applyConfig(args.json);
|
||||
});
|
||||
|
||||
API.$on('CONFIG', function (args) {
|
||||
if (typeof args.ref?.whiteListedAssetUrls !== 'object') {
|
||||
console.error('Invalid config whiteListedAssetUrls');
|
||||
}
|
||||
AppApi.PopulateImageHosts(
|
||||
JSON.stringify(args.ref.whiteListedAssetUrls)
|
||||
);
|
||||
});
|
||||
|
||||
API.applyConfig = function (json) {
|
||||
var ref = {
|
||||
...json
|
||||
|
||||
@@ -532,21 +532,21 @@ mixin userDialog
|
||||
span.extra(v-if='userDialog.timeSpent === 0') -
|
||||
span.extra(v-else) {{ timeToText(userDialog.timeSpent) }}
|
||||
template(v-else)
|
||||
el-tooltip(
|
||||
:disabled='hideTooltips || API.currentUser.id !== userDialog.id'
|
||||
placement='top'
|
||||
:content='$t("dialog.user.info.open_previouse_instance")')
|
||||
.x-friend-item(@click='showPreviousInstancesUserDialog(userDialog.ref)')
|
||||
.detail
|
||||
span.name {{ $t('dialog.user.info.play_time') }}
|
||||
el-tooltip(
|
||||
v-if='!hideTooltips'
|
||||
placement='top'
|
||||
style='margin-left: 5px'
|
||||
:content='$t("dialog.user.info.accuracy_notice")')
|
||||
i.el-icon-warning
|
||||
span.extra(v-if='userDialog.timeSpent === 0') -
|
||||
span.extra(v-else) {{ timeToText(userDialog.timeSpent) }}
|
||||
el-tooltip(
|
||||
:disabled='hideTooltips || API.currentUser.id !== userDialog.id'
|
||||
placement='top'
|
||||
:content='$t("dialog.user.info.open_previouse_instance")')
|
||||
.x-friend-item(@click='showPreviousInstancesUserDialog(userDialog.ref)')
|
||||
.detail
|
||||
span.name {{ $t('dialog.user.info.play_time') }}
|
||||
el-tooltip(
|
||||
v-if='!hideTooltips'
|
||||
placement='top'
|
||||
style='margin-left: 5px'
|
||||
:content='$t("dialog.user.info.accuracy_notice")')
|
||||
i.el-icon-warning
|
||||
span.extra(v-if='userDialog.timeSpent === 0') -
|
||||
span.extra(v-else) {{ timeToText(userDialog.timeSpent) }}
|
||||
.x-friend-item(style='cursor: default')
|
||||
el-tooltip(:placement='API.currentUser.id !== userDialog.id ? "bottom" : "top"')
|
||||
template(#content)
|
||||
|
||||
Reference in New Issue
Block a user