Skip to content

Commit

Permalink
mobile: ProfileTabs: refactor sign out
Browse files Browse the repository at this point in the history
Fixes #125
  • Loading branch information
ericswpark committed Apr 20, 2024
1 parent a256eaf commit 86205e4
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions mobile/Components/ProfileTabs/ProfileTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import { SafeAreaView } from "react-native-safe-area-context";
import { ProfileContext } from "../../Contexts";
import ManageProfile from "../ManageProfile";
import StatisticsTab from "../StatisticsTab";
import Backend from "@/Backend";

const backend = new Backend();

const Tab = createMaterialTopTabNavigator();

Expand Down Expand Up @@ -89,23 +92,20 @@ function ProfileTab(props) {
navigation.navigate("DeleteAccount");
};

function signOut() {
(async () => {
try {
console.log("here sign out");
await account.deleteSessions();
} catch (error) {
console.log(error);
}
})();
async function signOut() {
try {
account.get().then((response) => {
unregisterIndieDevice(response.$id, 20878, 'sMBFDEdTPOzXb6A2bqP169');
});
// Unregister notifications
await unregisterIndieDevice(
await backend.getUserId(),
20878,
"sMBFDEdTPOzXb6A2bqP169",
);

await account.deleteSessions();
refreshLoginState();
} catch (error) {
console.log(error);
console.error(error);
}
refreshLoginState();
}

return (
Expand Down Expand Up @@ -176,11 +176,9 @@ function ProfileTab(props) {
</Text>
</Button>

<Divider style={{marginTop: 10}}/>
<Divider style={{ marginTop: 10 }} />

<TouchableOpacity
onPress={() => navigation.navigate("pastWrappeds")}
>
<TouchableOpacity onPress={() => navigation.navigate("pastWrappeds")}>
<View
style={{
flexDirection: "row",
Expand All @@ -193,7 +191,11 @@ function ProfileTab(props) {
Past Wrappeds
</Text>
<View style={{ flex: 2 }}>
<Icon name="event-repeat" color={Colors.BUTTON_PURPLE} size={30} />
<Icon
name="event-repeat"
color={Colors.BUTTON_PURPLE}
size={30}
/>
</View>
</View>
</TouchableOpacity>
Expand Down Expand Up @@ -246,7 +248,7 @@ function ProfileTab(props) {

<Divider />

<TouchableOpacity onPress={() => signOut()}>
<TouchableOpacity onPress={signOut}>
<View
style={{
flexDirection: "row",
Expand Down

0 comments on commit 86205e4

Please sign in to comment.