Repository: directus/directus
File: app/src/composables/use-collab.ts (TypeScript)

Code before:

	async function receiveInit(message: InitMessage) {
		if (joining === false) return;

		joining = false;
		roomId.value = message.room;
		connectionId.value = message.connection;

		activeRooms[roomId.value] = (activeRooms[roomId.value] ?? 0) + 1;

		if (!isMatch({ ...initialValues.value, ...edits.value }, message.changes)) {
			if (!isEmpty(edits.value)) collidingLocalChanges.value = edits.value;
			edits.value = message.changes;
		}

		if (message.users.length > 0) {
			const usersInfo = await sdk.request(
				readUsers({
					filter: {
						id: {
							_in: Array.from(new Set(message.users.map((user) => user.user))),
						},
					},
					//  Object syntax for nested fields - SDK types require schema definition for full support
					// TODO: Update this once https://github.com/directus/directus/issues/26558 is Done
					fields: ['id', 'first_name', 'last_name', 'avatar.id', 'avatar.modified_on'] as ('id' | 'first_name' | 'last_name' | 'avatar')[],
				}),
			);

			users.value = message.users
				.map(({ user, color, connection }) => {
					const info = usersInfo.find((u) => u.id === user) as CollabUserInfo | undefined;

					if (message.connection === connection) {
						sessionStorage.setItem(SESSION_COLOR_KEY, color);
					}

					return {
						...info,
						color,
						connection,
					};
				})
				.sort((a, b) => {
					if (a.connection === message.connection) return -1;
					if (b.connection === message.connection) return 1;
					return 0;
				}) as CollabUser[];
		}

		focused.value = message.focuses;

Review comment (suggestion):
```suggestion
					fields: ['id', 'first_name', 'last_name', {'avatar': ['id', 'modified_on']}],
```

Code after:

	async function receiveInit(message: InitMessage) {
		if (joining === false) return;

		joining = false;
		roomId.value = message.room;
		connectionId.value = message.connection;

		activeRooms[roomId.value] = (activeRooms[roomId.value] ?? 0) + 1;

		if (!isMatch({ ...initialValues.value, ...edits.value }, message.changes)) {
			if (!isEmpty(edits.value)) collidingLocalChanges.value = edits.value;
			edits.value = message.changes;
		}

		if (message.users.length > 0) {
			const usersInfo = await sdk.request(
				readUsers({
					filter: {
						id: {
							_in: Array.from(new Set(message.users.map((user) => user.user))),
						},
					},
					//  Object syntax for nested fields - SDK types require schema definition for full support
					// TODO: Update this once https://github.com/directus/directus/issues/26558 is Done
					fields: ['id', 'first_name', 'last_name', { avatar: ['id', 'modified_on']}] as (keyof DirectusUser)[],
				}),
			);

			users.value = message.users
				.map(({ user, color, connection }) => {
					const info = usersInfo.find((u) => u.id === user) as CollabUserInfo | undefined;

					if (message.connection === connection) {
						sessionStorage.setItem(SESSION_COLOR_KEY, color);
					}

					return {
						...info,
						color,
						connection,
					};
				})
				.sort((a, b) => {
					if (a.connection === message.connection) return -1;
					if (b.connection === message.connection) return 1;
					return 0;
				}) as CollabUser[];
		}

		focused.value = message.focuses;