diff --git a/mobile-app/sapot-mobile-app/app.config.ts b/mobile-app/sapot-mobile-app/app.config.ts
index 335ee112..54d770ff 100644
--- a/mobile-app/sapot-mobile-app/app.config.ts
+++ b/mobile-app/sapot-mobile-app/app.config.ts
@@ -91,12 +91,12 @@ const withNetworkSecurityConfig: ConfigPlugin = (config) => {
`
: `
-
- server.sapot.lan
+
+
-
+
`;
// Step 1: write the XML into res/xml/
diff --git a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/chat/[id].tsx b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/chat/[id].tsx
index 873354c6..3dc8ce0e 100644
--- a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/chat/[id].tsx
+++ b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/chat/[id].tsx
@@ -152,7 +152,7 @@ const ChatRoom = () => {
if (source === ChatRoomSource.PEER) {
const resolvedPeerId = id as string;
- const isSelf = resolvedPeerId === userStore.user?.id;
+ const isSelf = userStore.hasUser && resolvedPeerId === userStore.user.id;
uiLog.debug("[ChatRoom] peer resolved from PEER source", {
resolvedPeerId,
isSelf,
@@ -206,7 +206,7 @@ const ChatRoom = () => {
const foundPeerId = await chatService.findPeerIdByChatId(id as string);
if (signal.aborted) return;
- const isSelf = foundPeerId === userStore.user?.id;
+ const isSelf = userStore.hasUser && foundPeerId === userStore.user.id;
uiLog.debug("[ChatRoom] peer resolved from CHAT source", {
foundPeerId,
isSelf,
@@ -482,7 +482,7 @@ const ChatRoom = () => {
const isSmsEnabled =
gsmReady &&
!!peer?.phoneNumberVerified &&
- !userStore.isGuest &&
+ userStore.hasUser &&
!!(userStore.user as Peer).phoneNumberVerified;
useEffect(() => {
diff --git a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/index.tsx b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/index.tsx
index f665ea44..f67185bf 100644
--- a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/index.tsx
+++ b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/index.tsx
@@ -71,10 +71,11 @@ export default function Chat() {
const isFabEnabled =
gsmReady &&
!userStore.isGuest &&
+ userStore.hasUser &&
!!(userStore.user as Peer).phoneNumberVerified;
const currentUserPhone = toInternationalPhone(
- (userStore.user as Peer)?.phoneNumber ?? ""
+ userStore.hasUser ? ((userStore.user as Peer).phoneNumber ?? "") : ""
);
const isSelfPhone = (phone: string) =>
diff --git a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/map.tsx b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/map.tsx
index 5565d0fc..cb595767 100644
--- a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/map.tsx
+++ b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/map.tsx
@@ -103,7 +103,7 @@ export default function GpsScreen() {
const { data: historyData } = useGpsHistory(pathUserId);
- const currentUserId = userStore.user.id;
+ const currentUserId = userStore.hasUser ? userStore.user.id : "";
const userLocations = rawLocations.filter(
(loc) => loc.user_id !== currentUserId
);
diff --git a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/public-chat.tsx b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/public-chat.tsx
index 33c32b25..1f3f1db9 100644
--- a/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/public-chat.tsx
+++ b/mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/public-chat.tsx
@@ -26,7 +26,7 @@ export default function PublicChat() {
const { messages, sendMessage, isConnected, isAvailable, isLoadingHistory, hasMoreHistory, loadMoreHistory } = usePublicChat();
const listRef = useRef>(null);
const userStore = useUserStore();
- const myId = userStore.user.id;
+ const myId = userStore.hasUser ? userStore.user.id : "";
const headerHeight = useHeaderHeight();
const reducedMotion = useReducedMotion();
const seenIdsRef = useRef | null>(null);
diff --git a/mobile-app/sapot-mobile-app/features/chat/components/chat-list.tsx b/mobile-app/sapot-mobile-app/features/chat/components/chat-list.tsx
index 6dae14df..50e9c79b 100644
--- a/mobile-app/sapot-mobile-app/features/chat/components/chat-list.tsx
+++ b/mobile-app/sapot-mobile-app/features/chat/components/chat-list.tsx
@@ -51,7 +51,7 @@ const ChatList = enhanceChats(
onRefresh?: () => void;
}) => {
const userStore = useUserStore();
- const currentUserId = userStore.user?.id ?? "";
+ const currentUserId = userStore.hasUser ? userStore.user.id : "";
const reducedMotion = useReducedMotion();
return (
diff --git a/mobile-app/sapot-mobile-app/features/chat/components/message-list.tsx b/mobile-app/sapot-mobile-app/features/chat/components/message-list.tsx
index c396225f..a0f754f2 100644
--- a/mobile-app/sapot-mobile-app/features/chat/components/message-list.tsx
+++ b/mobile-app/sapot-mobile-app/features/chat/components/message-list.tsx
@@ -402,7 +402,7 @@ const MessageListItemInner = memo(
const content = useDecryptedContent(message);
const userStore = useUserStore();
const theme = useTheme();
- const isCurrentUserMessage = message.sender?.id === userStore.user?.id;
+ const isCurrentUserMessage = userStore.hasUser && message.sender?.id === userStore.user.id;
const chatService = useChatService();
const gsmService = useGsmService();
const peerService = usePeerService();
diff --git a/mobile-app/sapot-mobile-app/features/debug/components/debug-panel.tsx b/mobile-app/sapot-mobile-app/features/debug/components/debug-panel.tsx
index 138b1cec..afb98275 100644
--- a/mobile-app/sapot-mobile-app/features/debug/components/debug-panel.tsx
+++ b/mobile-app/sapot-mobile-app/features/debug/components/debug-panel.tsx
@@ -53,7 +53,7 @@ function DebugPanelContent() {
const variant = __DEV__ ? "development" : (Updates.channel ?? "unknown");
const version = Constants.expoConfig?.extra?.displayVersion ?? "unknown";
- const peerId = userStore.user?.id ?? "—";
+ const peerId = userStore.hasUser ? userStore.user.id : "—";
const handleDismiss = () => {
setSelectedSection(null);
diff --git a/mobile-app/sapot-mobile-app/features/shared/connection/services/user-service.ts b/mobile-app/sapot-mobile-app/features/shared/connection/services/user-service.ts
index f2495d32..12764c9d 100644
--- a/mobile-app/sapot-mobile-app/features/shared/connection/services/user-service.ts
+++ b/mobile-app/sapot-mobile-app/features/shared/connection/services/user-service.ts
@@ -124,7 +124,7 @@ export class UserService {
async logout() {
try {
this.log("logout start");
- this.userStore.setIsRescuer(false);
+ this.userStore.clearUser();
await deleteItemAsync("userUUID");
this.sessionStore.setUserId(undefined);
this.log("logout complete");
@@ -149,7 +149,7 @@ export class UserService {
async wipeDatabase() {
try {
this.log("wipeDatabase start");
- this.userStore.setIsRescuer(false);
+ this.userStore.clearUser();
await deleteItemAsync("userUUID");
this.sessionStore.setUserId(undefined);
if (this.cleanUpService) {
diff --git a/mobile-app/sapot-mobile-app/features/shared/core/stores/user-store.ts b/mobile-app/sapot-mobile-app/features/shared/core/stores/user-store.ts
index 24354446..327b2b71 100644
--- a/mobile-app/sapot-mobile-app/features/shared/core/stores/user-store.ts
+++ b/mobile-app/sapot-mobile-app/features/shared/core/stores/user-store.ts
@@ -63,6 +63,14 @@ export class UserStore {
this.emit();
}
+ clearUser() {
+ this._user = undefined;
+ this._isGuest = false;
+ this._isRescuer = false;
+ this._isAdmin = false;
+ this.emit();
+ }
+
subscribe(listener: UserStoreListener) {
this.listeners.add(listener);
return () => {
diff --git a/mobile-app/sapot-mobile-app/features/shared/hooks/use-peer-list-data.ts b/mobile-app/sapot-mobile-app/features/shared/hooks/use-peer-list-data.ts
index 350f1aa7..2ac2714f 100644
--- a/mobile-app/sapot-mobile-app/features/shared/hooks/use-peer-list-data.ts
+++ b/mobile-app/sapot-mobile-app/features/shared/hooks/use-peer-list-data.ts
@@ -20,7 +20,7 @@ export function usePeerListData(): PeerListEntry[] {
const connectionService = useConnectionService();
const activeUserService = useAcitveUserService();
- const currentUserId = userStore.user.id;
+ const currentUserId = userStore.hasUser ? userStore.user.id : "";
const [allPeers, setAllPeers] = useState([]);
useEffect(() => {