Skip to content

Commit

Permalink
SUKU profileCloudUrl as persistent setting
Browse files Browse the repository at this point in the history
  • Loading branch information
SukuWc committed Nov 6, 2023
1 parent 0e22358 commit 0ca6413
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/renderer/main/panels/preferences/Preferences.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@

<BlockTitle>Profile cloud URL</BlockTitle>
<BlockBody>Change the url used in the Profile Cloud Iframe.</BlockBody>
<MoltenInput bind:target={$appSettings.profileCloudUrl} />
<MoltenInput bind:target={$appSettings.persistent.profileCloudUrl} />
<MeltRadio
bind:target={$appSettings.profileCloudUrl}
bind:target={$appSettings.persistent.profileCloudUrl}
options={[
{
title: "Development (localhost)",
Expand Down
41 changes: 27 additions & 14 deletions src/renderer/main/panels/profileCloud/ProfileCloud.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,29 @@
}
}
onMount(async () => {
// get to know the user
await userStore.known;
let listenerRegistered = false;
let profileCloudUrl = "";
$appSettings.profileCloudUrl = buildVariables.PROFILE_CLOUD_URL;
$: if (
listenerRegistered === true &&
profileCloudUrl !== $appSettings.persistent.profileCloudUrl
) {
// listenerRegistered variable makes sure that the iframe loading is after registering the listener.
// otherwise handleProfileCloudMounted is missed and offline fallback is displayed
profileCloudUrl = $appSettings.persistent.profileCloudUrl;
$appSettings.profileCloudUrlEnabled = true;
console.log("Profile Cloud url", profileCloudUrl);
profileCloudIsMounted = false;
}
onMount(async () => {
// get to know the user
await userStore.known;
console.log("profile cloud is mounted status", profileCloudIsMounted);
console.log("Profile Cloud url", $appSettings.persistent.profileCloudUrl);
window.addEventListener("message", initChannelCommunication);
profileCloudUrl = $appSettings.persistent.profileCloudUrl;
listenerRegistered = true;
});
onDestroy(() => {
Expand All @@ -323,13 +335,13 @@
async function loadOfflineProfileCloud() {
const serverAddress = await window.electron.startOfflineProfileCloud();
const url = `http://${serverAddress.address}:${serverAddress.port}`;
$appSettings.profileCloudUrl = url;
profileCloudUrl = url;
}
</script>
<div class="flex flex-col bg-primary w-full h-full">
{#if profileCloudIsMounted == false}
<div class="flex items-center justify-center h-full">
<div class="flex flex-col bg-primary w-full h-full relative">
<div class="flex items-center justify-center h-full absolute">
{#if !profileCloudIsMounted}
<div class="p-4">
<h1 class="text-white text-xl">Sorry, can't load Profile Cloud</h1>
<div class="text-white text-opacity-80">
Expand All @@ -343,13 +355,14 @@
Load Offline
</button>
</div>
</div>
{/if}
{/if}
</div>
<iframe
bind:this={iframe_element}
class="w-full h-full {profileCloudIsMounted == false ? 'hidden' : ''}"
class="w-full h-full {profileCloudIsMounted ? '' : ' hidden'}"
title="Test"
allow="clipboard-read; clipboard-write;}"
src={$appSettings.profileCloudUrl}
src={profileCloudUrl}
/>
</div>
4 changes: 2 additions & 2 deletions src/renderer/runtime/app-helper.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const persistentDefaultValues = {
analyticsEnabled: false,
firstLaunch: true,
fontSize: 12,
profileCloudUrl: configuration.PROFILE_CLOUD_URL_PROD,
};

function checkOS() {
Expand Down Expand Up @@ -114,7 +115,6 @@ function createAppSettingsStore(persistent) {
title: undefined,
owner: { neme: undefined },
},
profileCloudUrl: undefined,
pluginList: [],
persistent: structuredClone(persistent),
});
Expand Down Expand Up @@ -205,7 +205,7 @@ async function init_appsettings() {
get(appSettings).persistent.welcomeOnStartup === true ||
get(appSettings).persistent.lastVersion === undefined ||
get(appSettings).persistent.lastVersion !=
configuration["EDITOR_VERSION"]
configuration["EDITOR_VERSION"]
) {
appSettings.update((s) => {
s.persistent.lastVersion = configuration["EDITOR_VERSION"];
Expand Down

0 comments on commit 0ca6413

Please sign in to comment.