Skip to content

Commit

Permalink
removing more teams-v1 redundant logic
Browse files Browse the repository at this point in the history
  • Loading branch information
IsmaelMartinez committed Feb 7, 2025
1 parent e53702e commit 20af388
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 459 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ body:
- type: dropdown
id: can-reproduce-pwa
attributes:
label: Can you reproduce this bug in the PWA?
description: "If you can reproduce the bug in the PWA, it's likely a bug in the web app. Please report it to Microsoft instead"
label: Can you reproduce this bug in the PWA/Website?
description: "If you can reproduce the bug in the PWA/Website, it's likely a bug in the web app. Please report it to Microsoft instead"
options:
- "Yes"
- "No"
Expand Down
2 changes: 0 additions & 2 deletions app/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
initializeModules(config, ipcRenderer);

new ActivityManager(ipcRenderer, config).start();

});

Object.defineProperty(navigator.serviceWorker, 'register', {
Expand Down Expand Up @@ -67,7 +66,6 @@ function initializeModules(config, ipcRenderer) {
require('./tools/trayIconRenderer').init(config, ipcRenderer);
}
require('./tools/settings').init(config, ipcRenderer);
require('./tools/customBackgrounds')(config, ipcRenderer);
require('./tools/theme').init(config, ipcRenderer);
require('./tools/emulatePlatform').init(config);
}
2 changes: 0 additions & 2 deletions app/browser/notifications/activityManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class ActivityManager {
start() {
setActivityHandlers(this);
setEventHandlers(this);
activityHub.start();
activityHub.setDefaultTitle(this.config.appTitle);
this.watchSystemIdleState();
}

Expand Down
248 changes: 0 additions & 248 deletions app/browser/tools/activityHub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const instance = require('./instance');
const ReactHandler = require('./reactHandler');
const eventHandlers = [];

Expand All @@ -23,20 +22,6 @@ class ActivityHub {
return removeEventHandler(event, handle);
}

start() {
instance.whenReady().then(assignEventHandlers).catch(() => {
console.error('Failed to start Activity Hub by assigning Event Handlers');
});
}

setDefaultTitle(title) {
instance.whenReady().then(inst => {
inst.controller.pageTitleDefault = title;
}).catch(() => {
console.error('Failed to set Default Title');
});
}

setMachineState(state) {
const teams2IdleTracker = ReactHandler.getTeams2IdleTracker();
if (teams2IdleTracker) {
Expand All @@ -50,16 +35,6 @@ class ActivityHub {
} catch (e) {
console.error('Failed to set teams2 Machine State', e);
}
} else {
instance.whenReady().then((inst) => {
if (state === 1) {
this.refreshAppState(inst.controller, state);
} else {
inst.controller.appStateService.setMachineState(state);
}
}).catch(() => {
console.error('Failed to set Machine State');
});
}
}

Expand All @@ -76,12 +51,6 @@ class ActivityHub {
} catch (e) {
console.error('Failed to set teams2 User Status', e);
}
} else {
instance.whenReady().then((inst) => {
inst.injector.get('presenceService').setMyStatus(status, null, true);
}).catch(() => {
console.error('Failed to set User Status');
});
}
}

Expand Down Expand Up @@ -135,222 +104,5 @@ function removeEventHandler(event, handle) {
return null;
}

function getEventHandlers(event) {
return eventHandlers.filter(e => {
return e.event === event;
});
}

function assignEventHandlers(inst) {
assignActivitiesCountUpdateHandler(inst.controller);
assignIncomingCallCreatedHandler(inst.controller);
assignIncomingCallConnectingHandler(inst.controller);
assignIncomingCallDisconnectingHandler(inst.controller);
assignCallConnectedHandler(inst.controller);
assignCallDisconnectedHandler(inst.controller);
assignWorkerMessagingUpdatesHandler(inst.controller);
assignMyStatusChangedHandler(inst.controller);
performPlatformTweaks(inst.controller);
}

function performPlatformTweaks(controller) {
const isRunningOnWindows = process.platform === 'win32' || process.platform === 'linux';
controller.callingService.callingAlertsService.isRunningOnWindows = () => isRunningOnWindows;
}

function getMeetingEvents(data) {
return data.filter(d => {
return d.messagetype === 'Event/Call' && d.content === '<partlist alt =""></partlist>';
});
}

async function getActiveCaledarEvents(controller) {
await refreshCalendarEvents(controller);
const calendarEvents = controller.calendarService.getCachedEvents();
const rightNow = new Date();
return calendarEvents.filter(ce => {
return new Date(ce.endTime) - rightNow > 0;
});
}


