Commit b6d9bef
Changed files (3)
app
commands
screens
app/commands/index.js
@@ -1,5 +1,7 @@
import LoginCommand from './login-command';
+import LogoutCommand from './logout-command';
export {
LoginCommand,
+ LogoutCommand,
};
app/commands/logout-command.js
@@ -0,0 +1,13 @@
+export default class LogoutCommand {
+ constructor(applicationStorage) {
+ this.applicationStorage = applicationStorage;
+ }
+
+ subscribeTo(eventAggregator) {
+ eventAggregator.subscribe('LOGOUT', this);
+ }
+
+ notify(event) {
+ this.applicationStorage.delete('authentication_token');
+ }
+}
app/screens/dashboard-screen.js
@@ -25,7 +25,7 @@ export default class DashboardScreen extends ApplicationComponent {
return (
<Container>
<Header>
- <Title>Stronglifters {this.props.username}</Title>
+ <Title>{this.props.username}</Title>
<Button transparent rounded>
<Image source={{uri: gravatarUri}} style={{width: 32, height: 32}} />
</Button>
@@ -70,9 +70,7 @@ export default class DashboardScreen extends ApplicationComponent {
}
onLogout() {
- const storage = new ApplicationStorage();
- storage.delete('authentication_token');
- storage.delete('username');
+ this.publish({event: 'LOGOUT'})
this.props.navigator.pop();
}