Migrate from window.electron to tauri IPC functions across components
- Replaced `window.electron.invoke` calls with equivalent `tauri` function calls for all IPC interactions. - Removed `electron.d.ts` TypeScript definitions as they are no longer needed. - Updated related logic for offline/online state synchronization. - Added `types.rs` and `shared/mod.rs` modules to support Tauri IPC integration with Rust enums and shared logic. - Refactored IPC request queues to use updated handler names for consistency with Tauri.
This commit is contained in:
@@ -5,44 +5,32 @@ import OfflinePinVerify from '@/components/offline/OfflinePinVerify';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faWifi, faArrowLeft } from '@fortawesome/free-solid-svg-icons';
|
||||
import * as tauri from '@/lib/tauri';
|
||||
|
||||
export default function OfflineLoginPage() {
|
||||
const t = useTranslations();
|
||||
|
||||
async function handlePinSuccess(userId: string):Promise<void> {
|
||||
|
||||
// Initialize database with user's encryption key
|
||||
if (window.electron) {
|
||||
try {
|
||||
// Get encryption key
|
||||
const encryptionKey = await window.electron.getUserEncryptionKey(userId);
|
||||
if (encryptionKey) {
|
||||
// Initialize database
|
||||
await window.electron.dbInitialize(userId, encryptionKey);
|
||||
|
||||
// Navigate to main page
|
||||
window.location.href = '/';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[OfflineLogin] Error initializing database:', error);
|
||||
async function handlePinSuccess(userId: string): Promise<void> {
|
||||
try {
|
||||
const encryptionKey = await tauri.getUserEncryptionKey(userId);
|
||||
if (encryptionKey) {
|
||||
await tauri.dbInitialize(userId, encryptionKey);
|
||||
await tauri.loginSuccess();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[OfflineLogin] Error initializing database:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function handleBackToOnline():void {
|
||||
if (window.electron) {
|
||||
window.electron.logout();
|
||||
}
|
||||
function handleBackToOnline(): void {
|
||||
tauri.logout();
|
||||
}
|
||||
|
||||
useEffect(():void => {
|
||||
// Check if we have offline capability
|
||||
useEffect((): void => {
|
||||
async function checkOfflineCapability() {
|
||||
if (window.electron) {
|
||||
const offlineStatus = await window.electron.offlineModeGet();
|
||||
if (!offlineStatus.hasPin) {
|
||||
window.location.href = '/login/login';
|
||||
}
|
||||
const offlineStatus = await tauri.offlineModeGet();
|
||||
if (!offlineStatus.hasPin) {
|
||||
window.location.href = '/login/login';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user