final updates
This commit is contained in:
parent
b7e0bb582a
commit
b6316ee758
@ -201,7 +201,7 @@ impl Fansly {
|
|||||||
data: SyncDataResponse,
|
data: SyncDataResponse,
|
||||||
token: String,
|
token: String,
|
||||||
) -> Result<(), reqwest::Error> {
|
) -> Result<(), reqwest::Error> {
|
||||||
let url = "http://localhost:5001/sync";
|
let url = "https://botapi.fanslycreatorbot.com/sync";
|
||||||
|
|
||||||
// Set our content type to application/json
|
// Set our content type to application/json
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
@ -233,7 +233,7 @@ impl Fansly {
|
|||||||
// Check if the token is valid (GET /checkSyncToken with Authorization header)
|
// Check if the token is valid (GET /checkSyncToken with Authorization header)
|
||||||
// If it is, return the data back from the API
|
// If it is, return the data back from the API
|
||||||
// If it isn't, return an error
|
// If it isn't, return an error
|
||||||
let url = "http://localhost:5001/checkSyncToken";
|
let url = "https://botapi.fanslycreatorbot.com/checkSyncToken";
|
||||||
|
|
||||||
// Set our content type to application/json
|
// Set our content type to application/json
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
window.location.href = '/setup';
|
window.location.href = '/setup';
|
||||||
} else {
|
} else {
|
||||||
info(`[FanslySync::init] Token valid. Redirecting to /dashboard...`);
|
info(`[FanslySync::init] Token valid. Redirecting to /dashboard...`);
|
||||||
window.location.href = '/dashboard';
|
window.location.href = '/home';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { info, error } from '@tauri-apps/plugin-log';
|
import { info, error } from '@tauri-apps/plugin-log';
|
||||||
import { awaiter } from '$lib/utils';
|
import { awaiter } from '$lib/utils';
|
||||||
import { onMount } from 'svelte';
|
import { onDestroy, onMount } from 'svelte';
|
||||||
import type { Config, SyncData } from '$lib/types';
|
import type { Config, SyncData } from '$lib/types';
|
||||||
import { fade, fly, slide } from 'svelte/transition';
|
import { fade, fly, slide } from 'svelte/transition';
|
||||||
import { sendNotification } from '@tauri-apps/plugin-notification';
|
import { sendNotification } from '@tauri-apps/plugin-notification';
|
||||||
@ -37,7 +37,8 @@
|
|||||||
|
|
||||||
let autoSyncConfig = {
|
let autoSyncConfig = {
|
||||||
interval: 0,
|
interval: 0,
|
||||||
syncToken: ''
|
syncToken: '',
|
||||||
|
didRunInitialValidation: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let autoSyncConfigState = {
|
let autoSyncConfigState = {
|
||||||
@ -472,7 +473,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onAutoSyncSave() {
|
async function onAutoSyncSave() {
|
||||||
// Close the modal
|
// Close the modal and reset the didRunInitialValidation flag
|
||||||
|
autoSyncConfig.didRunInitialValidation = false;
|
||||||
isAutoSyncConfigModalOpen = false;
|
isAutoSyncConfigModalOpen = false;
|
||||||
|
|
||||||
const savingToast = await toast.loading('Saving Auto Sync configuration...');
|
const savingToast = await toast.loading('Saving Auto Sync configuration...');
|
||||||
@ -495,6 +497,31 @@
|
|||||||
await toast.success('Auto Sync configuration saved successfully.', { id: savingToast });
|
await toast.success('Auto Sync configuration saved successfully.', { id: savingToast });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the component is destroyed, clear the interval
|
||||||
|
onDestroy(() => {
|
||||||
|
info(`[FanslySync::page_destroy:home] onDestroy() called. Cleaning up...`);
|
||||||
|
if (syncInterval) {
|
||||||
|
info(`[FanslySync::page_destroy:home] Clearing autosync interval...`);
|
||||||
|
clearInterval(syncInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
info(`[FanslySync::page_destroy:home] Cleaning up completed. Goodbye!`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// When we show the modal, run the initial validation
|
||||||
|
$: if (isAutoSyncConfigModalOpen && !autoSyncConfig.didRunInitialValidation) {
|
||||||
|
onSyncTokenEntered();
|
||||||
|
autoSyncConfig.didRunInitialValidation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function useDebounce(fn: Function, delay: number) {
|
||||||
|
let timeout: number;
|
||||||
|
return function (...args: any) {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(() => fn(...args), delay);
|
||||||
|
};
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container bg-zinc-800 w-screen h-screen">
|
<div class="container bg-zinc-800 w-screen h-screen">
|
||||||
@ -537,7 +564,7 @@
|
|||||||
class="bg-zinc-700 text-gray-200 p-2 rounded-lg mt-1 w-full pr-10"
|
class="bg-zinc-700 text-gray-200 p-2 rounded-lg mt-1 w-full pr-10"
|
||||||
placeholder="Enter sync token"
|
placeholder="Enter sync token"
|
||||||
bind:value={autoSyncConfig.syncToken}
|
bind:value={autoSyncConfig.syncToken}
|
||||||
on:change={onSyncTokenEntered}
|
on:input={useDebounce(onSyncTokenEntered, 500)}
|
||||||
/>
|
/>
|
||||||
{#if !autoSyncConfigState.validatingToken && autoSyncConfigState.tokenValid}
|
{#if !autoSyncConfigState.validatingToken && autoSyncConfigState.tokenValid}
|
||||||
<svg
|
<svg
|
||||||
@ -579,8 +606,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<p class="text-gray-400 mt-1">
|
<p class="text-gray-400 mt-1">
|
||||||
Unfocus (click out of) the input to validate the token. A green checkmark means the
|
Enter your sync token here. A green tick will be displayed if the token is valid, a red
|
||||||
token is valid.
|
cross if it's invalid, and a spinner if it's validating. Please ensure you have a valid
|
||||||
|
sync token set or automatic sync will not work.
|
||||||
</p>
|
</p>
|
||||||
<div class="flex mt-2">
|
<div class="flex mt-2">
|
||||||
<button
|
<button
|
||||||
@ -594,6 +622,7 @@
|
|||||||
class="bg-red-500 text-white px-4 py-2 rounded-lg w-full ml-2 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-red-600 transition-all duration-200 ease-in-out"
|
class="bg-red-500 text-white px-4 py-2 rounded-lg w-full ml-2 disabled:opacity-50 disabled:cursor-not-allowed hover:bg-red-600 transition-all duration-200 ease-in-out"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
isAutoSyncConfigModalOpen = false;
|
isAutoSyncConfigModalOpen = false;
|
||||||
|
autoSyncConfig.didRunInitialValidation = false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
@ -690,6 +719,7 @@
|
|||||||
{config?.auto_sync_enabled ? 'Enabled' : 'Disabled'}
|
{config?.auto_sync_enabled ? 'Enabled' : 'Disabled'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="text-gray-400 mt-1">
|
<p class="text-gray-400 mt-1">
|
||||||
Sync content automatically every {config?.sync_interval}
|
Sync content automatically every {config?.sync_interval}
|
||||||
{(config?.sync_interval ?? 0 > 1) ? 'hour' : 'hours'}. Please ensure you have a
|
{(config?.sync_interval ?? 0 > 1) ? 'hour' : 'hours'}. Please ensure you have a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user