feat(app): implement character login and destination setting for multiple characters
This commit introduces several key features: - **Multiple Character Support**: The application can now handle multiple logged-in EVE Online characters. - **List Characters**: A new function `ListCharacters` allows retrieving a list of all authenticated characters. - **Set Destination for All**: The `SetDestinationForAll` function enables setting a destination for all logged-in characters simultaneously. - **UI Updates**: The frontend has been updated to display logged-in characters and to allow setting destinations for all characters. - **Backend Refinements**: The ESI SSO logic has been improved to support refreshing tokens for multiple characters and to handle the new multi-character functionality. - **Dependency Updates**: Dependencies have been updated to their latest versions. chore: update go module dependencies
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useState, useRef } from 'react';
|
||||
import { System } from '@/lib/types';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { StartESILogin, ESILoginStatus, SetDestinationByName } from 'wailsjs/go/main/App';
|
||||
import { StartESILogin, ListCharacters, SetDestinationForAll } from 'wailsjs/go/main/App';
|
||||
|
||||
interface SystemContextMenuProps {
|
||||
x: number;
|
||||
@@ -29,15 +29,24 @@ export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearCon
|
||||
setIsRenaming(false);
|
||||
};
|
||||
|
||||
const handleSetDestination = async () => {
|
||||
const ensureLoggedInAny = async () => {
|
||||
try {
|
||||
const status = await ESILoginStatus();
|
||||
if (status.includes('not logged in')) {
|
||||
await StartESILogin();
|
||||
toast({ title: 'EVE Login', description: 'Please complete login in your browser, then retry.' });
|
||||
return;
|
||||
}
|
||||
await SetDestinationByName(system.solarSystemName, true, false);
|
||||
const list = await ListCharacters();
|
||||
if (Array.isArray(list) && list.length > 0) return true;
|
||||
await StartESILogin();
|
||||
toast({ title: 'EVE Login', description: 'Please complete login in your browser, then retry.' });
|
||||
return false;
|
||||
} catch {
|
||||
await StartESILogin();
|
||||
toast({ title: 'EVE Login', description: 'Please complete login in your browser, then retry.' });
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSetDestinationAll = async () => {
|
||||
try {
|
||||
if (!(await ensureLoggedInAny())) return;
|
||||
await SetDestinationForAll(system.solarSystemName, true, false);
|
||||
toast({ title: 'Destination set', description: `${system.solarSystemName}` });
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
@@ -102,8 +111,8 @@ export const SystemContextMenu = ({ x, y, system, onRename, onDelete, onClearCon
|
||||
</button>
|
||||
<div className="h-px bg-slate-700 my-1" />
|
||||
<button
|
||||
onClick={handleSetDestination}
|
||||
className="w-full px-3 py-1 text-left text-green-400 hover:bg-slate-700 rounded text-sm"
|
||||
onClick={handleSetDestinationAll}
|
||||
className="w-full px-3 py-1 text-left text-emerald-400 hover:bg-slate-700 rounded text-sm"
|
||||
>
|
||||
Set destination
|
||||
</button>
|
||||
|
Reference in New Issue
Block a user