version 0.0.04
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
* typisierte Nachrichten.
|
||||
*/
|
||||
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
|
||||
// --- Typen ---
|
||||
|
||||
export type ConnectionState = 'connecting' | 'connected' | 'disconnected';
|
||||
@@ -232,12 +234,13 @@ class RVSConnection {
|
||||
this.messageListeners.forEach(cb => cb(message));
|
||||
}
|
||||
|
||||
// --- Persistenz (AsyncStorage Wrapper) ---
|
||||
// --- Persistenz ---
|
||||
|
||||
private static readonly STORAGE_KEY = 'rvs_config';
|
||||
|
||||
private async saveConfig(config: ConnectionConfig): Promise<void> {
|
||||
try {
|
||||
// In Produktion: AsyncStorage verwenden
|
||||
// await AsyncStorage.setItem('rvs_config', JSON.stringify(config));
|
||||
await AsyncStorage.setItem(RVSConnection.STORAGE_KEY, JSON.stringify(config));
|
||||
console.log('[RVS] Konfiguration gespeichert');
|
||||
} catch (err) {
|
||||
console.error('[RVS] Fehler beim Speichern:', err);
|
||||
@@ -246,9 +249,12 @@ class RVSConnection {
|
||||
|
||||
async loadConfig(): Promise<ConnectionConfig | null> {
|
||||
try {
|
||||
// In Produktion: AsyncStorage verwenden
|
||||
// const data = await AsyncStorage.getItem('rvs_config');
|
||||
// if (data) { this.config = JSON.parse(data); return this.config; }
|
||||
const data = await AsyncStorage.getItem(RVSConnection.STORAGE_KEY);
|
||||
if (data) {
|
||||
this.config = JSON.parse(data);
|
||||
console.log('[RVS] Konfiguration geladen');
|
||||
return this.config;
|
||||
}
|
||||
return null;
|
||||
} catch (err) {
|
||||
console.error('[RVS] Fehler beim Laden:', err);
|
||||
|
||||
Reference in New Issue
Block a user