async function refreshCalendarEvents(controller) {
const c = controller.calendarService.refreshCalendarEvents();
do {
await new Promise(r => setTimeout(r, 1000));
} while (c.$$state.status == 0);
return c.$$state.status;
}

async function getActiveMeetingEvents(controller, data) {
const workerEvents = getMeetingEvents(data);
if (workerEvents.length > 0) {
const calendarEvents = await getActiveCaledarEvents(controller);
return getMeetingNotificationList(workerEvents, calendarEvents);
} else {
return [];
}
}

function getMeetingNotificationList(workerEvents, calendarEvents) {
const notificationList = [];
for (const we of workerEvents) {
const meetingId = we.conversationLink.split('/')[1].split(';')[0];
addEligibleCalendarEvents(calendarEvents, meetingId, notificationList);
}
return notificationList;
}

function addEligibleCalendarEvents(calendarEvents, meetingId, notificationList) {
for (const ce of calendarEvents) {
if (ce.skypeTeamsData && JSON.parse(ce.skypeTeamsData).cid === meetingId) {
notificationList.push(ce);
break;
}
}
}

function assignActivitiesCountUpdateHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.notifications.bellCountUpdated,
() => onActivitiesCountUpdated(controller));

controller.chatListService.safeSubscribe(
controller.$scope,
() => onActivitiesCountUpdated(controller),
window.teamspace.services.ChatListServiceEvents.EventType_UnreadCount);
onActivitiesCountUpdated(controller);
}

function assignIncomingCallCreatedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callCreated,
(e, data) => {
if (data.signalingSession.isIncomingCall) {
onIncomingCallCreated({ caller: data.signalingSession.remoteCaller.displayName });
}
});
}

function assignIncomingCallConnectingHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callConnecting,
(e, data) => {
if (data.signalingSession.isIncomingCall) {
onIncomingCallConnecting();
}
});
}

function assignIncomingCallDisconnectingHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callDisconnecting,
(e, data) => {
if (data.signalingSession.isIncomingCall) {
onIncomingCallDisconnecting();
}
});
}

function assignCallConnectedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callConnected,
() => onCallConnected());
}

function assignCallDisconnectedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.calling.callDisposed,
() => onCallDisconnected());
}

function assignWorkerMessagingUpdatesHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.workerMessagingUpdates.messageUpdatesFromWorker,
(event, data) => onMessageUpdatesFromWorker(controller, data));
}

function assignMyStatusChangedHandler(controller) {
controller.eventingService.$on(
controller.$scope,
controller.constants.events.presence.myStatusChanged,
(event, data) => onMyStatusChanged(controller, data));
}

async function onActivitiesCountUpdated(controller) {
const count = controller.bellNotificationsService.getNewActivitiesCount() + controller.chatListService.getUnreadCountFromChatList();
const handlers = getEventHandlers('activities-count-updated');
for (const handler of handlers) {
handler.handler({ count: count });
}
}

async function onIncomingCallCreated(data) {
const handlers = getEventHandlers('incoming-call-created');
for (const handler of handlers) {
handler.handler(data);
}
}

async function onIncomingCallConnecting() {
const handlers = getEventHandlers('incoming-call-connecting');
for (const handler of handlers) {
handler.handler({});
}
}

async function onIncomingCallDisconnecting() {
const handlers = getEventHandlers('incoming-call-disconnecting');
for (const handler of handlers) {
handler.handler({});
}
}

async function onCallConnected() {
const handlers = getEventHandlers('call-connected');
for (const handler of handlers) {
handler.handler({});
}
}

async function onCallDisconnected() {
const handlers = getEventHandlers('call-disconnected');
for (const handler of handlers) {
handler.handler({});
}
}

async function onMessageUpdatesFromWorker(controller, data) {
if (Array.isArray(data)) {
const handlers = getEventHandlers('meeting-started');
const events = await getActiveMeetingEvents(controller, data);
for (const e of events) {
callMeetingStartedEventHandlers(handlers, e);
}
}
}

function callMeetingStartedEventHandlers(handlers, e) {
for (const handler of handlers) {
handler.handler({
title: e.subject
});
}
}

async function onMyStatusChanged(controller, data) {
const handlers = getEventHandlers('my-status-changed');
for (const handler of handlers) {
handler.handler({ data: data, isInactive: window.teamspace.services.ApplicationState[controller.appStateService.current] === 'Inactive' || window.teamspace.services.ApplicationState[controller.appStateService.current] === 'LongInactive' });
}
}

const activityHub = new ActivityHub();
module.exports = activityHub;
31 changes: 0 additions & 31 deletions app/browser/tools/customBackgrounds.js

This file was deleted.

32 changes: 0 additions & 32 deletions app/browser/tools/instance.js

This file was deleted.

Loading

0 comments on commit 20af388

Please sign in to comment.