[MM-36459] Drag and drop for dropdown (#1651)

* [MM-36459] Drag and drop for dropdown

* CircleCI build

* Drag and drop feedback from UX

* PR feedback

* PR feedback
This commit is contained in:
Devin Binnie
2021-07-14 16:29:35 -04:00
committed by GitHub
parent 26ca8ccefc
commit e71c4ff9f0
13 changed files with 252 additions and 78 deletions

View File

@@ -58,6 +58,13 @@ export const updateUnreads = (serverName: string, unreads: boolean) => {
emitMentions(serverName);
};
export const updateBadge = () => {
const expired = anyExpired();
const mentions = totalMentions();
const unreads = anyUnreads();
emitBadge(expired, mentions, unreads);
};
export const getUnreads = (serverName: string) => {
return status.unreads.get(serverName) || false;
};

View File

@@ -64,7 +64,7 @@ function showBadge(sessionExpired: boolean, mentionCount: number, showUnreadBadg
export function setUnreadBadgeSetting(showUnreadBadge: boolean) {
showUnreadBadgeSetting = showUnreadBadge;
AppState.emitStatus();
AppState.updateBadge();
}
export function setupBadge() {

View File

@@ -13,6 +13,7 @@ import {
SWITCH_SERVER,
CLOSE_TEAMS_DROPDOWN,
SHOW_NEW_SERVER_MODAL,
UPDATE_TEAMS,
} from 'common/communication';
console.log('preloaded for the dropdown!');
@@ -34,12 +35,15 @@ window.addEventListener('message', async (event) => {
case CLOSE_TEAMS_DROPDOWN:
ipcRenderer.send(CLOSE_TEAMS_DROPDOWN);
break;
case UPDATE_TEAMS:
ipcRenderer.invoke(UPDATE_TEAMS, event.data.data);
break;
default:
console.log(`got a message: ${event}`);
console.log(event);
}
});
ipcRenderer.on(UPDATE_TEAMS_DROPDOWN, (event, teams, activeTeam, darkMode, expired, mentions, unreads) => {
window.postMessage({type: UPDATE_TEAMS_DROPDOWN, data: {teams, activeTeam, darkMode, expired, mentions, unreads}}, window.location.href);
ipcRenderer.on(UPDATE_TEAMS_DROPDOWN, (event, teams, activeTeam, darkMode, hasGPOTeams, expired, mentions, unreads) => {
window.postMessage({type: UPDATE_TEAMS_DROPDOWN, data: {teams, activeTeam, darkMode, hasGPOTeams, expired, mentions, unreads}}, window.location.href);
});

View File

@@ -25,6 +25,7 @@ export default class TeamDropdownView {
teams: Team[];
activeTeam?: string;
darkMode: boolean;
hasGPOTeams?: boolean;
unreads?: Map<string, boolean>;
mentions?: Map<string, number>;
expired?: Map<string, boolean>;
@@ -57,6 +58,7 @@ export default class TeamDropdownView {
updateConfig = (event: IpcMainEvent, config: CombinedConfig) => {
this.teams = config.teams;
this.darkMode = config.darkMode;
this.hasGPOTeams = config.registryTeams && config.registryTeams.length > 0;
this.updateDropdown();
}
@@ -73,7 +75,7 @@ export default class TeamDropdownView {
}
updateDropdown = () => {
this.view.webContents.send(UPDATE_TEAMS_DROPDOWN, this.teams, this.activeTeam, this.darkMode, this.expired, this.mentions, this.unreads);
this.view.webContents.send(UPDATE_TEAMS_DROPDOWN, this.teams, this.activeTeam, this.darkMode, this.hasGPOTeams, this.expired, this.mentions, this.unreads);
}
handleOpen = () => {