[MM-52919] Remove all uses of window.desktop.version from webapp (#23558)

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Devin Binnie
2023-06-01 12:44:27 -04:00
коммит произвёл GitHub
родитель a1614da6f8
Коммит 31c67fff4b
4 изменённых файлов: 19 добавлений и 37 удалений

Просмотреть файл

@@ -1,8 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import semver from 'semver';
import {logError} from 'mattermost-redux/actions/errors'; import {logError} from 'mattermost-redux/actions/errors';
import {getProfilesByIds} from 'mattermost-redux/actions/users'; import {getProfilesByIds} from 'mattermost-redux/actions/users';
import {getCurrentChannel, getMyChannelMember, makeGetChannel} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentChannel, getMyChannelMember, makeGetChannel} from 'mattermost-redux/selectors/entities/channels';
@@ -197,8 +195,8 @@ export function sendDesktopNotification(post, msgProps) {
} }
const notifyMe = (title, body, channel, teamId, silent, soundName, url) => (dispatch) => { const notifyMe = (title, body, channel, teamId, silent, soundName, url) => (dispatch) => {
// handle notifications in desktop app >= 4.3.0 // handle notifications in desktop app
if (isDesktopApp() && window.desktop && semver.gte(window.desktop.version, '4.3.0')) { if (isDesktopApp()) {
const msg = { const msg = {
title, title,
body, body,
@@ -206,16 +204,8 @@ const notifyMe = (title, body, channel, teamId, silent, soundName, url) => (disp
teamId, teamId,
silent, silent,
}; };
msg.data = {soundName};
if (isDesktopApp() && window.desktop) { msg.url = url;
if (semver.gte(window.desktop.version, '4.6.0')) {
msg.data = {soundName};
}
if (semver.gte(window.desktop.version, '4.7.2')) {
msg.url = url;
}
}
// get the desktop app to trigger the notification // get the desktop app to trigger the notification
window.postMessage( window.postMessage(

Просмотреть файл

@@ -164,6 +164,7 @@ export default class LoggedIn extends React.PureComponent<Props> {
} }
// listen for messages from the desktop app // listen for messages from the desktop app
// TODO: This needs to be deprecated in favour of a more solid Desktop App API.
private onDesktopMessageListener = (desktopMessage: DesktopMessage) => { private onDesktopMessageListener = (desktopMessage: DesktopMessage) => {
if (!this.props.currentUser) { if (!this.props.currentUser) {
return; return;
@@ -174,6 +175,7 @@ export default class LoggedIn extends React.PureComponent<Props> {
switch (desktopMessage.data.type) { switch (desktopMessage.data.type) {
case 'register-desktop': { case 'register-desktop': {
// Currently used by calls
const {version} = desktopMessage.data.message; const {version} = desktopMessage.data.message;
if (!window.desktop) { if (!window.desktop) {
window.desktop = {}; window.desktop = {};

Просмотреть файл

@@ -5,13 +5,10 @@ import React, {ChangeEvent, RefObject} from 'react';
import ReactSelect, {ValueType} from 'react-select'; import ReactSelect, {ValueType} from 'react-select';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import semver from 'semver';
import {NotificationLevels} from 'utils/constants'; import {NotificationLevels} from 'utils/constants';
import * as NotificationSounds from 'utils/notification_sounds'; import * as NotificationSounds from 'utils/notification_sounds';
import * as Utils from 'utils/utils'; import * as Utils from 'utils/utils';
import {t} from 'utils/i18n'; import {t} from 'utils/i18n';
import {isDesktopApp} from 'utils/user_agent';
import SettingItemMin from 'components/setting_item_min'; import SettingItemMin from 'components/setting_item_min';
import SettingItemMax from 'components/setting_item_max'; import SettingItemMax from 'components/setting_item_max';
@@ -129,20 +126,18 @@ export default class DesktopNotificationSettings extends React.PureComponent<Pro
return {value: sound, label: sound}; return {value: sound, label: sound};
}); });
if (!isDesktopApp() || (window.desktop && semver.gte(window.desktop.version || '', '4.6.0'))) { notificationSelection = (<div className='pt-2'>
notificationSelection = (<div className='pt-2'> <ReactSelect
<ReactSelect className='react-select notification-sound-dropdown'
className='react-select notification-sound-dropdown' classNamePrefix='react-select'
classNamePrefix='react-select' id='displaySoundNotification'
id='displaySoundNotification' options={options}
options={options} clearable={false}
clearable={false} onChange={this.setDesktopNotificationSound}
onChange={this.setDesktopNotificationSound} value={this.state.selectedOption}
value={this.state.selectedOption} isSearchable={false}
isSearchable={false} ref={this.dropdownSoundRef}
ref={this.dropdownSoundRef} /></div>);
/></div>);
}
} }
if (NotificationSounds.hasSoundOptions()) { if (NotificationSounds.hasSoundOptions()) {

Просмотреть файл

@@ -6,13 +6,10 @@
import React, {ChangeEvent, RefObject} from 'react'; import React, {ChangeEvent, RefObject} from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import semver from 'semver';
import {ActionResult} from 'mattermost-redux/types/actions'; import {ActionResult} from 'mattermost-redux/types/actions';
import Constants, {NotificationLevels} from 'utils/constants'; import Constants, {NotificationLevels} from 'utils/constants';
import {a11yFocus, localizeMessage, moveCursorToEnd} from 'utils/utils'; import {a11yFocus, localizeMessage, moveCursorToEnd} from 'utils/utils';
import {isDesktopApp} from 'utils/user_agent';
import {t} from 'utils/i18n'; import {t} from 'utils/i18n';
import SettingItem from 'components/setting_item'; import SettingItem from 'components/setting_item';
@@ -200,9 +197,7 @@ export default class NotificationsTab extends React.PureComponent<Props, State>
const data: UserNotifyProps = {} as UserNotifyProps; const data: UserNotifyProps = {} as UserNotifyProps;
data.email = this.state.enableEmail; data.email = this.state.enableEmail;
data.desktop_sound = this.state.desktopSound; data.desktop_sound = this.state.desktopSound;
if (!isDesktopApp() || (window.desktop && semver.gte(window.desktop.version || '', '4.6.0'))) { data.desktop_notification_sound = this.state.desktopNotificationSound;
data.desktop_notification_sound = this.state.desktopNotificationSound;
}
data.desktop = this.state.desktopActivity; data.desktop = this.state.desktopActivity;
data.desktop_threads = this.state.desktopThreads; data.desktop_threads = this.state.desktopThreads;
data.email_threads = this.state.emailThreads; data.email_threads = this.state.emailThreads;