Skip to content

Commit

Permalink
fix: open the home screen if the current server is deleted externally
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexogamer committed Oct 28, 2023
1 parent 3abb0be commit a5cdb11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ class MainView extends React.Component {
}
}
});
client.on('server/delete', async s => {
const currentServer = app.getCurrentServer();
if (currentServer === s) {
app.openServer(undefined);
app.openChannel(null);
}
});
AsyncStorage.getItem('token', async (err, res) => {
if (!err) {
if (typeof res !== 'string') {
Expand Down
3 changes: 3 additions & 0 deletions src/Generic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ export const app = {
openInvite: i => {},
openBotInvite: i => {},
openServer: (s?: Server) => {},
getCurrentServer: () => {
return undefined as string | undefined;
},
openChannel: c => {},
openDirectMessage: (c: Channel) => {},
openImage: a => {},
Expand Down
3 changes: 3 additions & 0 deletions src/SideMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export const LeftMenu = ({
setCurrentServerInner(s);
AsyncStorage.setItem('lastServer', s?._id || 'DirectMessage');
}
setFunction('getCurrentServer', () => {
return currentServer?._id ?? undefined;
})
setFunction('openServer', (s: Server | null) => {
setCurrentServer(s);
});
Expand Down

0 comments on commit a5cdb11

Please sign in to comment.