- Neuer Endpoint /api/magic/me liefert nickname/avatar/plan fuer Hub-Header. Mac-App ruft fetchMe() beim Hub-Load. - DeviceHubView Header zeigt jetzt Avatar (AsyncImage mit Fallback auf Initial-Letter), Nickname + Plan-Badge statt nur 'ReBreak Magic'. - /api/magic/devices erweitert: listet zusaetzlich UserDevice-Rows mit boundToPlan != null (das sind iPhone/iPad aus dem Native-App-Login- Flow, Legend-Device-Lock). source='locked'. - Dedupe: ProtectedDevice wird unterdrueckt wenn bereits ein UserDevice mit aehnlichem Namen + gleicher Plattform existiert (fixt doppelten MacBook im Hub). - Helper prettyPlatform() + Normalisierung (platform-key 'mac'/'ios'/ 'android'/'win') fuer robusten Vergleich.
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { create } from 'zustand';
|
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
|
|
const STORAGE_KEY = '@rebreak/chat-backgrounds';
|
|
|
|
// Pro-Chat-Hintergrund (lokal, gerätegebunden). Default = 'clean' (Insta-Style,
|
|
// solider Theme-BG ohne Muster). 'pattern' = der WhatsApp-artige SVG-Symbol-BG.
|
|
export type ChatBgStyle = 'clean' | 'pattern';
|
|
export const DEFAULT_CHAT_BG: ChatBgStyle = 'clean';
|
|
|
|
type ChatBackgroundState = {
|
|
// partnerId → Stil. Fehlt der Key → DEFAULT_CHAT_BG.
|
|
backgrounds: Record<string, ChatBgStyle>;
|
|
init: () => Promise<void>;
|
|
setBackground: (partnerId: string, style: ChatBgStyle) => Promise<void>;
|
|
};
|
|
|
|
export const useChatBackgroundStore = create<ChatBackgroundState>((set, get) => ({
|
|
backgrounds: {},
|
|
|
|
init: async () => {
|
|
try {
|
|
const raw = await AsyncStorage.getItem(STORAGE_KEY);
|
|
if (raw) set({ backgrounds: JSON.parse(raw) });
|
|
} catch {
|
|
// non-fatal — Default-Clean greift
|
|
}
|
|
},
|
|
|
|
setBackground: async (partnerId, style) => {
|
|
const next = { ...get().backgrounds, [partnerId]: style };
|
|
set({ backgrounds: next });
|
|
try {
|
|
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
|
} catch {
|
|
// non-fatal
|
|
}
|
|
},
|
|
}));
|