Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Aug 16, 2024
1 parent 79fbacb commit fcde41c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
7 changes: 5 additions & 2 deletions scripts/apps/users/directives/UserPreferencesDirective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {appConfig, extensions, getUserInterfaceLanguage} from 'appConfig';
import {applyDefault} from 'core/helpers/typescript-helpers';
import {DEFAULT_EDITOR_THEME} from 'apps/authoring/authoring/services/AuthoringThemesService';
import {cloneDeep, pick} from 'lodash';
import {IExtensionActivationResult} from 'superdesk-api';
import {IExtensionActivationResult, IMultiChannelNotification} from 'superdesk-api';

/**
* @ngdoc directive
Expand Down Expand Up @@ -391,7 +391,10 @@ export function UserPreferencesDirective(
scope.preferences[NOTIFICATIONS_KEY] = {};
}

for (const [notificationId, notification] of Object.entries(registeredNotifications)) {
for (
const [notificationId, notification]
of Object.entries(registeredNotifications) as Array<[string, IMultiChannelNotification]>
) {
if (scope.preferences[NOTIFICATIONS_KEY][notificationId] == null) {
scope.preferences[NOTIFICATIONS_KEY][notificationId] = {
email: true,
Expand Down
10 changes: 5 additions & 5 deletions scripts/core/menu/notifications/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash';
import {gettext} from 'core/utils';
import {AuthoringWorkspaceService} from 'apps/authoring/authoring/services/AuthoringWorkspaceService';
import {extensions} from 'appConfig';
import {IExtensionActivationResult} from 'superdesk-api';
import {IMultiChannelNotification} from 'superdesk-api';
import {logger} from 'core/services/logger';
import emptyState from 'superdesk-ui-framework/dist/empty-state--small-2.svg';

Expand Down Expand Up @@ -296,12 +296,12 @@ angular.module('superdesk.core.menu.notifications', ['superdesk.core.services.as
scope.emptyState = emptyState;

// merged from all extensions
const notificationsKeyed: {
[key: string]: IExtensionActivationResult['contributions']['notifications'][0]['handler']
} = {};
const notificationsKeyed: {[key: string]: IMultiChannelNotification['handler']} = {};

for (const extension of Object.values(extensions)) {
const notificationsFromExtensions = extension.activationResult.contributions?.notifications;
const notificationsFromExtensions = extension
.activationResult
.contributions?.notifications as {[key: string]: IMultiChannelNotification};

if (notificationsFromExtensions != null) {
for (const key in notificationsFromExtensions) {
Expand Down
22 changes: 11 additions & 11 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,16 +706,14 @@ declare module 'superdesk-api' {
}

/**
* @deprecated This interface is deprecated and will be removed in future versions.
* Use the `name, handler` one
* @deprecated This interface is deprecated and will be removed in future versions. Use IMultiChannelNotification
*/
interface IEmailNotification {
type: 'email';
}

/**
* @deprecated This interface is deprecated and will be removed in future versions.
* Use the `name, handler` one
* @deprecated This interface is deprecated and will be removed in future versions. Use IMultiChannelNotification
*/
interface IDesktopNotification {
type: 'desktop';
Expand All @@ -726,6 +724,14 @@ declare module 'superdesk-api' {
};
}

interface IMultiChannelNotification {
name: string;
handler?: (notification: any) => {
body: string;
actions: Array<{label: string; onClick: () => void;}>;
};
}

export interface IExtensionActivationResult {
contributions?: {
globalMenuHorizontal?: Array<React.ComponentType>;
Expand Down Expand Up @@ -764,13 +770,7 @@ declare module 'superdesk-api' {
workspaceMenuItems?: Array<IWorkspaceMenuItem>;
customFieldTypes?: Array<ICustomFieldType>;
notifications?: {
[id: string]: IDesktopNotification | IEmailNotification | {
name: string;
handler?: (notification: any) => {
body: string;
actions: Array<{label: string; onClick: () => void;}>;
};
};
[id: string]: IDesktopNotification | IEmailNotification | IMultiChannelNotification;
};
entities?: {
article?: {
Expand Down

0 comments on commit fcde41c

Please sign in to comment.