Skip to content

Commit

Permalink
fix update and reset teams handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbuks committed Mar 13, 2024
1 parent b0d9db9 commit 27b2d69
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/main/app/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ function updateTeamsHandler(_: any, servers: ConfigServer[]) {
const [defaultServer] = buildConfig.defaultServers!;
const [firstServer] = servers;

if (!servers.length) {
ServerManager.removePredefinedServersHandler(true);
ServerManager.removePredefinedServersHandler(false);

ServerManager.emit(SERVERS_UPDATE);

return;
}

// Check if it's first call to fetch kchat info with kchat.infomaniak.com
if (defaultServer?.url && firstServer.url === defaultServer.url) {
initIKserver();
Expand Down
6 changes: 0 additions & 6 deletions src/main/menus/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ export function createTemplate(config: Config, updateManager: UpdateManager) {
TokenManager.reset();
ViewManager.reload();
},
}, {
label: localizeMessage('main.menus.app.view.updateTeams', 'Update organisations'),
accelerator: 'Shift+CmdOrCtrl+T',
click() {
ViewManager.resetTeams();
},
}, {
role: 'togglefullscreen',
label: localizeMessage('main.menus.app.view.fullscreen', 'Toggle Full Screen'),
Expand Down
14 changes: 14 additions & 0 deletions src/main/preload/internalAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ import {
SERVERS_UPDATE,
VALIDATE_SERVER_URL,
GET_APP_INFO,
RESET_AUTH,
UPDATE_TEAMS,
} from 'common/communication';
import {IKOrigin} from 'common/config/ikConfig';

console.log('Preload initialized');

Expand Down Expand Up @@ -176,6 +179,17 @@ contextBridge.exposeInMainWorld('desktop', {
onFocusThreeDotMenu: (listener) => ipcRenderer.on(FOCUS_THREE_DOT_MENU, () => listener()),
updateURLViewWidth: (width) => ipcRenderer.send(UPDATE_URL_VIEW_WIDTH, width),

resetAuth: async () => {
await ipcRenderer.invoke(RESET_AUTH);
ipcRenderer.send(UPDATE_TEAMS, [{
name: '.',
url: IKOrigin,
order: 0,
tabs: [{name: 'TAB_MESSAGING', order: 0, isOpen: true}],
}]);
ipcRenderer.send(MODAL_CANCEL, {});
},

downloadsDropdown: {
toggleDownloadsDropdownMenu: (payload) => ipcRenderer.send(TOGGLE_DOWNLOADS_DROPDOWN_MENU, payload),
requestInfo: () => ipcRenderer.send(REQUEST_DOWNLOADS_DROPDOWN_INFO),
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/modals/welcomeScreen/welcomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const WelcomeScreenModalWrapper = () => {
}, []);

const onGetStarted = () => {
setGetStarted(true);
window.desktop.resetAuth();
};

return (
Expand Down

0 comments on commit 27b2d69

Please sign in to comment.