feat: PiP mute indicator, export history, activity log, unverified device warning
- PiP call window: mute overlay using MutationObserver on EC iframe's [data-testid="incall_mute"] button (data-kind="primary" = muted), same pattern as screenshare detection in CallControl.ts - P2-4 Export Room History: new tab in room settings — Plain Text / JSON / HTML formats, optional date range, progress counter, paginated via paginateEventTimeline, blob download; E2EE-aware (skips failed decryptions) - P2-6 Room Activity Log: new tab in room settings — filterable log of m.room.member, m.room.power_levels, m.room.name/topic/avatar/server_acl events with human-readable descriptions, relative timestamps, Load More pagination - P2-10 Unverified Device Warning: warnOnUnverifiedDevices setting (default off); Warning.Container banner above composer in encrypted rooms with unverified devices; toggle in Settings → General → Privacy Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { CryptoApi } from 'matrix-js-sdk/lib/crypto-api';
|
||||
import { verifiedDevice } from '../utils/matrix-crypto';
|
||||
import { useAlive } from './useAlive';
|
||||
@@ -104,3 +105,62 @@ export const useUnverifiedDeviceCount = (
|
||||
|
||||
return unverifiedCount;
|
||||
};
|
||||
|
||||
export const useRoomUnverifiedDeviceCount = (
|
||||
crypto: CryptoApi | undefined,
|
||||
room: Room,
|
||||
): number | undefined => {
|
||||
const [unverifiedCount, setUnverifiedCount] = useState<number>();
|
||||
const alive = useAlive();
|
||||
|
||||
const memberIds = useMemo(
|
||||
() => room.getJoinedMembers().map((m) => m.userId),
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[room.roomId],
|
||||
);
|
||||
|
||||
const updateCount = useCallback(async () => {
|
||||
if (!crypto) return;
|
||||
|
||||
const deviceMap = await crypto.getUserDeviceInfo(memberIds);
|
||||
let count = 0;
|
||||
|
||||
const allChecks: Promise<boolean | null>[] = [];
|
||||
|
||||
deviceMap.forEach((devices, userId) => {
|
||||
devices.forEach((_device, deviceId) => {
|
||||
allChecks.push(verifiedDevice(crypto, userId, deviceId));
|
||||
});
|
||||
});
|
||||
|
||||
const results = await Promise.allSettled(allChecks);
|
||||
const settled = fulfilledPromiseSettledResult(results);
|
||||
settled.forEach((status) => {
|
||||
if (status === false) {
|
||||
count += 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (alive()) {
|
||||
setUnverifiedCount(count);
|
||||
}
|
||||
}, [crypto, memberIds, alive]);
|
||||
|
||||
useDeviceListChange(
|
||||
useCallback(
|
||||
(userIds) => {
|
||||
const affected = userIds.some((uid) => memberIds.includes(uid));
|
||||
if (affected) {
|
||||
updateCount();
|
||||
}
|
||||
},
|
||||
[memberIds, updateCount],
|
||||
),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
updateCount();
|
||||
}, [updateCount]);
|
||||
|
||||
return unverifiedCount;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user