Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mobile-app/sapot-mobile-app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ const withNetworkSecurityConfig: ConfigPlugin = (config) => {
</network-security-config>`
: `<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="false">server.sapot.lan</domain>
<base-config cleartextTrafficPermitted="false">
<trust-anchors>
<certificates src="system"/>
<certificates src="@raw/server_ca"/>
</trust-anchors>
</domain-config>
</base-config>
</network-security-config>`;

// Step 1: write the XML into res/xml/
Expand Down
6 changes: 3 additions & 3 deletions mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/chat/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -482,7 +482,7 @@ const ChatRoom = () => {
const isSmsEnabled =
gsmReady &&
!!peer?.phoneNumberVerified &&
!userStore.isGuest &&
userStore.hasUser &&
!!(userStore.user as Peer).phoneNumberVerified;

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
2 changes: 1 addition & 1 deletion mobile-app/sapot-mobile-app/app/(drawer)/(tabs)/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function PublicChat() {
const { messages, sendMessage, isConnected, isAvailable, isLoadingHistory, hasMoreHistory, loadMoreHistory } = usePublicChat();
const listRef = useRef<FlatList<PublicChatMessage>>(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<Set<string> | null>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<View style={{ flex: 1 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Peer[]>([]);
useEffect(() => {
Expand Down
Loading