mirror of
				https://github.com/cinnyapp/cinny.git
				synced 2025-11-04 06:20:28 +03:00 
			
		
		
		
	Improve-auth-media (#1933)
* fix set power level broken after sdk update * add media authentication hook * fix service worker types * fix service worker not working in dev mode * fix env mode check when registering sw
This commit is contained in:
		
							parent
							
								
									4dfce32730
								
							
						
					
					
						commit
						96df140153
					
				
					 38 changed files with 100 additions and 124 deletions
				
			
		
							
								
								
									
										11
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										11
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -79,7 +79,6 @@
 | 
				
			||||||
        "@types/react-dom": "18.2.17",
 | 
					        "@types/react-dom": "18.2.17",
 | 
				
			||||||
        "@types/react-google-recaptcha": "2.1.8",
 | 
					        "@types/react-google-recaptcha": "2.1.8",
 | 
				
			||||||
        "@types/sanitize-html": "2.9.0",
 | 
					        "@types/sanitize-html": "2.9.0",
 | 
				
			||||||
        "@types/serviceworker": "0.0.95",
 | 
					 | 
				
			||||||
        "@types/ua-parser-js": "0.7.36",
 | 
					        "@types/ua-parser-js": "0.7.36",
 | 
				
			||||||
        "@typescript-eslint/eslint-plugin": "5.46.1",
 | 
					        "@typescript-eslint/eslint-plugin": "5.46.1",
 | 
				
			||||||
        "@typescript-eslint/parser": "5.46.1",
 | 
					        "@typescript-eslint/parser": "5.46.1",
 | 
				
			||||||
| 
						 | 
					@ -5036,13 +5035,6 @@
 | 
				
			||||||
      "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==",
 | 
					      "integrity": "sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==",
 | 
				
			||||||
      "dev": true
 | 
					      "dev": true
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@types/serviceworker": {
 | 
					 | 
				
			||||||
      "version": "0.0.95",
 | 
					 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@types/serviceworker/-/serviceworker-0.0.95.tgz",
 | 
					 | 
				
			||||||
      "integrity": "sha512-Zw7kLIehLvaXf/9RnxAUiYyHmYC5pfvIJD3b1uSPkZGzp+OVmXgmPzVW5fbhYHKcqkeGzsv89uGm+JmMCAPa8Q==",
 | 
					 | 
				
			||||||
      "dev": true,
 | 
					 | 
				
			||||||
      "license": "Apache-2.0"
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "node_modules/@types/trusted-types": {
 | 
					    "node_modules/@types/trusted-types": {
 | 
				
			||||||
      "version": "2.0.7",
 | 
					      "version": "2.0.7",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
 | 
				
			||||||
| 
						 | 
					@ -11514,7 +11506,6 @@
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.20.5.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.20.5.tgz",
 | 
				
			||||||
      "integrity": "sha512-aweuI/6G6n4C5Inn0vwHumElU/UEpNuO+9iZzwPZGTCH87TeZ6YFMrEY6ZUBQdIHHlhTsbMDryFARcSuOdsz9Q==",
 | 
					      "integrity": "sha512-aweuI/6G6n4C5Inn0vwHumElU/UEpNuO+9iZzwPZGTCH87TeZ6YFMrEY6ZUBQdIHHlhTsbMDryFARcSuOdsz9Q==",
 | 
				
			||||||
      "dev": true,
 | 
					      "dev": true,
 | 
				
			||||||
      "license": "MIT",
 | 
					 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "debug": "^4.3.6",
 | 
					        "debug": "^4.3.6",
 | 
				
			||||||
        "pretty-bytes": "^6.1.1",
 | 
					        "pretty-bytes": "^6.1.1",
 | 
				
			||||||
| 
						 | 
					@ -12446,4 +12437,4 @@
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,7 +90,6 @@
 | 
				
			||||||
    "@types/react-dom": "18.2.17",
 | 
					    "@types/react-dom": "18.2.17",
 | 
				
			||||||
    "@types/react-google-recaptcha": "2.1.8",
 | 
					    "@types/react-google-recaptcha": "2.1.8",
 | 
				
			||||||
    "@types/sanitize-html": "2.9.0",
 | 
					    "@types/sanitize-html": "2.9.0",
 | 
				
			||||||
    "@types/serviceworker": "0.0.95",
 | 
					 | 
				
			||||||
    "@types/ua-parser-js": "0.7.36",
 | 
					    "@types/ua-parser-js": "0.7.36",
 | 
				
			||||||
    "@typescript-eslint/eslint-plugin": "5.46.1",
 | 
					    "@typescript-eslint/eslint-plugin": "5.46.1",
 | 
				
			||||||
    "@typescript-eslint/parser": "5.46.1",
 | 
					    "@typescript-eslint/parser": "5.46.1",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ import { useMatrixClient } from '../../hooks/useMatrixClient';
 | 
				
			||||||
import { getBeginCommand } from './utils';
 | 
					import { getBeginCommand } from './utils';
 | 
				
			||||||
import { BlockType } from './types';
 | 
					import { BlockType } from './types';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Put this at the start and end of an inline component to work around this Chromium bug:
 | 
					// Put this at the start and end of an inline component to work around this Chromium bug:
 | 
				
			||||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=1249405
 | 
					// https://bugs.chromium.org/p/chromium/issues/detail?id=1249405
 | 
				
			||||||
| 
						 | 
					@ -78,8 +78,7 @@ function RenderEmoticonElement({
 | 
				
			||||||
  children,
 | 
					  children,
 | 
				
			||||||
}: { element: EmoticonElement } & RenderElementProps) {
 | 
					}: { element: EmoticonElement } & RenderElementProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const selected = useSelected();
 | 
					  const selected = useSelected();
 | 
				
			||||||
  const focused = useFocused();
 | 
					  const focused = useFocused();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ import { IEmoji, emojis } from '../../../plugins/emoji';
 | 
				
			||||||
import { ExtendedPackImage, PackUsage } from '../../../plugins/custom-emoji';
 | 
					import { ExtendedPackImage, PackUsage } from '../../../plugins/custom-emoji';
 | 
				
			||||||
import { useKeyDown } from '../../../hooks/useKeyDown';
 | 
					import { useKeyDown } from '../../../hooks/useKeyDown';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type EmoticonCompleteHandler = (key: string, shortcode: string) => void;
 | 
					type EmoticonCompleteHandler = (key: string, shortcode: string) => void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,8 +50,7 @@ export function EmoticonAutocomplete({
 | 
				
			||||||
  requestClose,
 | 
					  requestClose,
 | 
				
			||||||
}: EmoticonAutocompleteProps) {
 | 
					}: EmoticonAutocompleteProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const imagePacks = useRelevantImagePacks(mx, PackUsage.Emoticon, imagePackRooms);
 | 
					  const imagePacks = useRelevantImagePacks(mx, PackUsage.Emoticon, imagePackRooms);
 | 
				
			||||||
  const recentEmoji = useRecentEmoji(mx, 20);
 | 
					  const recentEmoji = useRecentEmoji(mx, 20);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ import { useKeyDown } from '../../../hooks/useKeyDown';
 | 
				
			||||||
import { getMxIdLocalPart, getMxIdServer, validMxId } from '../../../utils/matrix';
 | 
					import { getMxIdLocalPart, getMxIdServer, validMxId } from '../../../utils/matrix';
 | 
				
			||||||
import { getMemberDisplayName, getMemberSearchStr } from '../../../utils/room';
 | 
					import { getMemberDisplayName, getMemberSearchStr } from '../../../utils/room';
 | 
				
			||||||
import { UserAvatar } from '../../user-avatar';
 | 
					import { UserAvatar } from '../../user-avatar';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type MentionAutoCompleteHandler = (userId: string, name: string) => void;
 | 
					type MentionAutoCompleteHandler = (userId: string, name: string) => void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -85,8 +85,7 @@ export function UserMentionAutocomplete({
 | 
				
			||||||
  requestClose,
 | 
					  requestClose,
 | 
				
			||||||
}: UserMentionAutocompleteProps) {
 | 
					}: UserMentionAutocompleteProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const roomId: string = room.roomId!;
 | 
					  const roomId: string = room.roomId!;
 | 
				
			||||||
  const roomAliasOrId = room.getCanonicalAlias() || roomId;
 | 
					  const roomAliasOrId = room.getCanonicalAlias() || roomId;
 | 
				
			||||||
  const members = useRoomMembers(mx, roomId);
 | 
					  const members = useRoomMembers(mx, roomId);
 | 
				
			||||||
| 
						 | 
					@ -147,7 +146,9 @@ export function UserMentionAutocomplete({
 | 
				
			||||||
      ) : (
 | 
					      ) : (
 | 
				
			||||||
        autoCompleteMembers.map((roomMember) => {
 | 
					        autoCompleteMembers.map((roomMember) => {
 | 
				
			||||||
          const avatarMxcUrl = roomMember.getMxcAvatarUrl();
 | 
					          const avatarMxcUrl = roomMember.getMxcAvatarUrl();
 | 
				
			||||||
          const avatarUrl = avatarMxcUrl ? mx.mxcUrlToHttp(avatarMxcUrl, 32, 32, 'crop', undefined, false, useAuthentication) : undefined;
 | 
					          const avatarUrl = avatarMxcUrl
 | 
				
			||||||
 | 
					            ? mx.mxcUrlToHttp(avatarMxcUrl, 32, 32, 'crop', undefined, false, useAuthentication)
 | 
				
			||||||
 | 
					            : undefined;
 | 
				
			||||||
          return (
 | 
					          return (
 | 
				
			||||||
            <MenuItem
 | 
					            <MenuItem
 | 
				
			||||||
              key={roomMember.userId}
 | 
					              key={roomMember.userId}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ import { useDebounce } from '../../hooks/useDebounce';
 | 
				
			||||||
import { useThrottle } from '../../hooks/useThrottle';
 | 
					import { useThrottle } from '../../hooks/useThrottle';
 | 
				
			||||||
import { addRecentEmoji } from '../../plugins/recent-emoji';
 | 
					import { addRecentEmoji } from '../../plugins/recent-emoji';
 | 
				
			||||||
import { mobileOrTablet } from '../../utils/user-agent';
 | 
					import { mobileOrTablet } from '../../utils/user-agent';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const RECENT_GROUP_ID = 'recent_group';
 | 
					const RECENT_GROUP_ID = 'recent_group';
 | 
				
			||||||
const SEARCH_GROUP_ID = 'search_group';
 | 
					const SEARCH_GROUP_ID = 'search_group';
 | 
				
			||||||
| 
						 | 
					@ -650,8 +650,7 @@ export function EmojiBoard({
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const setActiveGroupId = useSetAtom(activeGroupIdAtom);
 | 
					  const setActiveGroupId = useSetAtom(activeGroupIdAtom);
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const emojiGroupLabels = useEmojiGroupLabels();
 | 
					  const emojiGroupLabels = useEmojiGroupLabels();
 | 
				
			||||||
  const emojiGroupIcons = useEmojiGroupIcons();
 | 
					  const emojiGroupIcons = useEmojiGroupIcons();
 | 
				
			||||||
  const imagePacks = useRelevantImagePacks(mx, usage, imagePackRooms);
 | 
					  const imagePacks = useRelevantImagePacks(mx, usage, imagePackRooms);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,7 @@ import * as css from './EventReaders.css';
 | 
				
			||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
 | 
					import { useMatrixClient } from '../../hooks/useMatrixClient';
 | 
				
			||||||
import { openProfileViewer } from '../../../client/action/navigation';
 | 
					import { openProfileViewer } from '../../../client/action/navigation';
 | 
				
			||||||
import { UserAvatar } from '../user-avatar';
 | 
					import { UserAvatar } from '../user-avatar';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type EventReadersProps = {
 | 
					export type EventReadersProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -31,8 +31,7 @@ export type EventReadersProps = {
 | 
				
			||||||
export const EventReaders = as<'div', EventReadersProps>(
 | 
					export const EventReaders = as<'div', EventReadersProps>(
 | 
				
			||||||
  ({ className, room, eventId, requestClose, ...props }, ref) => {
 | 
					  ({ className, room, eventId, requestClose, ...props }, ref) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const latestEventReaders = useRoomEventReaders(room, eventId);
 | 
					    const latestEventReaders = useRoomEventReaders(room, eventId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const getName = (userId: string) =>
 | 
					    const getName = (userId: string) =>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ import {
 | 
				
			||||||
import { useThrottle } from '../../../hooks/useThrottle';
 | 
					import { useThrottle } from '../../../hooks/useThrottle';
 | 
				
			||||||
import { secondsToMinutesAndSeconds } from '../../../utils/common';
 | 
					import { secondsToMinutesAndSeconds } from '../../../utils/common';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const PLAY_TIME_THROTTLE_OPS = {
 | 
					const PLAY_TIME_THROTTLE_OPS = {
 | 
				
			||||||
  wait: 500,
 | 
					  wait: 500,
 | 
				
			||||||
| 
						 | 
					@ -46,8 +46,7 @@ export function AudioContent({
 | 
				
			||||||
  renderMediaControl,
 | 
					  renderMediaControl,
 | 
				
			||||||
}: AudioContentProps) {
 | 
					}: AudioContentProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [srcState, loadSrc] = useAsyncCallback(
 | 
					  const [srcState, loadSrc] = useAsyncCallback(
 | 
				
			||||||
    useCallback(
 | 
					    useCallback(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ import {
 | 
				
			||||||
import * as css from './style.css';
 | 
					import * as css from './style.css';
 | 
				
			||||||
import { stopPropagation } from '../../../utils/keyboard';
 | 
					import { stopPropagation } from '../../../utils/keyboard';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const renderErrorButton = (retry: () => void, text: string) => (
 | 
					const renderErrorButton = (retry: () => void, text: string) => (
 | 
				
			||||||
  <TooltipProvider
 | 
					  <TooltipProvider
 | 
				
			||||||
| 
						 | 
					@ -77,8 +77,7 @@ type ReadTextFileProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function ReadTextFile({ body, mimeType, url, encInfo, renderViewer }: ReadTextFileProps) {
 | 
					export function ReadTextFile({ body, mimeType, url, encInfo, renderViewer }: ReadTextFileProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const [textViewer, setTextViewer] = useState(false);
 | 
					  const [textViewer, setTextViewer] = useState(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const loadSrc = useCallback(
 | 
					  const loadSrc = useCallback(
 | 
				
			||||||
| 
						 | 
					@ -170,8 +169,7 @@ export type ReadPdfFileProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function ReadPdfFile({ body, mimeType, url, encInfo, renderViewer }: ReadPdfFileProps) {
 | 
					export function ReadPdfFile({ body, mimeType, url, encInfo, renderViewer }: ReadPdfFileProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const [pdfViewer, setPdfViewer] = useState(false);
 | 
					  const [pdfViewer, setPdfViewer] = useState(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [pdfState, loadPdf] = useAsyncCallback(
 | 
					  const [pdfState, loadPdf] = useAsyncCallback(
 | 
				
			||||||
| 
						 | 
					@ -246,8 +244,7 @@ export type DownloadFileProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function DownloadFile({ body, mimeType, url, info, encInfo }: DownloadFileProps) {
 | 
					export function DownloadFile({ body, mimeType, url, info, encInfo }: DownloadFileProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [downloadState, download] = useAsyncCallback(
 | 
					  const [downloadState, download] = useAsyncCallback(
 | 
				
			||||||
    useCallback(async () => {
 | 
					    useCallback(async () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ import { bytesToSize } from '../../../utils/common';
 | 
				
			||||||
import { FALLBACK_MIMETYPE } from '../../../utils/mimeTypes';
 | 
					import { FALLBACK_MIMETYPE } from '../../../utils/mimeTypes';
 | 
				
			||||||
import { stopPropagation } from '../../../utils/keyboard';
 | 
					import { stopPropagation } from '../../../utils/keyboard';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RenderViewerProps = {
 | 
					type RenderViewerProps = {
 | 
				
			||||||
  src: string;
 | 
					  src: string;
 | 
				
			||||||
| 
						 | 
					@ -71,8 +71,7 @@ export const ImageContent = as<'div', ImageContentProps>(
 | 
				
			||||||
    ref
 | 
					    ref
 | 
				
			||||||
  ) => {
 | 
					  ) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const blurHash = info?.[MATRIX_BLUR_HASH_PROPERTY_NAME];
 | 
					    const blurHash = info?.[MATRIX_BLUR_HASH_PROPERTY_NAME];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [load, setLoad] = useState(false);
 | 
					    const [load, setLoad] = useState(false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@ import { useMatrixClient } from '../../../hooks/useMatrixClient';
 | 
				
			||||||
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
 | 
					import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
 | 
				
			||||||
import { getFileSrcUrl } from './util';
 | 
					import { getFileSrcUrl } from './util';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type ThumbnailContentProps = {
 | 
					export type ThumbnailContentProps = {
 | 
				
			||||||
  info: IThumbnailContent;
 | 
					  info: IThumbnailContent;
 | 
				
			||||||
| 
						 | 
					@ -12,8 +12,7 @@ export type ThumbnailContentProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function ThumbnailContent({ info, renderImage }: ThumbnailContentProps) {
 | 
					export function ThumbnailContent({ info, renderImage }: ThumbnailContentProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [thumbSrcState, loadThumbSrc] = useAsyncCallback(
 | 
					  const [thumbSrcState, loadThumbSrc] = useAsyncCallback(
 | 
				
			||||||
    useCallback(() => {
 | 
					    useCallback(() => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,7 @@ import { getFileSrcUrl } from './util';
 | 
				
			||||||
import { bytesToSize } from '../../../../util/common';
 | 
					import { bytesToSize } from '../../../../util/common';
 | 
				
			||||||
import { millisecondsToMinutesAndSeconds } from '../../../utils/common';
 | 
					import { millisecondsToMinutesAndSeconds } from '../../../utils/common';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RenderVideoProps = {
 | 
					type RenderVideoProps = {
 | 
				
			||||||
  title: string;
 | 
					  title: string;
 | 
				
			||||||
| 
						 | 
					@ -63,8 +63,7 @@ export const VideoContent = as<'div', VideoContentProps>(
 | 
				
			||||||
    ref
 | 
					    ref
 | 
				
			||||||
  ) => {
 | 
					  ) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const blurHash = info.thumbnail_info?.[MATRIX_BLUR_HASH_PROPERTY_NAME];
 | 
					    const blurHash = info.thumbnail_info?.[MATRIX_BLUR_HASH_PROPERTY_NAME];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [load, setLoad] = useState(false);
 | 
					    const [load, setLoad] = useState(false);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ import { useJoinedRoomId } from '../../hooks/useJoinedRoomId';
 | 
				
			||||||
import { useElementSizeObserver } from '../../hooks/useElementSizeObserver';
 | 
					import { useElementSizeObserver } from '../../hooks/useElementSizeObserver';
 | 
				
			||||||
import { getRoomAvatarUrl, getStateEvent } from '../../utils/room';
 | 
					import { getRoomAvatarUrl, getStateEvent } from '../../utils/room';
 | 
				
			||||||
import { useStateEventCallback } from '../../hooks/useStateEventCallback';
 | 
					import { useStateEventCallback } from '../../hooks/useStateEventCallback';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type GridColumnCount = '1' | '2' | '3';
 | 
					type GridColumnCount = '1' | '2' | '3';
 | 
				
			||||||
const getGridColumnCount = (gridWidth: number): GridColumnCount => {
 | 
					const getGridColumnCount = (gridWidth: number): GridColumnCount => {
 | 
				
			||||||
| 
						 | 
					@ -162,8 +162,7 @@ export const RoomCard = as<'div', RoomCardProps>(
 | 
				
			||||||
    ref
 | 
					    ref
 | 
				
			||||||
  ) => {
 | 
					  ) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const joinedRoomId = useJoinedRoomId(allRooms, roomIdOrAlias);
 | 
					    const joinedRoomId = useJoinedRoomId(allRooms, roomIdOrAlias);
 | 
				
			||||||
    const joinedRoom = mx.getRoom(joinedRoomId);
 | 
					    const joinedRoom = mx.getRoom(joinedRoomId);
 | 
				
			||||||
    const [topicEvent, setTopicEvent] = useState(() =>
 | 
					    const [topicEvent, setTopicEvent] = useState(() =>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ import { RoomAvatar } from '../room-avatar';
 | 
				
			||||||
import { nameInitials } from '../../utils/common';
 | 
					import { nameInitials } from '../../utils/common';
 | 
				
			||||||
import { useRoomAvatar, useRoomName, useRoomTopic } from '../../hooks/useRoomMeta';
 | 
					import { useRoomAvatar, useRoomName, useRoomTopic } from '../../hooks/useRoomMeta';
 | 
				
			||||||
import { mDirectAtom } from '../../state/mDirectList';
 | 
					import { mDirectAtom } from '../../state/mDirectList';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type RoomIntroProps = {
 | 
					export type RoomIntroProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -22,8 +22,7 @@ export type RoomIntroProps = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const RoomIntro = as<'div', RoomIntroProps>(({ room, ...props }, ref) => {
 | 
					export const RoomIntro = as<'div', RoomIntroProps>(({ room, ...props }, ref) => {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const { navigateRoom } = useRoomNavigate();
 | 
					  const { navigateRoom } = useRoomNavigate();
 | 
				
			||||||
  const mDirects = useAtomValue(mDirectAtom);
 | 
					  const mDirects = useAtomValue(mDirectAtom);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,15 +11,14 @@ import {
 | 
				
			||||||
import * as css from './UrlPreviewCard.css';
 | 
					import * as css from './UrlPreviewCard.css';
 | 
				
			||||||
import { tryDecodeURIComponent } from '../../utils/dom';
 | 
					import { tryDecodeURIComponent } from '../../utils/dom';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const linkStyles = { color: color.Success.Main };
 | 
					const linkStyles = { color: color.Success.Main };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const UrlPreviewCard = as<'div', { url: string; ts: number }>(
 | 
					export const UrlPreviewCard = as<'div', { url: string; ts: number }>(
 | 
				
			||||||
  ({ url, ts, ...props }, ref) => {
 | 
					  ({ url, ts, ...props }, ref) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const [previewStatus, loadPreview] = useAsyncCallback(
 | 
					    const [previewStatus, loadPreview] = useAsyncCallback(
 | 
				
			||||||
      useCallback(() => mx.getUrlPreview(url, ts), [url, ts, mx])
 | 
					      useCallback(() => mx.getUrlPreview(url, ts), [url, ts, mx])
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ import { stopPropagation } from '../../utils/keyboard';
 | 
				
			||||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
 | 
					import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
 | 
				
			||||||
import { BackRouteHandler } from '../../components/BackRouteHandler';
 | 
					import { BackRouteHandler } from '../../components/BackRouteHandler';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type LobbyMenuProps = {
 | 
					type LobbyMenuProps = {
 | 
				
			||||||
  roomId: string;
 | 
					  roomId: string;
 | 
				
			||||||
| 
						 | 
					@ -124,8 +124,7 @@ type LobbyHeaderProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) {
 | 
					export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const space = useSpace();
 | 
					  const space = useSpace();
 | 
				
			||||||
  const setPeopleDrawer = useSetSetting(settingsAtom, 'isPeopleDrawer');
 | 
					  const setPeopleDrawer = useSetSetting(settingsAtom, 'isPeopleDrawer');
 | 
				
			||||||
  const [menuAnchor, setMenuAnchor] = useState<RectCords>();
 | 
					  const [menuAnchor, setMenuAnchor] = useState<RectCords>();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,12 +12,11 @@ import * as css from './LobbyHero.css';
 | 
				
			||||||
import { PageHero } from '../../components/page';
 | 
					import { PageHero } from '../../components/page';
 | 
				
			||||||
import { onEnterOrSpace, stopPropagation } from '../../utils/keyboard';
 | 
					import { onEnterOrSpace, stopPropagation } from '../../utils/keyboard';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function LobbyHero() {
 | 
					export function LobbyHero() {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const space = useSpace();
 | 
					  const space = useSpace();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const name = useRoomName(space);
 | 
					  const name = useRoomName(space);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,7 +40,7 @@ import { ErrorCode } from '../../cs-errorcode';
 | 
				
			||||||
import { getDirectRoomAvatarUrl, getRoomAvatarUrl } from '../../utils/room';
 | 
					import { getDirectRoomAvatarUrl, getRoomAvatarUrl } from '../../utils/room';
 | 
				
			||||||
import { ItemDraggableTarget, useDraggableItem } from './DnD';
 | 
					import { ItemDraggableTarget, useDraggableItem } from './DnD';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RoomJoinButtonProps = {
 | 
					type RoomJoinButtonProps = {
 | 
				
			||||||
  roomId: string;
 | 
					  roomId: string;
 | 
				
			||||||
| 
						 | 
					@ -336,8 +336,7 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
 | 
				
			||||||
    ref
 | 
					    ref
 | 
				
			||||||
  ) => {
 | 
					  ) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const { roomId, content } = item;
 | 
					    const { roomId, content } = item;
 | 
				
			||||||
    const room = getRoom(roomId);
 | 
					    const room = getRoom(roomId);
 | 
				
			||||||
    const targetRef = useRef<HTMLDivElement>(null);
 | 
					    const targetRef = useRef<HTMLDivElement>(null);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ import { useDraggableItem } from './DnD';
 | 
				
			||||||
import { openCreateRoom, openSpaceAddExisting } from '../../../client/action/navigation';
 | 
					import { openCreateRoom, openSpaceAddExisting } from '../../../client/action/navigation';
 | 
				
			||||||
import { stopPropagation } from '../../utils/keyboard';
 | 
					import { stopPropagation } from '../../utils/keyboard';
 | 
				
			||||||
import { mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function SpaceProfileLoading() {
 | 
					function SpaceProfileLoading() {
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
| 
						 | 
					@ -410,8 +410,7 @@ export const SpaceItemCard = as<'div', SpaceItemCardProps>(
 | 
				
			||||||
    ref
 | 
					    ref
 | 
				
			||||||
  ) => {
 | 
					  ) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const { roomId, content } = item;
 | 
					    const { roomId, content } = item;
 | 
				
			||||||
    const space = getRoom(roomId);
 | 
					    const space = getRoom(roomId);
 | 
				
			||||||
    const targetRef = useRef<HTMLDivElement>(null);
 | 
					    const targetRef = useRef<HTMLDivElement>(null);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ import { SequenceCard } from '../../components/sequence-card';
 | 
				
			||||||
import { UserAvatar } from '../../components/user-avatar';
 | 
					import { UserAvatar } from '../../components/user-avatar';
 | 
				
			||||||
import { useMentionClickHandler } from '../../hooks/useMentionClickHandler';
 | 
					import { useMentionClickHandler } from '../../hooks/useMentionClickHandler';
 | 
				
			||||||
import { useSpoilerClickHandler } from '../../hooks/useSpoilerClickHandler';
 | 
					import { useSpoilerClickHandler } from '../../hooks/useSpoilerClickHandler';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type SearchResultGroupProps = {
 | 
					type SearchResultGroupProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -57,8 +57,7 @@ export function SearchResultGroup({
 | 
				
			||||||
  onOpen,
 | 
					  onOpen,
 | 
				
			||||||
}: SearchResultGroupProps) {
 | 
					}: SearchResultGroupProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const highlightRegex = useMemo(() => makeHighlightRegex(highlights), [highlights]);
 | 
					  const highlightRegex = useMemo(() => makeHighlightRegex(highlights), [highlights]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const mentionClickHandler = useMentionClickHandler(room.roomId);
 | 
					  const mentionClickHandler = useMentionClickHandler(room.roomId);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ import { stopPropagation } from '../../utils/keyboard';
 | 
				
			||||||
import { getMatrixToRoom } from '../../plugins/matrix-to';
 | 
					import { getMatrixToRoom } from '../../plugins/matrix-to';
 | 
				
			||||||
import { getCanonicalAliasOrRoomId, isRoomAlias } from '../../utils/matrix';
 | 
					import { getCanonicalAliasOrRoomId, isRoomAlias } from '../../utils/matrix';
 | 
				
			||||||
import { getViaServers } from '../../plugins/via-servers';
 | 
					import { getViaServers } from '../../plugins/via-servers';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RoomNavItemMenuProps = {
 | 
					type RoomNavItemMenuProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -176,8 +176,7 @@ export function RoomNavItem({
 | 
				
			||||||
  linkPath,
 | 
					  linkPath,
 | 
				
			||||||
}: RoomNavItemProps) {
 | 
					}: RoomNavItemProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const [hover, setHover] = useState(false);
 | 
					  const [hover, setHover] = useState(false);
 | 
				
			||||||
  const { hoverProps } = useHover({ onHoverChange: setHover });
 | 
					  const { hoverProps } = useHover({ onHoverChange: setHover });
 | 
				
			||||||
  const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover });
 | 
					  const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,7 +55,7 @@ import { ScrollTopContainer } from '../../components/scroll-top-container';
 | 
				
			||||||
import { UserAvatar } from '../../components/user-avatar';
 | 
					import { UserAvatar } from '../../components/user-avatar';
 | 
				
			||||||
import { useRoomTypingMember } from '../../hooks/useRoomTypingMembers';
 | 
					import { useRoomTypingMember } from '../../hooks/useRoomTypingMembers';
 | 
				
			||||||
import { stopPropagation } from '../../utils/keyboard';
 | 
					import { stopPropagation } from '../../utils/keyboard';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const MembershipFilters = {
 | 
					export const MembershipFilters = {
 | 
				
			||||||
  filterJoined: (m: RoomMember) => m.membership === Membership.Join,
 | 
					  filterJoined: (m: RoomMember) => m.membership === Membership.Join,
 | 
				
			||||||
| 
						 | 
					@ -172,8 +172,7 @@ type MembersDrawerProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function MembersDrawer({ room, members }: MembersDrawerProps) {
 | 
					export function MembersDrawer({ room, members }: MembersDrawerProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const scrollRef = useRef<HTMLDivElement>(null);
 | 
					  const scrollRef = useRef<HTMLDivElement>(null);
 | 
				
			||||||
  const searchInputRef = useRef<HTMLInputElement>(null);
 | 
					  const searchInputRef = useRef<HTMLInputElement>(null);
 | 
				
			||||||
  const scrollTopAnchorRef = useRef<HTMLDivElement>(null);
 | 
					  const scrollTopAnchorRef = useRef<HTMLDivElement>(null);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -108,7 +108,7 @@ import { mobileOrTablet } from '../../utils/user-agent';
 | 
				
			||||||
import { useElementSizeObserver } from '../../hooks/useElementSizeObserver';
 | 
					import { useElementSizeObserver } from '../../hooks/useElementSizeObserver';
 | 
				
			||||||
import { ReplyLayout, ThreadIndicator } from '../../components/message';
 | 
					import { ReplyLayout, ThreadIndicator } from '../../components/message';
 | 
				
			||||||
import { roomToParentsAtom } from '../../state/room/roomToParents';
 | 
					import { roomToParentsAtom } from '../../state/room/roomToParents';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface RoomInputProps {
 | 
					interface RoomInputProps {
 | 
				
			||||||
  editor: Editor;
 | 
					  editor: Editor;
 | 
				
			||||||
| 
						 | 
					@ -119,8 +119,7 @@ interface RoomInputProps {
 | 
				
			||||||
export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
 | 
					export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
 | 
				
			||||||
  ({ editor, fileDropContainerRef, roomId, room }, ref) => {
 | 
					  ({ editor, fileDropContainerRef, roomId, room }, ref) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
 | 
					    const [enterForNewline] = useSetting(settingsAtom, 'enterForNewline');
 | 
				
			||||||
    const [isMarkdown] = useSetting(settingsAtom, 'isMarkdown');
 | 
					    const [isMarkdown] = useSetting(settingsAtom, 'isMarkdown');
 | 
				
			||||||
    const commands = useCommands(mx, room);
 | 
					    const commands = useCommands(mx, room);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -122,7 +122,7 @@ import { roomToUnreadAtom } from '../../state/room/roomToUnread';
 | 
				
			||||||
import { useMentionClickHandler } from '../../hooks/useMentionClickHandler';
 | 
					import { useMentionClickHandler } from '../../hooks/useMentionClickHandler';
 | 
				
			||||||
import { useSpoilerClickHandler } from '../../hooks/useSpoilerClickHandler';
 | 
					import { useSpoilerClickHandler } from '../../hooks/useSpoilerClickHandler';
 | 
				
			||||||
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
 | 
					import { useRoomNavigate } from '../../hooks/useRoomNavigate';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const TimelineFloat = as<'div', css.TimelineFloatVariants>(
 | 
					const TimelineFloat = as<'div', css.TimelineFloatVariants>(
 | 
				
			||||||
  ({ position, className, ...props }, ref) => (
 | 
					  ({ position, className, ...props }, ref) => (
 | 
				
			||||||
| 
						 | 
					@ -438,8 +438,7 @@ const getRoomUnreadInfo = (room: Room, scrollTo = false) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimelineProps) {
 | 
					export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimelineProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const encryptedRoom = mx.isRoomEncrypted(room.roomId);
 | 
					  const encryptedRoom = mx.isRoomEncrypted(room.roomId);
 | 
				
			||||||
  const [messageLayout] = useSetting(settingsAtom, 'messageLayout');
 | 
					  const [messageLayout] = useSetting(settingsAtom, 'messageLayout');
 | 
				
			||||||
  const [messageSpacing] = useSetting(settingsAtom, 'messageSpacing');
 | 
					  const [messageSpacing] = useSetting(settingsAtom, 'messageSpacing');
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,7 +53,7 @@ import { stopPropagation } from '../../utils/keyboard';
 | 
				
			||||||
import { getMatrixToRoom } from '../../plugins/matrix-to';
 | 
					import { getMatrixToRoom } from '../../plugins/matrix-to';
 | 
				
			||||||
import { getViaServers } from '../../plugins/via-servers';
 | 
					import { getViaServers } from '../../plugins/via-servers';
 | 
				
			||||||
import { BackRouteHandler } from '../../components/BackRouteHandler';
 | 
					import { BackRouteHandler } from '../../components/BackRouteHandler';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RoomMenuProps = {
 | 
					type RoomMenuProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -175,8 +175,7 @@ const RoomMenu = forwardRef<HTMLDivElement, RoomMenuProps>(({ room, requestClose
 | 
				
			||||||
export function RoomViewHeader() {
 | 
					export function RoomViewHeader() {
 | 
				
			||||||
  const navigate = useNavigate();
 | 
					  const navigate = useNavigate();
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const screenSize = useScreenSizeContext();
 | 
					  const screenSize = useScreenSizeContext();
 | 
				
			||||||
  const room = useRoom();
 | 
					  const room = useRoom();
 | 
				
			||||||
  const space = useSpaceOptionally();
 | 
					  const space = useSpaceOptionally();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,7 +67,7 @@ import { copyToClipboard } from '../../../utils/dom';
 | 
				
			||||||
import { stopPropagation } from '../../../utils/keyboard';
 | 
					import { stopPropagation } from '../../../utils/keyboard';
 | 
				
			||||||
import { getMatrixToRoomEvent } from '../../../plugins/matrix-to';
 | 
					import { getMatrixToRoomEvent } from '../../../plugins/matrix-to';
 | 
				
			||||||
import { getViaServers } from '../../../plugins/via-servers';
 | 
					import { getViaServers } from '../../../plugins/via-servers';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type ReactionHandler = (keyOrMxc: string, shortcode: string) => void;
 | 
					export type ReactionHandler = (keyOrMxc: string, shortcode: string) => void;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -651,8 +651,7 @@ export const Message = as<'div', MessageProps>(
 | 
				
			||||||
    ref
 | 
					    ref
 | 
				
			||||||
  ) => {
 | 
					  ) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const senderId = mEvent.getSender() ?? '';
 | 
					    const senderId = mEvent.getSender() ?? '';
 | 
				
			||||||
    const [hover, setHover] = useState(false);
 | 
					    const [hover, setHover] = useState(false);
 | 
				
			||||||
    const { hoverProps } = useHover({ onHoverChange: setHover });
 | 
					    const { hoverProps } = useHover({ onHoverChange: setHover });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ import { useRelations } from '../../../hooks/useRelations';
 | 
				
			||||||
import * as css from './styles.css';
 | 
					import * as css from './styles.css';
 | 
				
			||||||
import { ReactionViewer } from '../reaction-viewer';
 | 
					import { ReactionViewer } from '../reaction-viewer';
 | 
				
			||||||
import { stopPropagation } from '../../../utils/keyboard';
 | 
					import { stopPropagation } from '../../../utils/keyboard';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type ReactionsProps = {
 | 
					export type ReactionsProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -34,8 +34,7 @@ export type ReactionsProps = {
 | 
				
			||||||
export const Reactions = as<'div', ReactionsProps>(
 | 
					export const Reactions = as<'div', ReactionsProps>(
 | 
				
			||||||
  ({ className, room, relations, mEventId, canSendReaction, onReactionToggle, ...props }, ref) => {
 | 
					  ({ className, room, relations, mEventId, canSendReaction, onReactionToggle, ...props }, ref) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const [viewer, setViewer] = useState<boolean | string>(false);
 | 
					    const [viewer, setViewer] = useState<boolean | string>(false);
 | 
				
			||||||
    const myUserId = mx.getUserId();
 | 
					    const myUserId = mx.getUserId();
 | 
				
			||||||
    const reactions = useRelations(
 | 
					    const reactions = useRelations(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ import { useRelations } from '../../../hooks/useRelations';
 | 
				
			||||||
import { Reaction } from '../../../components/message';
 | 
					import { Reaction } from '../../../components/message';
 | 
				
			||||||
import { getHexcodeForEmoji, getShortcodeFor } from '../../../plugins/emoji';
 | 
					import { getHexcodeForEmoji, getShortcodeFor } from '../../../plugins/emoji';
 | 
				
			||||||
import { UserAvatar } from '../../../components/user-avatar';
 | 
					import { UserAvatar } from '../../../components/user-avatar';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type ReactionViewerProps = {
 | 
					export type ReactionViewerProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -36,8 +36,7 @@ export type ReactionViewerProps = {
 | 
				
			||||||
export const ReactionViewer = as<'div', ReactionViewerProps>(
 | 
					export const ReactionViewer = as<'div', ReactionViewerProps>(
 | 
				
			||||||
  ({ className, room, initialKey, relations, requestClose, ...props }, ref) => {
 | 
					  ({ className, room, initialKey, relations, requestClose, ...props }, ref) => {
 | 
				
			||||||
    const mx = useMatrixClient();
 | 
					    const mx = useMatrixClient();
 | 
				
			||||||
    const { versions } = useSpecVersions();
 | 
					    const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
    const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
    const reactions = useRelations(
 | 
					    const reactions = useRelations(
 | 
				
			||||||
      relations,
 | 
					      relations,
 | 
				
			||||||
      useCallback((rel) => [...(rel.getSortedAnnotationsByKey() ?? [])], [])
 | 
					      useCallback((rel) => [...(rel.getSortedAnnotationsByKey() ?? [])], [])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										10
									
								
								src/app/hooks/useMediaAuthentication.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/app/hooks/useMediaAuthentication.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					import { useSpecVersions } from './useSpecVersions';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const useMediaAuthentication = (): boolean => {
 | 
				
			||||||
 | 
					  const { versions } = useSpecVersions();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Media authentication is introduced in spec version 1.11
 | 
				
			||||||
 | 
					  const authenticatedMedia = versions.includes('v1.11');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return authenticatedMedia;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,7 @@ import { NotificationType, UnreadInfo } from '../../../types/matrix/room';
 | 
				
			||||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
 | 
					import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
 | 
				
			||||||
import { useSelectedRoom } from '../../hooks/router/useSelectedRoom';
 | 
					import { useSelectedRoom } from '../../hooks/router/useSelectedRoom';
 | 
				
			||||||
import { useInboxNotificationsSelected } from '../../hooks/router/useInbox';
 | 
					import { useInboxNotificationsSelected } from '../../hooks/router/useInbox';
 | 
				
			||||||
import { useSpecVersions } from '../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function SystemEmojiFeature() {
 | 
					function SystemEmojiFeature() {
 | 
				
			||||||
  const [twitterEmoji] = useSetting(settingsAtom, 'twitterEmoji');
 | 
					  const [twitterEmoji] = useSetting(settingsAtom, 'twitterEmoji');
 | 
				
			||||||
| 
						 | 
					@ -133,8 +133,7 @@ function MessageNotifications() {
 | 
				
			||||||
  const notifRef = useRef<Notification>();
 | 
					  const notifRef = useRef<Notification>();
 | 
				
			||||||
  const unreadCacheRef = useRef<Map<string, UnreadInfo>>(new Map());
 | 
					  const unreadCacheRef = useRef<Map<string, UnreadInfo>>(new Map());
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const [showNotifications] = useSetting(settingsAtom, 'showNotifications');
 | 
					  const [showNotifications] = useSetting(settingsAtom, 'showNotifications');
 | 
				
			||||||
  const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds');
 | 
					  const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -243,6 +242,7 @@ function MessageNotifications() {
 | 
				
			||||||
    playSound,
 | 
					    playSound,
 | 
				
			||||||
    notify,
 | 
					    notify,
 | 
				
			||||||
    selectedRoomId,
 | 
					    selectedRoomId,
 | 
				
			||||||
 | 
					    useAuthentication,
 | 
				
			||||||
  ]);
 | 
					  ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ import { useRoomNavigate } from '../../../hooks/useRoomNavigate';
 | 
				
			||||||
import { useRoomTopic } from '../../../hooks/useRoomMeta';
 | 
					import { useRoomTopic } from '../../../hooks/useRoomMeta';
 | 
				
			||||||
import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize';
 | 
					import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize';
 | 
				
			||||||
import { BackRouteHandler } from '../../../components/BackRouteHandler';
 | 
					import { BackRouteHandler } from '../../../components/BackRouteHandler';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const COMPACT_CARD_WIDTH = 548;
 | 
					const COMPACT_CARD_WIDTH = 548;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,8 +55,7 @@ type InviteCardProps = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
function InviteCard({ room, userId, direct, compact, onNavigate }: InviteCardProps) {
 | 
					function InviteCard({ room, userId, direct, compact, onNavigate }: InviteCardProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const roomName = room.name || room.getCanonicalAlias() || room.roomId;
 | 
					  const roomName = room.name || room.getCanonicalAlias() || room.roomId;
 | 
				
			||||||
  const member = room.getMember(userId);
 | 
					  const member = room.getMember(userId);
 | 
				
			||||||
  const memberEvent = member?.events.member;
 | 
					  const memberEvent = member?.events.member;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,7 @@ import { useMentionClickHandler } from '../../../hooks/useMentionClickHandler';
 | 
				
			||||||
import { useSpoilerClickHandler } from '../../../hooks/useSpoilerClickHandler';
 | 
					import { useSpoilerClickHandler } from '../../../hooks/useSpoilerClickHandler';
 | 
				
			||||||
import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize';
 | 
					import { ScreenSize, useScreenSizeContext } from '../../../hooks/useScreenSize';
 | 
				
			||||||
import { BackRouteHandler } from '../../../components/BackRouteHandler';
 | 
					import { BackRouteHandler } from '../../../components/BackRouteHandler';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RoomNotificationsGroup = {
 | 
					type RoomNotificationsGroup = {
 | 
				
			||||||
  roomId: string;
 | 
					  roomId: string;
 | 
				
			||||||
| 
						 | 
					@ -192,8 +192,7 @@ function RoomNotificationsGroupComp({
 | 
				
			||||||
  onOpen,
 | 
					  onOpen,
 | 
				
			||||||
}: RoomNotificationsGroupProps) {
 | 
					}: RoomNotificationsGroupProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const unread = useRoomUnread(room.roomId, roomToUnreadAtom);
 | 
					  const unread = useRoomUnread(room.roomId, roomToUnreadAtom);
 | 
				
			||||||
  const mentionClickHandler = useMentionClickHandler(room.roomId);
 | 
					  const mentionClickHandler = useMentionClickHandler(room.roomId);
 | 
				
			||||||
  const spoilerClickHandler = useSpoilerClickHandler();
 | 
					  const spoilerClickHandler = useSpoilerClickHandler();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -87,7 +87,7 @@ import { stopPropagation } from '../../../utils/keyboard';
 | 
				
			||||||
import { getMatrixToRoom } from '../../../plugins/matrix-to';
 | 
					import { getMatrixToRoom } from '../../../plugins/matrix-to';
 | 
				
			||||||
import { getViaServers } from '../../../plugins/via-servers';
 | 
					import { getViaServers } from '../../../plugins/via-servers';
 | 
				
			||||||
import { getRoomAvatarUrl } from '../../../utils/room';
 | 
					import { getRoomAvatarUrl } from '../../../utils/room';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type SpaceMenuProps = {
 | 
					type SpaceMenuProps = {
 | 
				
			||||||
  room: Room;
 | 
					  room: Room;
 | 
				
			||||||
| 
						 | 
					@ -381,8 +381,7 @@ function SpaceTab({
 | 
				
			||||||
  onUnpin,
 | 
					  onUnpin,
 | 
				
			||||||
}: SpaceTabProps) {
 | 
					}: SpaceTabProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const targetRef = useRef<HTMLDivElement>(null);
 | 
					  const targetRef = useRef<HTMLDivElement>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const spaceDraggable: SidebarDraggable = useMemo(
 | 
					  const spaceDraggable: SidebarDraggable = useMemo(
 | 
				
			||||||
| 
						 | 
					@ -528,8 +527,7 @@ function ClosedSpaceFolder({
 | 
				
			||||||
  disabled,
 | 
					  disabled,
 | 
				
			||||||
}: ClosedSpaceFolderProps) {
 | 
					}: ClosedSpaceFolderProps) {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const handlerRef = useRef<HTMLDivElement>(null);
 | 
					  const handlerRef = useRef<HTMLDivElement>(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const spaceDraggable: FolderDraggable = useMemo(() => ({ folder }), [folder]);
 | 
					  const spaceDraggable: FolderDraggable = useMemo(() => ({ folder }), [folder]);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@ import { UserAvatar } from '../../../components/user-avatar';
 | 
				
			||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
 | 
					import { useMatrixClient } from '../../../hooks/useMatrixClient';
 | 
				
			||||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../../utils/matrix';
 | 
					import { getMxIdLocalPart, mxcUrlToHttp } from '../../../utils/matrix';
 | 
				
			||||||
import { nameInitials } from '../../../utils/common';
 | 
					import { nameInitials } from '../../../utils/common';
 | 
				
			||||||
import { useSpecVersions } from '../../../hooks/useSpecVersions';
 | 
					import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type UserProfile = {
 | 
					type UserProfile = {
 | 
				
			||||||
  avatar_url?: string;
 | 
					  avatar_url?: string;
 | 
				
			||||||
| 
						 | 
					@ -15,8 +15,7 @@ type UserProfile = {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
export function UserTab() {
 | 
					export function UserTab() {
 | 
				
			||||||
  const mx = useMatrixClient();
 | 
					  const mx = useMatrixClient();
 | 
				
			||||||
  const { versions } = useSpecVersions();
 | 
					  const useAuthentication = useMediaAuthentication();
 | 
				
			||||||
  const useAuthentication = versions.includes('v1.11');
 | 
					 | 
				
			||||||
  const userId = mx.getUserId()!;
 | 
					  const userId = mx.getUserId()!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const [profile, setProfile] = useState<UserProfile>({});
 | 
					  const [profile, setProfile] = useState<UserProfile>({});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -244,11 +244,7 @@ async function unignore(mx, userIds) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function setPowerLevel(mx, roomId, userId, powerLevel) {
 | 
					async function setPowerLevel(mx, roomId, userId, powerLevel) {
 | 
				
			||||||
  const room = mx.getRoom(roomId);
 | 
					  const result = await mx.setPowerLevel(roomId, userId, powerLevel);
 | 
				
			||||||
 | 
					 | 
				
			||||||
  const powerlevelEvent = room.currentState.getStateEvents('m.room.power_levels')[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  const result = await mx.setPowerLevel(roomId, userId, powerLevel, powerlevelEvent);
 | 
					 | 
				
			||||||
  return result;
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,19 +23,22 @@ settings.applyTheme();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Register Service Worker
 | 
					// Register Service Worker
 | 
				
			||||||
if ('serviceWorker' in navigator) {
 | 
					if ('serviceWorker' in navigator) {
 | 
				
			||||||
  navigator.serviceWorker.register(
 | 
					  const swUrl =
 | 
				
			||||||
    import.meta.env.MODE === 'production' ? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js` : '/dev-sw.js?dev-sw'
 | 
					    import.meta.env.MODE === 'production'
 | 
				
			||||||
  )
 | 
					      ? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js`
 | 
				
			||||||
 | 
					      : `/dev-sw.js?dev-sw`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  navigator.serviceWorker.register(swUrl);
 | 
				
			||||||
  navigator.serviceWorker.addEventListener('message', (event) => {
 | 
					  navigator.serviceWorker.addEventListener('message', (event) => {
 | 
				
			||||||
    if (event.data?.type === 'token' && event.data?.responseKey) {
 | 
					    if (event.data?.type === 'token' && event.data?.responseKey) {
 | 
				
			||||||
      // Get the token for SW.
 | 
					      // Get the token for SW.
 | 
				
			||||||
      const token = localStorage.getItem('cinny_access_token');
 | 
					      const token = localStorage.getItem('cinny_access_token') ?? undefined;
 | 
				
			||||||
      event.source!.postMessage({
 | 
					      event.source!.postMessage({
 | 
				
			||||||
        responseKey: event.data.responseKey,
 | 
					        responseKey: event.data.responseKey,
 | 
				
			||||||
        token,
 | 
					        token,
 | 
				
			||||||
      })
 | 
					      });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  })
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const mountApp = () => {
 | 
					const mountApp = () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,8 @@
 | 
				
			||||||
 | 
					/// <reference lib="WebWorker" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type {};
 | 
				
			||||||
 | 
					declare const self: ServiceWorkerGlobalScope;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function askForAccessToken(client: Client): Promise<string | undefined> {
 | 
					async function askForAccessToken(client: Client): Promise<string | undefined> {
 | 
				
			||||||
  return new Promise((resolve) => {
 | 
					  return new Promise((resolve) => {
 | 
				
			||||||
    const responseKey = Math.random().toString(36);
 | 
					    const responseKey = Math.random().toString(36);
 | 
				
			||||||
| 
						 | 
					@ -32,11 +37,10 @@ self.addEventListener('fetch', (event: FetchEvent) => {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  event.respondWith(
 | 
					  event.respondWith(
 | 
				
			||||||
    (async (): Promise<Response> => {
 | 
					    (async (): Promise<Response> => {
 | 
				
			||||||
      const client = await clients.get(event.clientId);
 | 
					      const client = await self.clients.get(event.clientId);
 | 
				
			||||||
      let token: string | undefined;
 | 
					      let token: string | undefined;
 | 
				
			||||||
      if (client) token = await askForAccessToken(client);
 | 
					      if (client) token = await askForAccessToken(client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // eslint-disable-next-line consistent-return
 | 
					 | 
				
			||||||
      return fetch(url, fetchConfig(token));
 | 
					      return fetch(url, fetchConfig(token));
 | 
				
			||||||
    })()
 | 
					    })()
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +77,10 @@ export default defineConfig({
 | 
				
			||||||
      injectManifest: {
 | 
					      injectManifest: {
 | 
				
			||||||
        injectionPoint: undefined,
 | 
					        injectionPoint: undefined,
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 | 
					      devOptions: {
 | 
				
			||||||
 | 
					        enabled: true,
 | 
				
			||||||
 | 
					        type: 'module'
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }),
 | 
					    }),
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  optimizeDeps: {
 | 
					  optimizeDeps: {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue