async VRCXStorage

This commit is contained in:
Natsumi
2023-01-08 00:39:40 +13:00
parent e7e2960fab
commit 3fca54408c
6 changed files with 47 additions and 26 deletions
+4
View File
@@ -3,4 +3,8 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup> </startup>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration> </configuration>
+3 -4
View File
@@ -20,7 +20,6 @@ namespace VRCX
{ {
CachePath = Path.Combine(Program.AppDataDirectory, "cache"), CachePath = Path.Combine(Program.AppDataDirectory, "cache"),
UserDataPath = Path.Combine(Program.AppDataDirectory, "userdata"), UserDataPath = Path.Combine(Program.AppDataDirectory, "userdata"),
IgnoreCertificateErrors = true,
LogSeverity = LogSeverity.Disable, LogSeverity = LogSeverity.Disable,
WindowlessRenderingEnabled = true, WindowlessRenderingEnabled = true,
PersistSessionCookies = true, PersistSessionCookies = true,
@@ -34,16 +33,16 @@ namespace VRCX
SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html") SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html")
});*/ });*/
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
// cefSettings.CefCommandLineArgs.Add("ignore-certificate-errors"); // cefSettings.CefCommandLineArgs.Add("ignore-certificate-errors");
cefSettings.CefCommandLineArgs.Add("disable-plugins"); // cefSettings.CefCommandLineArgs.Add("disable-plugins");
cefSettings.CefCommandLineArgs.Add("disable-spell-checking"); cefSettings.CefCommandLineArgs.Add("disable-spell-checking");
cefSettings.CefCommandLineArgs.Add("disable-pdf-extension"); cefSettings.CefCommandLineArgs.Add("disable-pdf-extension");
cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required"; cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
cefSettings.CefCommandLineArgs.Add("disable-web-security"); cefSettings.CefCommandLineArgs.Add("disable-web-security");
cefSettings.SetOffScreenRenderingBestPerformanceArgs(); cefSettings.SetOffScreenRenderingBestPerformanceArgs();
CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO // CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO (needed for synchronous configRepository)
CefSharpSettings.ShutdownOnExit = false; CefSharpSettings.ShutdownOnExit = false;
// Enable High-DPI support on Windows 7 or newer // Enable High-DPI support on Windows 7 or newer
+1 -1
View File
@@ -10,7 +10,7 @@ namespace VRCX
repository.Register("AppApi", AppApi.Instance, true); repository.Register("AppApi", AppApi.Instance, true);
repository.Register("SharedVariable", SharedVariable.Instance, false); repository.Register("SharedVariable", SharedVariable.Instance, false);
repository.Register("WebApi", WebApi.Instance, true); repository.Register("WebApi", WebApi.Instance, true);
repository.Register("VRCXStorage", VRCXStorage.Instance, false); repository.Register("VRCXStorage", VRCXStorage.Instance, true);
repository.Register("SQLite", SQLite.Instance, true); repository.Register("SQLite", SQLite.Instance, true);
repository.Register("LogWatcher", LogWatcher.Instance, true); repository.Register("LogWatcher", LogWatcher.Instance, true);
repository.Register("Discord", Discord.Instance, true); repository.Register("Discord", Discord.Instance, true);
+1 -7
View File
@@ -8,6 +8,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="CefSharp.MinimalExample.Offscreen.app" /> <assemblyIdentity version="1.0.0.0" name="CefSharp.MinimalExample.Offscreen.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security> <security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
@@ -28,13 +29,6 @@
</security> </security>
</trustInfo> </trustInfo>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application> <application>
<!-- A list of all Windows versions that this application is designed to work with. <!-- A list of all Windows versions that this application is designed to work with.
+17 -11
View File
@@ -63,7 +63,10 @@ speechSynthesis.getVoices();
'launchAsDesktop' 'launchAsDesktop'
]; ];
for (var _key of legacyConfigKeys) { for (var _key of legacyConfigKeys) {
configRepository.setBool(_key, VRCXStorage.Get(_key) === 'true'); configRepository.setBool(
_key,
(await VRCXStorage.Get(_key)) === 'true'
);
} }
configRepository.setBool('migrate_config_20201101', true); configRepository.setBool('migrate_config_20201101', true);
} }
@@ -80,9 +83,9 @@ speechSynthesis.getVoices();
} }
}); });
VRCXStorage.GetArray = function (key) { VRCXStorage.GetArray = async function (key) {
try { try {
var array = JSON.parse(this.Get(key)); var array = JSON.parse(await this.Get(key));
if (Array.isArray(array)) { if (Array.isArray(array)) {
return array; return array;
} }
@@ -96,9 +99,9 @@ speechSynthesis.getVoices();
this.Set(key, JSON.stringify(value)); this.Set(key, JSON.stringify(value));
}; };
VRCXStorage.GetObject = function (key) { VRCXStorage.GetObject = async function (key) {
try { try {
var object = JSON.parse(this.Get(key)); var object = JSON.parse(await this.Get(key));
if (object === Object(object)) { if (object === Object(object)) {
return object; return object;
} }
@@ -7058,7 +7061,7 @@ speechSynthesis.getVoices();
}; };
$app.methods.migrateMemos = async function () { $app.methods.migrateMemos = async function () {
var json = JSON.parse(VRCXStorage.GetAll()); var json = JSON.parse(await VRCXStorage.GetAll());
database.begin(); database.begin();
for (var line in json) { for (var line in json) {
if (line.substring(0, 8) === 'memo_usr') { if (line.substring(0, 8) === 'memo_usr') {
@@ -8368,7 +8371,7 @@ speechSynthesis.getVoices();
} }
$app.vrInit(); $app.vrInit();
// 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`)) { if (await VRCXStorage.Get(`${args.json.id}_friendLogUpdatedAt`)) {
VRCXStorage.Remove(`${args.json.id}_feedTable`); VRCXStorage.Remove(`${args.json.id}_feedTable`);
$app.migrateMemos(); $app.migrateMemos();
$app.migrateFriendLog(args.json.id); $app.migrateFriendLog(args.json.id);
@@ -12089,10 +12092,10 @@ speechSynthesis.getVoices();
this.friendLogInitStatus = true; this.friendLogInitStatus = true;
}; };
$app.methods.migrateFriendLog = function (userId) { $app.methods.migrateFriendLog = async function (userId) {
VRCXStorage.Remove(`${userId}_friendLogUpdatedAt`); VRCXStorage.Remove(`${userId}_friendLogUpdatedAt`);
VRCXStorage.Remove(`${userId}_friendLog`); VRCXStorage.Remove(`${userId}_friendLog`);
this.friendLogTable.data = VRCXStorage.GetArray( this.friendLogTable.data = await VRCXStorage.GetArray(
`${userId}_friendLogTable` `${userId}_friendLogTable`
); );
database.addFriendLogHistoryArray(this.friendLogTable.data); database.addFriendLogHistoryArray(this.friendLogTable.data);
@@ -12996,12 +12999,15 @@ speechSynthesis.getVoices();
'VRCX_StartAtWindowsStartup' 'VRCX_StartAtWindowsStartup'
); );
$app.data.isStartAsMinimizedState = $app.data.isStartAsMinimizedState =
VRCXStorage.Get('VRCX_StartAsMinimizedState') === 'true'; (await VRCXStorage.Get('VRCX_StartAsMinimizedState')) === 'true';
$app.data.isCloseToTray = VRCXStorage.Get('VRCX_CloseToTray') === 'true'; $app.data.isCloseToTray = VRCXStorage.Get('VRCX_CloseToTray') === 'true';
if (configRepository.getBool('VRCX_CloseToTray')) { if (configRepository.getBool('VRCX_CloseToTray')) {
// move back to JSON // move back to JSON
$app.data.isCloseToTray = configRepository.getBool('VRCX_CloseToTray'); $app.data.isCloseToTray = configRepository.getBool('VRCX_CloseToTray');
VRCXStorage.Set('VRCX_CloseToTray', $app.data.isCloseToTray.toString()); await VRCXStorage.Set(
'VRCX_CloseToTray',
$app.data.isCloseToTray.toString()
);
configRepository.remove('VRCX_CloseToTray'); configRepository.remove('VRCX_CloseToTray');
} }
var saveVRCXWindowOption = function () { var saveVRCXWindowOption = function () {
+18
View File
@@ -4,6 +4,22 @@ function transformKey(key) {
return String(key).toLowerCase(); return String(key).toLowerCase();
} }
function waitSynchronous(promise) {
if (typeof promise !== 'object' || promise === null) {
return promise;
}
console.log('waitSynchronous', promise);
while (true) {
var state = promise.getState();
if (state === 'resolved') {
return promise.get();
}
if (state === 'rejected') {
return null;
}
}
}
class SharedRepository { class SharedRepository {
remove(key) { remove(key) {
var _key = transformKey(key); var _key = transformKey(key);
@@ -12,6 +28,8 @@ class SharedRepository {
getString(key, defaultValue = null) { getString(key, defaultValue = null) {
var _key = transformKey(key); var _key = transformKey(key);
// var get = SharedVariable.Get(_key);
// var value = waitSynchronous(get);
var value = SharedVariable.Get(_key); var value = SharedVariable.Get(_key);
if (value === null) { if (value === null) {
return defaultValue; return defaultValue;