feat: app 2.0
Some checks failed
FanslySync Build & Test / FanslySync Test Runner (push) Has been cancelled
Some checks failed
FanslySync Build & Test / FanslySync Test Runner (push) Has been cancelled
This commit is contained in:
parent
d7907558df
commit
22259a3e8f
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "fanslysync-desktop",
|
||||
"version": "0.1.7",
|
||||
"version": "0.2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
@ -17,7 +17,7 @@ tauri-build = { version = "2.0.0", features = [] }
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "2.4.1", features = [] }
|
||||
tauri = { version = "2.4.1", features = ["tray-icon"] }
|
||||
dirs = "5.0.1"
|
||||
reqwest = { version = "0.11.18", features = ["json", "multipart"] }
|
||||
lazy_static = "1.5.0"
|
||||
@ -28,7 +28,7 @@ tauri-plugin-dialog = { version = "2.2.1" }
|
||||
tauri-plugin-clipboard-manager = { version = "2.2.1" }
|
||||
tauri-plugin-notification = { version = "2.2.1" }
|
||||
tauri-plugin-updater = { version = "2.2.1" }
|
||||
tauri-plugin-log = { version = "2.2.1" }
|
||||
tauri-plugin-log = { version = "2.2.1" }
|
||||
log = "0.4.27"
|
||||
thiserror = "2.0.12"
|
||||
|
||||
@ -36,7 +36,7 @@ thiserror = "2.0.12"
|
||||
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
||||
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
|
||||
# DO NOT REMOVE!!
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-autostart = "2.3.0"
|
||||
|
@ -1,4 +1,3 @@
|
||||
use lazy_static::lazy::Lazy;
|
||||
use lazy_static::lazy_static;
|
||||
// Create a simple module for handling the Fansly API, using reqwest to make requests to the API.
|
||||
// This module will contain a struct Fansly, which will have a method to get the user's profile information.
|
||||
@ -9,8 +8,8 @@ use crate::structs::{
|
||||
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use tokio::sync::Mutex;
|
||||
use thiserror::Error;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
// Create a PROGRESS mutex to hold the current sync progress, lazy initialized
|
||||
lazy_static! {
|
||||
@ -39,6 +38,11 @@ pub struct PasteResponse {
|
||||
payload: PasteData,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
struct PasteRequest {
|
||||
content: String,
|
||||
}
|
||||
|
||||
pub struct Fansly {
|
||||
client: reqwest::Client,
|
||||
token: Option<String>,
|
||||
@ -48,9 +52,6 @@ pub struct Fansly {
|
||||
pub enum UploadError {
|
||||
#[error("HTTP error: {0}")]
|
||||
Http(#[from] reqwest::Error),
|
||||
|
||||
#[error("Failed to get UUID from paste.hep.gg URL")]
|
||||
MissingUuid,
|
||||
}
|
||||
|
||||
impl Fansly {
|
||||
@ -230,44 +231,58 @@ impl Fansly {
|
||||
p.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
async fn upload_sync_data(&self, data: SyncDataResponse) -> Result<String, UploadError> {
|
||||
let url = "https://paste.hep.gg/";
|
||||
let url = "https://paste.hep.gg/api/";
|
||||
|
||||
// Convert passed data to bytes
|
||||
let json_string = serde_json::to_string(&data).unwrap();
|
||||
// Make an JSON object with our raw data
|
||||
let paste_data = PasteRequest {
|
||||
content: serde_json::to_string(&data).unwrap(),
|
||||
};
|
||||
|
||||
let form = reqwest::multipart::Form::new()
|
||||
.text("content", json_string);
|
||||
let paste_data_str = serde_json::to_string(&paste_data).unwrap();
|
||||
let est_upload_size = paste_data_str.len() / 1024; // in KB
|
||||
|
||||
log::info!(
|
||||
"Uploading sync data to paste.hep.gg (size: {} KB)",
|
||||
est_upload_size
|
||||
);
|
||||
|
||||
// Create a new client and POST
|
||||
let response = self
|
||||
.client
|
||||
.post(url)
|
||||
.multipart(form)
|
||||
.body(paste_data_str)
|
||||
.header("Content-Type", "application/json")
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
log::error!("Failed to upload sync data...");
|
||||
log::info!("Response: {:?}", response);
|
||||
return Err(UploadError::from(response.error_for_status().unwrap_err()));
|
||||
let status_code = response.status();
|
||||
let err = response.error_for_status_ref().unwrap_err();
|
||||
let response_text = response
|
||||
.text()
|
||||
.await
|
||||
.unwrap_or_else(|_| "Unknown error".to_string());
|
||||
|
||||
log::error!(
|
||||
"Failed to upload sync data to paste.hep.gg. Status code: {}, Response: {}",
|
||||
status_code,
|
||||
response_text
|
||||
);
|
||||
|
||||
return Err(UploadError::Http(err));
|
||||
}
|
||||
|
||||
log::info!("Uploaded sync data successfully.");
|
||||
|
||||
// Get the response URL from the response
|
||||
let url = response.url();
|
||||
// Parse the response
|
||||
let paste_response: PasteResponse = response.json().await?;
|
||||
|
||||
// Grab the UUID from the URL
|
||||
let uuid = url.path_segments()
|
||||
.and_then(|segments| segments.last())
|
||||
.ok_or(UploadError::MissingUuid)?;
|
||||
// Return the paste URL
|
||||
let paste_url = format!("https://paste.hep.gg/api/{}/raw", paste_response.payload.id);
|
||||
log::info!("Paste URL: {}", paste_url);
|
||||
|
||||
log::info!("Sync data uploaded to paste.hep.gg with UUID: {}", uuid);
|
||||
|
||||
// Return the URL of the uploaded data
|
||||
Ok(format!("https://paste.hep.gg/api/{}/raw", uuid))
|
||||
Ok(paste_url)
|
||||
}
|
||||
|
||||
pub async fn upload_auto_sync_data(
|
||||
@ -341,7 +356,8 @@ impl Fansly {
|
||||
|
||||
pub async fn sync(&mut self, auto: bool) -> Result<SyncDataResponse, String> {
|
||||
// Reset progress
|
||||
self.update_progress("Starting Sync".to_string(), 0, 100, false).await;
|
||||
self.update_progress("Starting Sync".to_string(), 0, 100, false)
|
||||
.await;
|
||||
|
||||
// Fetch profile
|
||||
log::info!("[sync::process] Fetching profile...");
|
||||
@ -357,10 +373,14 @@ impl Fansly {
|
||||
let total_followers = account.follow_count;
|
||||
let total_subscribers = account.subscriber_count;
|
||||
|
||||
log::info!("[sync::process] Account ID: {}, Followers: {}, Subscribers: {}",
|
||||
account.id, total_followers, total_subscribers);
|
||||
log::info!(
|
||||
"[sync::process] Account ID: {}, Followers: {}, Subscribers: {}",
|
||||
account.id,
|
||||
total_followers,
|
||||
total_subscribers
|
||||
);
|
||||
|
||||
let mut followers: Vec<FanslyFollowersResponse> = Vec::new();
|
||||
let mut followers: Vec<String> = Vec::new();
|
||||
let mut subscribers: Vec<Subscription> = Vec::new();
|
||||
|
||||
log::info!("[sync::process] Fetching followers...");
|
||||
@ -371,7 +391,9 @@ impl Fansly {
|
||||
while followers.len() < total_followers as usize {
|
||||
log::info!(
|
||||
"[sync::process] Fetching followers for account {} with offset {} (total: {})",
|
||||
account.id, offset, total_followers
|
||||
account.id,
|
||||
offset,
|
||||
total_followers
|
||||
);
|
||||
let response = self
|
||||
.fetch_followers(&account.id, &self.token.as_ref().unwrap(), offset)
|
||||
@ -382,7 +404,13 @@ impl Fansly {
|
||||
"[sync::process] Got {} followers from API.",
|
||||
response.response.len()
|
||||
);
|
||||
followers.extend(response.response.clone());
|
||||
|
||||
|
||||
// Collect followers
|
||||
for follower in response.response.clone() {
|
||||
followers.push(follower.follower_id);
|
||||
}
|
||||
|
||||
offset += 100;
|
||||
total_requests += 1;
|
||||
|
||||
@ -391,8 +419,9 @@ impl Fansly {
|
||||
"Fetching Followers".to_string(),
|
||||
followers.len() as u32,
|
||||
total_followers as u32,
|
||||
false
|
||||
).await;
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Every 10 requests, sleep for a bit to avoid rate limiting
|
||||
if total_requests % 10 == 0 {
|
||||
@ -400,7 +429,7 @@ impl Fansly {
|
||||
}
|
||||
|
||||
// If we've received no followers, break the loop
|
||||
if response.response.is_empty() {
|
||||
if response.clone().response.is_empty() {
|
||||
log::info!("[sync::process] No more followers found, breaking the loop.");
|
||||
break;
|
||||
}
|
||||
@ -411,7 +440,9 @@ impl Fansly {
|
||||
while subscribers.len() < total_subscribers as usize {
|
||||
log::info!(
|
||||
"[sync::process] Fetching subscribers with offset {} for account {} (total: {})",
|
||||
offset, account.id, total_subscribers
|
||||
offset,
|
||||
account.id,
|
||||
total_subscribers
|
||||
);
|
||||
|
||||
let response = self
|
||||
@ -428,8 +459,9 @@ impl Fansly {
|
||||
"Fetching Subscribers".to_string(),
|
||||
subscribers.len() as u32,
|
||||
total_subscribers as u32,
|
||||
false
|
||||
).await;
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
|
||||
// Every 10 requests, sleep for a bit to avoid rate limiting
|
||||
if total_requests % 10 == 0 {
|
||||
@ -452,7 +484,8 @@ impl Fansly {
|
||||
log::info!("[sync::process] Sync complete.");
|
||||
|
||||
// Reset progress
|
||||
self.update_progress("Sync Complete".to_string(), 100, 100, true).await;
|
||||
self.update_progress("Sync Complete".to_string(), 100, 100, true)
|
||||
.await;
|
||||
|
||||
log::info!("[sync::process] Uploading sync data to paste.hep.gg for processing...");
|
||||
|
||||
|
@ -10,10 +10,15 @@ use std::io;
|
||||
|
||||
use commands::config::{get_config, init_config, save_config};
|
||||
use commands::fansly::{
|
||||
fansly_check_sync_token, fansly_get_me, fansly_set_token, fansly_sync,
|
||||
fansly_upload_auto_sync_data, fansly_get_sync_status
|
||||
fansly_check_sync_token, fansly_get_me, fansly_get_sync_status, fansly_set_token, fansly_sync,
|
||||
fansly_upload_auto_sync_data,
|
||||
};
|
||||
use commands::utils::quit;
|
||||
use tauri::menu::Menu;
|
||||
use tauri::menu::MenuItem;
|
||||
use tauri::tray::TrayIconBuilder;
|
||||
use tauri::AppHandle;
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_autostart::MacosLauncher;
|
||||
use tauri_plugin_log::{Target, TargetKind};
|
||||
|
||||
@ -32,9 +37,55 @@ fn get_log_path() -> io::Result<String> {
|
||||
Ok(config_dir.to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
fn handle_menu(app: &tauri::AppHandle, event: &tauri::menu::MenuEvent) {
|
||||
match event.id().as_ref() {
|
||||
"quit" => {
|
||||
app.exit(0);
|
||||
}
|
||||
"show_window" => {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.show();
|
||||
let _ = window.set_focus();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
// Setup menu items for the tray
|
||||
let quit_i = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;
|
||||
let show_window_i =
|
||||
MenuItem::with_id(app, "show_window", "Show Window", true, None::<&str>)?;
|
||||
|
||||
// Create our Menu and add the items to it
|
||||
let menu = Menu::with_items(app, &[&quit_i, &show_window_i])?;
|
||||
|
||||
// Create our Tray using TrayIconBuilder and add the menu to it
|
||||
TrayIconBuilder::new()
|
||||
.icon(app.default_window_icon().unwrap().clone())
|
||||
.title("FanslySync")
|
||||
.tooltip("FanslySync")
|
||||
.menu(&menu)
|
||||
.show_menu_on_left_click(true)
|
||||
.on_menu_event(|app: &AppHandle, event: tauri::menu::MenuEvent| {
|
||||
handle_menu(app, &event)
|
||||
})
|
||||
.build(app)?;
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.on_window_event(|app, event| {
|
||||
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
|
||||
if let Some(window) = app.get_webview_window("main") {
|
||||
let _ = window.hide();
|
||||
api.prevent_close();
|
||||
}
|
||||
}
|
||||
})
|
||||
.plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
None,
|
||||
|
@ -3,7 +3,7 @@ use serde_json::Value;
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SyncDataResponse {
|
||||
pub followers: Vec<FanslyFollowersResponse>,
|
||||
pub followers: Vec<String>,
|
||||
pub subscribers: Vec<Subscription>,
|
||||
pub sync_data_url: String,
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
"createUpdaterArtifacts": true
|
||||
},
|
||||
"productName": "FanslySync",
|
||||
"version": "0.1.7",
|
||||
"version": "0.2.0",
|
||||
"identifier": "com.fanslycreatorbot.fanslysync",
|
||||
"plugins": {
|
||||
"updater": {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
||||
[0813/143825.367:ERROR:registration_protocol_win.cc(108)] CreateFile: The system cannot find the file specified. (0x2)
|
||||
[0813/143918.868:ERROR:registration_protocol_win.cc(108)] CreateFile: The system cannot find the file specified. (0x2)
|
@ -1,265 +1,194 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import { message } from '@tauri-apps/plugin-dialog';
|
||||
import { awaiter } from '$lib/utils';
|
||||
|
||||
// --- Types & Config ---
|
||||
import type { Config, AccountInfo } from '$lib/types';
|
||||
|
||||
// --- State ---
|
||||
let loading = true;
|
||||
let errored = false;
|
||||
let step = 0;
|
||||
let status = 'Contacting Fansly and checking account...';
|
||||
|
||||
let fanslyToken = '';
|
||||
let validationErrors = {
|
||||
fanslyToken: ''
|
||||
};
|
||||
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
import { message } from '@tauri-apps/plugin-dialog';
|
||||
import { awaiter } from '$lib/utils';
|
||||
import { onMount } from 'svelte';
|
||||
import type { AccountInfo, Config } from '$lib/types';
|
||||
let validationErrors = { fanslyToken: '' };
|
||||
|
||||
onMount(async () => {
|
||||
const [config, configError] = await awaiter(invoke('get_config'));
|
||||
|
||||
if (configError) {
|
||||
await message(
|
||||
`Something went wrong while getting the configuration. We've copied the error to your clipboard. Please report this issue on GitHub.\n\nError: ${configError}\n\nThe application will now close.`,
|
||||
{ title: 'BambuConnect | Configuration Error', kind: 'error' }
|
||||
);
|
||||
|
||||
await writeText(configError);
|
||||
invoke('quit', { code: 1 });
|
||||
return;
|
||||
}
|
||||
|
||||
if (configError) return await handleError(configError);
|
||||
loading = false;
|
||||
});
|
||||
|
||||
async function loginToFanslyAndFetchData() {
|
||||
const [config, configError] = (await awaiter(invoke('get_config'))) as [Config, any | null];
|
||||
|
||||
if (configError) {
|
||||
await message(
|
||||
`Something went wrong while getting the configuration. We've copied the error to your clipboard. Please report this issue on GitHub.\n\nError: ${configError}\n\nThe application will now close.`,
|
||||
{ title: 'BambuConnect | Configuration Error', kind: 'error' }
|
||||
);
|
||||
|
||||
await writeText(configError);
|
||||
invoke('quit', { code: 1 });
|
||||
return;
|
||||
}
|
||||
await invoke('fansly_set_token', { token: fanslyToken });
|
||||
const [me, error] = (await awaiter(invoke('fansly_get_me'))) as [
|
||||
{
|
||||
success: boolean;
|
||||
response: AccountInfo;
|
||||
},
|
||||
any | null
|
||||
];
|
||||
|
||||
if (me === null) {
|
||||
console.error(`Failed to authenticate with Fansly. Error: ${error}`);
|
||||
step = 1;
|
||||
validationErrors.fanslyToken =
|
||||
'We could not authenticate with Fansly. Please check your token and try again.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!me.success) {
|
||||
console.error(`Failed to authenticate with Fansly. Error: ${me.response}`);
|
||||
step = 1;
|
||||
validationErrors.fanslyToken =
|
||||
'We could not authenticate with Fansly. Please check your token and try again.';
|
||||
return;
|
||||
}
|
||||
|
||||
status = 'Finishing up...';
|
||||
|
||||
console.log('fanslyToken', fanslyToken);
|
||||
config.fansly_token = fanslyToken;
|
||||
config.is_first_run = false;
|
||||
await invoke('save_config', { config });
|
||||
step = 3;
|
||||
async function handleError(err: unknown) {
|
||||
errored = true;
|
||||
await message(`Something went wrong. Error: ${err}`, { title: 'Setup Error', kind: 'error' });
|
||||
await writeText(String(err));
|
||||
invoke('quit', { code: 1 });
|
||||
}
|
||||
|
||||
function validateLoginForm() {
|
||||
let hasErrors = false;
|
||||
|
||||
if (fanslyToken === '') {
|
||||
validationErrors.fanslyToken = 'Please enter your Fansly token.';
|
||||
hasErrors = true;
|
||||
} else {
|
||||
validationErrors.fanslyToken = '';
|
||||
}
|
||||
|
||||
if (hasErrors) {
|
||||
return;
|
||||
}
|
||||
|
||||
validationErrors.fanslyToken = fanslyToken ? '' : 'Please enter your Fansly token.';
|
||||
if (validationErrors.fanslyToken) return;
|
||||
step = 2;
|
||||
loginToFanslyAndFetchData();
|
||||
}
|
||||
|
||||
async function loginToFanslyAndFetchData() {
|
||||
try {
|
||||
const [config] = await awaiter(invoke('get_config') as Promise<Config>);
|
||||
|
||||
if (!config) {
|
||||
validationErrors.fanslyToken =
|
||||
'Failed to retrieve configuration -- please try restarting the app.';
|
||||
step = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
await invoke('fansly_set_token', { token: fanslyToken });
|
||||
const [me, err] = (await awaiter(invoke('fansly_get_me'))) as [
|
||||
{ success: boolean; response: AccountInfo },
|
||||
unknown
|
||||
];
|
||||
if (err || !me?.success) {
|
||||
validationErrors.fanslyToken =
|
||||
'Authentication failed. Please check your token and try again.';
|
||||
step = 1;
|
||||
return;
|
||||
}
|
||||
status = 'Finishing up...';
|
||||
config.fansly_token = fanslyToken;
|
||||
config.is_first_run = false;
|
||||
await invoke('save_config', { config });
|
||||
step = 3;
|
||||
} catch (e) {
|
||||
validationErrors.fanslyToken = 'Unexpected error. Please try again.';
|
||||
step = 1;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="container bg-zinc-800 w-screen h-screen">
|
||||
<!-- Centered loading spinner -->
|
||||
<div class="flex flex-col justify-center items-center h-screen">
|
||||
<div class="flex items-center justify-center min-h-screen bg-zinc-900 text-zinc-200 p-6">
|
||||
<div class="w-full max-w-lg space-y-8">
|
||||
{#if loading}
|
||||
<div role="status">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
<div class="text-center space-y-4">
|
||||
<svg class="mx-auto w-16 h-16 animate-spin text-zinc-600 fill-zinc-500" viewBox="0 0 24 24">
|
||||
<circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" fill="none"
|
||||
></circle>
|
||||
<path d="M22 12a10 10 0 00-10-10" stroke="currentFill" stroke-width="4"></path>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
<p>Loading setup...</p>
|
||||
</div>
|
||||
|
||||
<h1 class="text-2xl font-bold mt-2 text-white">Setup is loading...</h1>
|
||||
{/if}
|
||||
|
||||
{#if errored}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="w-12 h-12 text-red-500 dark:text-red-400"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<h1 class="text-2xl font-bold mt-2 text-white">Oops!</h1>
|
||||
<p class="text-red-500 mt-2 max-w-[30em]">
|
||||
An error was encountered while initializing the setup, please try closing and reopening
|
||||
FanslySync.
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if !loading && !errored}
|
||||
{:else if errored}
|
||||
<div class="text-center space-y-4">
|
||||
<svg
|
||||
class="mx-auto w-12 h-12 text-red-500"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path d="M6 18L18 6M6 6l12 12"></path>
|
||||
</svg>
|
||||
<h2 class="text-2xl font-bold">Oops!</h2>
|
||||
<p>An error occurred during setup. Please restart the application.</p>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- Step 0: Welcome -->
|
||||
{#if step === 0}
|
||||
<h1 class="text-2xl font-bold mt-2 text-white">Welcome to FanslySync!</h1>
|
||||
<p class="text-gray-200 break-words max-w-[30em]">
|
||||
Because this is your first time running FanslySync, we need to set up the connection to
|
||||
your Fansly account. Click the button below to get started.
|
||||
</p>
|
||||
|
||||
{#if errored}
|
||||
<p class="text-red-500 mt-2">
|
||||
An error occurred while initializing the setup. Please try again.
|
||||
<div class="space-y-4 text-center">
|
||||
<h2 class="text-2xl font-bold">Welcome to FanslySync!</h2>
|
||||
<p>
|
||||
Since this is your first time running FanslySync, we need to connect to your Fansly
|
||||
account.
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
{#if !loading}
|
||||
<button
|
||||
on:click={() => {
|
||||
step = 1;
|
||||
}}
|
||||
class="mt-4 bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||
on:click={() => (step = 1)}
|
||||
class="mt-4 w-full bg-blue-600 text-white py-2 rounded hover:bg-blue-500 transition"
|
||||
>
|
||||
Begin Setup
|
||||
</button>
|
||||
{/if}
|
||||
{:else if step === 1}
|
||||
<h1 class="text-2xl font-bold mt-2 text-white">Authenticate with Fansly</h1>
|
||||
<p class="text-gray-200 break-words max-w-[30em]">
|
||||
To establish a secure connection with Fansly, we require your Fansly Authentication Token.
|
||||
We do not transmit this token to our servers and it is only used to authenticate with
|
||||
Fansly and fetch data locally. <br /> <br />
|
||||
For more information on how to get your Fansly Authentication Token, please visit our documentation,
|
||||
or join our Discord server if you need help or have any questions.
|
||||
</p>
|
||||
|
||||
<label for="username" class="text-gray-200 mt-4"> Fansly Authentication Token </label>
|
||||
<input
|
||||
id="fanslyToken"
|
||||
class="w-full bg-zinc-700 text-gray-200 px-4 py-2 rounded-md mt-2 max-w-96"
|
||||
type="text"
|
||||
autocomplete="current-password"
|
||||
bind:value={fanslyToken}
|
||||
/>
|
||||
|
||||
{#if validationErrors.fanslyToken !== ''}
|
||||
<p class="text-red-500 mt-2">{validationErrors.fanslyToken}</p>
|
||||
{/if}
|
||||
|
||||
{#if !loading}
|
||||
<button
|
||||
on:click={validateLoginForm}
|
||||
class="mt-4 bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||
>
|
||||
Authenticate and setup connection
|
||||
</button>
|
||||
{/if}
|
||||
{:else if step == 2}
|
||||
<div role="status">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
|
||||
<h1 class="text-2xl font-bold mt-2 text-white">We are working our magic!</h1>
|
||||
<p class="text-gray-200 break-words max-w-[30em]">
|
||||
We are now authenticating with Fansly and fetching your data. This may take a few moments.
|
||||
</p>
|
||||
<p class="text-gray-200 break-words max-w-[30em]">
|
||||
{status}
|
||||
</p>
|
||||
{:else if step === 3}
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="w-12 h-12 text-green-500 dark:text-green-400"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
|
||||
/>
|
||||
</svg>
|
||||
<h1 class="text-2xl font-bold mt-2 text-white">Setup Complete!</h1>
|
||||
<p class="text-gray-200 break-words max-w-[30em]">
|
||||
You're all set! FanslySync is now connected to your Fansly account and is ready to use.
|
||||
</p>
|
||||
<!-- Step 1: Token entry -->
|
||||
{:else if step === 1}
|
||||
<div class="space-y-4">
|
||||
<h2 class="text-2xl font-bold text-center">Authenticate with Fansly</h2>
|
||||
<p class="text-zinc-400">
|
||||
Enter your Fansly Authentication Token. We use it only locally to fetch data.
|
||||
</p>
|
||||
<div class="space-y-2">
|
||||
<label for="token" class="block">Fansly Token</label>
|
||||
<input
|
||||
id="token"
|
||||
type="text"
|
||||
bind:value={fanslyToken}
|
||||
class="w-full bg-zinc-800 p-2 rounded placeholder-zinc-500"
|
||||
placeholder="Paste your token here"
|
||||
/>
|
||||
{#if validationErrors.fanslyToken}
|
||||
<p class="text-red-500 text-sm">{validationErrors.fanslyToken}</p>
|
||||
{/if}
|
||||
</div>
|
||||
<button
|
||||
on:click={validateLoginForm}
|
||||
class="mt-4 w-full bg-blue-600 text-white py-2 rounded hover:bg-blue-500 transition"
|
||||
>
|
||||
Authenticate & Continue
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
on:click={() => {
|
||||
window.location.href = '/home';
|
||||
}}
|
||||
class="mt-4 bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||
>
|
||||
Finish
|
||||
</button>
|
||||
<!-- Step 2: Loading -->
|
||||
{:else if step === 2}
|
||||
<div class="text-center space-y-4">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="mx-auto size-16 animate-spin"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"
|
||||
/>
|
||||
</svg>
|
||||
<h2 class="text-2xl font-bold">Processing…</h2>
|
||||
<p>{status}</p>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Success -->
|
||||
{:else if step === 3}
|
||||
<div class="text-center space-y-4">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke-width="1.5"
|
||||
stroke="currentColor"
|
||||
class="mx-auto size-16 text-green-400"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0
|
||||
1 1-18 0 9 9 0 0 1 18 0Z"
|
||||
/>
|
||||
</svg>
|
||||
<h2 class="text-2xl font-bold">Setup Complete!</h2>
|
||||
<p>You’re now connected. Ready to go!</p>
|
||||
<button
|
||||
on:click={() => (window.location.href = '/home')}
|
||||
class="mt-4 w-full bg-blue-600 text-white py-2 rounded hover:bg-blue-500 transition"
|
||||
>
|
||||
Finish
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user