This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 819
Implement push notification toggle in device detail #9308
Merged
Merged
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5a9b919
Create push notifications UI in session tile
1fa1c75
Implement push notification toggle in device detail
2176d2f
Fix missing props
9f8e93b
Move supportsMSC3881 logic in hook to keep component stateless
d271173
Add device details tests
0e5a90a
Merge branch 'develop' into gsouquet/pusher-ui-psg-708
297b9f0
remove useless context providers
909e3eb
Update comment indentation
1785092
Fix typo
38983ed
Fix test name
1e417b2
Use optional props rather than null
5c4cc23
Update incorrect getPusherForDevice return type
d97e579
PR fixes
45ee44f
add test for pusher enabled
a22f478
Add tests
f2da65c
fix i18n
d3b454d
Add test for the pusher state
d9a9378
Remove "only"
73cef6d
Merge branch 'develop' into gsouquet/pusher-ui-psg-708
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,6 +15,8 @@ limitations under the License. | |||||||||||||
*/ | ||||||||||||||
|
||||||||||||||
import React, { ForwardedRef, forwardRef } from 'react'; | ||||||||||||||
import { IPusher } from 'matrix-js-sdk/src/@types/PushRules'; | ||||||||||||||
import { PUSHER_DEVICE_ID } from 'matrix-js-sdk/src/@types/event'; | ||||||||||||||
|
||||||||||||||
import { _t } from '../../../../languageHandler'; | ||||||||||||||
import AccessibleButton from '../../elements/AccessibleButton'; | ||||||||||||||
|
@@ -36,6 +38,7 @@ import { DevicesState } from './useOwnDevices'; | |||||||||||||
|
||||||||||||||
interface Props { | ||||||||||||||
devices: DevicesDictionary; | ||||||||||||||
pushers: IPusher[]; | ||||||||||||||
expandedDeviceIds: DeviceWithVerification['device_id'][]; | ||||||||||||||
signingOutDeviceIds: DeviceWithVerification['device_id'][]; | ||||||||||||||
filter?: DeviceSecurityVariation; | ||||||||||||||
|
@@ -44,6 +47,8 @@ interface Props { | |||||||||||||
onSignOutDevices: (deviceIds: DeviceWithVerification['device_id'][]) => void; | ||||||||||||||
saveDeviceName: DevicesState['saveDeviceName']; | ||||||||||||||
onRequestDeviceVerification?: (deviceId: DeviceWithVerification['device_id']) => void; | ||||||||||||||
setPusherEnabled: (deviceId: string, enabled: boolean) => Promise<void>; | ||||||||||||||
supportsMSC3881: boolean | null; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// devices without timestamp metadata should be sorted last | ||||||||||||||
|
@@ -135,20 +140,26 @@ const NoResults: React.FC<NoResultsProps> = ({ filter, clearFilter }) => | |||||||||||||
|
||||||||||||||
const DeviceListItem: React.FC<{ | ||||||||||||||
device: DeviceWithVerification; | ||||||||||||||
pusher: IPusher | null; | ||||||||||||||
isExpanded: boolean; | ||||||||||||||
isSigningOut: boolean; | ||||||||||||||
onDeviceExpandToggle: () => void; | ||||||||||||||
onSignOutDevice: () => void; | ||||||||||||||
saveDeviceName: (deviceName: string) => Promise<void>; | ||||||||||||||
onRequestDeviceVerification?: () => void; | ||||||||||||||
setPusherEnabled: (deviceId: string, enabled: boolean) => Promise<void>; | ||||||||||||||
supportsMSC3881: boolean | null; | ||||||||||||||
}> = ({ | ||||||||||||||
device, | ||||||||||||||
pusher, | ||||||||||||||
isExpanded, | ||||||||||||||
isSigningOut, | ||||||||||||||
onDeviceExpandToggle, | ||||||||||||||
onSignOutDevice, | ||||||||||||||
saveDeviceName, | ||||||||||||||
onRequestDeviceVerification, | ||||||||||||||
setPusherEnabled, | ||||||||||||||
supportsMSC3881, | ||||||||||||||
}) => <li className='mx_FilteredDeviceList_listItem'> | ||||||||||||||
<DeviceTile | ||||||||||||||
device={device} | ||||||||||||||
|
@@ -162,10 +173,13 @@ const DeviceListItem: React.FC<{ | |||||||||||||
isExpanded && | ||||||||||||||
<DeviceDetails | ||||||||||||||
device={device} | ||||||||||||||
pusher={pusher} | ||||||||||||||
isSigningOut={isSigningOut} | ||||||||||||||
onVerifyDevice={onRequestDeviceVerification} | ||||||||||||||
onSignOutDevice={onSignOutDevice} | ||||||||||||||
saveDeviceName={saveDeviceName} | ||||||||||||||
setPusherEnabled={setPusherEnabled} | ||||||||||||||
supportsMSC3881={supportsMSC3881} | ||||||||||||||
/> | ||||||||||||||
} | ||||||||||||||
</li>; | ||||||||||||||
|
@@ -177,6 +191,7 @@ const DeviceListItem: React.FC<{ | |||||||||||||
export const FilteredDeviceList = | ||||||||||||||
forwardRef(({ | ||||||||||||||
devices, | ||||||||||||||
pushers, | ||||||||||||||
filter, | ||||||||||||||
expandedDeviceIds, | ||||||||||||||
signingOutDeviceIds, | ||||||||||||||
|
@@ -185,9 +200,15 @@ export const FilteredDeviceList = | |||||||||||||
saveDeviceName, | ||||||||||||||
onSignOutDevices, | ||||||||||||||
onRequestDeviceVerification, | ||||||||||||||
setPusherEnabled, | ||||||||||||||
supportsMSC3881, | ||||||||||||||
}: Props, ref: ForwardedRef<HTMLDivElement>) => { | ||||||||||||||
const sortedDevices = getFilteredSortedDevices(devices, filter); | ||||||||||||||
|
||||||||||||||
function getPusherForDevice(device: DeviceWithVerification): IPusher | null { | ||||||||||||||
germain-gg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
return pushers.find(pusher => pusher[PUSHER_DEVICE_ID.name] === device.device_id); | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm paranoid about scope changing randomly on us There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand the rationale behind this change. |
||||||||||||||
|
||||||||||||||
const options: FilterDropdownOption<DeviceFilterKey>[] = [ | ||||||||||||||
{ id: ALL_FILTER_ID, label: _t('All') }, | ||||||||||||||
{ | ||||||||||||||
|
@@ -236,6 +257,7 @@ export const FilteredDeviceList = | |||||||||||||
{ sortedDevices.map((device) => <DeviceListItem | ||||||||||||||
key={device.device_id} | ||||||||||||||
device={device} | ||||||||||||||
pusher={getPusherForDevice(device)} | ||||||||||||||
isExpanded={expandedDeviceIds.includes(device.device_id)} | ||||||||||||||
isSigningOut={signingOutDeviceIds.includes(device.device_id)} | ||||||||||||||
onDeviceExpandToggle={() => onDeviceExpandToggle(device.device_id)} | ||||||||||||||
|
@@ -246,6 +268,8 @@ export const FilteredDeviceList = | |||||||||||||
? () => onRequestDeviceVerification(device.device_id) | ||||||||||||||
: undefined | ||||||||||||||
} | ||||||||||||||
setPusherEnabled={setPusherEnabled} | ||||||||||||||
supportsMSC3881={supportsMSC3881} | ||||||||||||||
/>, | ||||||||||||||
) } | ||||||||||||||
</ol> | ||||||||||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.