Turn off debug flags and clear study group messages notification cache when switching study groups

This commit is contained in:
Keannu Bernasol 2023-10-28 00:22:17 +08:00
parent 5d7327ef26
commit 2603741aab
2 changed files with 10 additions and 3 deletions

View file

@ -27,7 +27,7 @@ import { useToast } from "react-native-toast-notifications";
import MessageIcon from "../../icons/MessageIcon/MessageIcon"; import MessageIcon from "../../icons/MessageIcon/MessageIcon";
export default function CustomDrawerContent(props: {}) { export default function CustomDrawerContent(props: {}) {
const debug = true; const debug = false;
const navigation = useNavigation<RootDrawerParamList>(); const navigation = useNavigation<RootDrawerParamList>();
const status = useSelector((state: RootState) => state.status); const status = useSelector((state: RootState) => state.status);
const dispatch = useDispatch(); const dispatch = useDispatch();

View file

@ -44,10 +44,11 @@ import Modal from "react-native-modal";
import DropdownIcon from "../../icons/CaretDownIcon/CaretDownIcon"; import DropdownIcon from "../../icons/CaretDownIcon/CaretDownIcon";
import CaretUpIcon from "../../icons/CaretUpIcon/CaretUpIcon"; import CaretUpIcon from "../../icons/CaretUpIcon/CaretUpIcon";
import RefreshIcon from "../../icons/RefreshIcon/RefreshIcon"; import RefreshIcon from "../../icons/RefreshIcon/RefreshIcon";
import AsyncStorage from "@react-native-async-storage/async-storage";
export default function Home() { export default function Home() {
// Switch this condition to see the main map when debugging // Switch this condition to see the main map when debugging
const map_distance_override = true; const map_distance_override = false;
const navigation = useNavigation<RootDrawerParamList>(); const navigation = useNavigation<RootDrawerParamList>();
const [location, setLocation] = useState<RawLocationType | null>(null); const [location, setLocation] = useState<RawLocationType | null>(null);
const [locationPermitted, setLocationPermitted] = useState(false); const [locationPermitted, setLocationPermitted] = useState(false);
@ -125,6 +126,9 @@ export default function Home() {
} }
} }
async function clear_messages_notification_cache() {
AsyncStorage.setItem("messages", "");
}
// Student Status // Student Status
const [studying, setStudying] = useState(false); const [studying, setStudying] = useState(false);
const [subject, setSubject] = useState(""); const [subject, setSubject] = useState("");
@ -163,7 +167,7 @@ export default function Home() {
mutationFn: async (info: StudentStatusPatchType) => { mutationFn: async (info: StudentStatusPatchType) => {
const data = await PatchStudentStatus(info); const data = await PatchStudentStatus(info);
if (data[0] != true) { if (data[0] != true) {
return Promise.reject(new Error()); return Promise.reject(new Error(JSON.stringify(data[1])));
} }
return data; return data;
}, },
@ -224,6 +228,7 @@ export default function Home() {
duration: 2000, duration: 2000,
animationType: "slide-in", animationType: "slide-in",
}); });
clear_messages_notification_cache();
} }
queryClient.invalidateQueries({ queryKey: ["user_status"] }); queryClient.invalidateQueries({ queryKey: ["user_status"] });
@ -932,6 +937,8 @@ export default function Home() {
return <MapRendererFar location={location.coords} dist={dist} />; return <MapRendererFar location={location.coords} dist={dist} />;
} }
} else { } else {
requestLocationPermission();
requestLocation();
return ( return (
<> <>
<View style={{ paddingVertical: 8 }} /> <View style={{ paddingVertical: 8 }} />