Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ declare module "vue" {
LucideHand: typeof import("~icons/lucide/hand")["default"];
LucideHome: typeof import("~icons/lucide/home")["default"];
LucideLoader: typeof import("~icons/lucide/loader")["default"];
LucideMessageCircle: typeof import(
"~icons/lucide/message-circle",
)["default"];
LucideMessageSquare: typeof import(
"~icons/lucide/message-square",
)["default"];
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/components/FloatingControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,19 @@ const props = defineProps({
},
});

const { getMeetingDoc, isCurrentUserHost: isHost } = useMeetingDoc();
const {
getMeetingDoc,
isCurrentUserHost: isHost,
isCurrentUserCohost: isCohost,
} = useMeetingDoc();

if (props.meetingId) {
getMeetingDoc(props.meetingId);
}

const { isPreview } = toRefs(props);

const isCurrentUserHost = computed(() => isHost.value);
const isCurrentUserHost = computed(() => isHost.value || isCohost.value);

const emit = defineEmits([
"toggle-chat",
Expand Down
27 changes: 25 additions & 2 deletions frontend/src/components/PeoplePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
@muteParticipant="handleMuteParticipant"
@kickParticipant="handleKickParticipant"
@lowerHand="handleLowerHand"
@promoteToCohost="handlePromoteToCohost"
/>
</div>

Expand Down Expand Up @@ -117,6 +118,7 @@ interface Props {
isMicOn: boolean;
isCameraOn: boolean;
creatorUserId: string;
coHosts: string[];
}

const props = withDefaults(defineProps<Props>(), {
Expand All @@ -126,13 +128,15 @@ const props = withDefaults(defineProps<Props>(), {
isMicOn: false,
isCameraOn: false,
creatorUserId: "",
coHosts: () => [],
});

const emit = defineEmits<{
close: [];
muteParticipant: [participantId: string];
kickParticipant: [participantId: string, ban: boolean];
lowerHand: [participantId: string];
promoteToCohost: [participantId: string];
approveLobbyUser: [participantId: string];
approveAllLobbyUsers: [participantIds: string[]];
rejectLobbyUser: [participantId: string];
Expand All @@ -141,6 +145,13 @@ const emit = defineEmits<{
const searchQuery = ref<string>("");

const isCreator = computed(() => {
return (
props.currentUser.user_id === props.creatorUserId ||
props.coHosts.includes(props.currentUser.user_id || "")
);
});

const isHost = computed(() => {
return props.currentUser.user_id === props.creatorUserId;
});

Expand Down Expand Up @@ -224,6 +235,7 @@ const allVisibleParticipants = computed(() => {
isCurrentUser: true,
isHost: isCreator.value,
canControlParticipant: false,
canPromoteToCohost: false,
});
}

Expand All @@ -232,8 +244,15 @@ const allVisibleParticipants = computed(() => {
user_id: participant.user_id,
participantData: participant,
isCurrentUser: false,
isHost: participant.user_id === props.creatorUserId,
canControlParticipant: isCreator.value,
isHost:
participant.user_id === props.creatorUserId ||
props.coHosts.includes(participant.user_id),
canControlParticipant:
isCreator.value && participant.user_id !== props.creatorUserId,
canPromoteToCohost:
isHost.value &&
!participant.is_guest &&
!props.coHosts.includes(participant.user_id),
is_guest: participant.is_guest || false,
});
}
Expand Down Expand Up @@ -268,6 +287,10 @@ const handleLowerHand = (participantId: string) => {
emit("lowerHand", participantId);
};

const handlePromoteToCohost = (participantId: string) => {
emit("promoteToCohost", participantId);
};

const handleApproveLobbyUser = (participantId: string) => {
emit("approveLobbyUser", participantId);
};
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/PeopleParticipantTile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,21 @@ interface Props {
isCurrentUser?: boolean;
isHost?: boolean;
canControlParticipant?: boolean;
canPromoteToCohost?: boolean;
}

const props = withDefaults(defineProps<Props>(), {
isCurrentUser: false,
isHost: false,
canControlParticipant: false,
canPromoteToCohost: false,
});

const emit = defineEmits<{
muteParticipant: [participantId: string];
kickParticipant: [participantId: string, ban: boolean];
lowerHand: [participantId: string];
promoteToCohost: [participantId: string];
}>();

const { stream } = useAudioStream(props.participant.user_id);
Expand Down Expand Up @@ -157,6 +160,12 @@ const hostOptions = computed(() => {
condition: () => isHandRaised.value,
onClick: () => emit("lowerHand", props.participant.user_id),
},
{
icon: "user-plus",
label: "Promote to Co-host",
condition: () => props.canPromoteToCohost,
onClick: () => emit("promoteToCohost", props.participant.user_id),
},
{
icon: "user-x",
label: "Remove",
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/composables/useMeetingDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface MeetingDocument {
owner?: string;
title?: string;
name?: string;
co_hosts?: { user: string }[];
}

interface DocumentResource {
Expand All @@ -27,6 +28,8 @@ interface UseMeetingDocReturn {
isCurrentUserHost: ComputedRef<boolean>;
meetingType: ComputedRef<string>;
allowGuest: ComputedRef<boolean>;
meetingCoHosts: ComputedRef<string[]>;
isCurrentUserCohost: ComputedRef<boolean>;
}

const meetingDoc: Ref<DocumentResource | null> = ref(null);
Expand Down Expand Up @@ -74,6 +77,18 @@ export function useMeetingDoc(): UseMeetingDocReturn {
return Boolean(currentUserId && ownerId && currentUserId === ownerId);
});

const meetingCoHosts = computed((): string[] => {
const doc = meetingDoc.value?.doc;
if (!doc?.co_hosts) return [];
return doc.co_hosts.map((row: { user: string }) => row.user);
});

const isCurrentUserCohost = computed((): boolean => {
const currentUserId = session.user?.sessionUser;
const coHosts = meetingCoHosts.value;
return Boolean(currentUserId && coHosts && coHosts.includes(currentUserId));
});

const meetingType = computed((): string => {
return meetingDoc.value?.doc?.meeting_type || "open";
});
Expand All @@ -89,6 +104,8 @@ export function useMeetingDoc(): UseMeetingDocReturn {
meetingTitle,
meetingOwner,
isCurrentUserHost,
meetingCoHosts,
isCurrentUserCohost,
meetingType,
allowGuest,
};
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/composables/useMeetingLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,24 @@ export function useMeetingLogic(meetingState, meetingId, options = {}) {
}
});

socket.on("meeting_user_approved", (data) => {
if (data.meeting === meetingId) {
meetingState.lobbyUsers.value = (
meetingState.lobbyUsers.value || []
).filter((u) => u.userId !== data.user);
console.log(`User ${data.user} was approved by ${data.approved_by}`);
}
});

socket.on("meeting_user_rejected", (data) => {
if (data.meeting === meetingId) {
meetingState.lobbyUsers.value = (
meetingState.lobbyUsers.value || []
).filter((u) => u.userId !== data.user);
console.log(`User ${data.user} was rejected by ${data.rejected_by}`);
}
});

realtimeListenersSetup.value = true;
};

Expand Down
35 changes: 33 additions & 2 deletions frontend/src/pages/Meeting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@
:isMicOn="meetingState.isMicOn.value"
:isCameraOn="meetingState.isCameraOn.value"
:creatorUserId="creatorUserId"
:coHosts="meetingCoHosts"
@close="togglePeople"
@muteParticipant="handleMuteParticipant"
@kickParticipant="handleKickParticipant"
@lowerHand="handleLowerHand"
@promoteToCohost="handlePromoteToCohost"
@approveLobbyUser="handleApproveLobbyUser"
@approveAllLobbyUsers="handleApproveAllLobbyUsers"
@rejectLobbyUser="handleRejectLobbyUser"
Expand Down Expand Up @@ -207,8 +209,13 @@ const socket = useSocket();
// Lobby user notification tracking
const notifiedLobbyUsers = ref(new Set());

const { getMeetingDoc, meetingTitle, meetingOwner, isCurrentUserHost } =
useMeetingDoc();
const {
getMeetingDoc,
meetingTitle,
meetingOwner,
isCurrentUserHost,
meetingCoHosts,
} = useMeetingDoc();

const meetingDoc = getMeetingDoc(meetingId.value);

Expand Down Expand Up @@ -510,6 +517,30 @@ const handleLowerHand = async (participantId) => {
}
};

const handlePromoteToCohost = async (participantId) => {
try {
console.log("Promoting participant to co-host:", participantId);

const response = await frappeRequest({
url: "meet.api.meeting.promote_to_cohost",
params: {
meeting_id: route.params.meetingId,
user_id: participantId,
},
});

if (response.success) {
toast.success("User promoted to co-host");
await meetingDoc.reload();
} else {
toast.error(response.error || "Failed to promote user to co-host");
}
} catch (error) {
console.error("Failed to promote participant to co-host:", error);
toast.error("Failed to promote user to co-host");
}
};

const handleApproveLobbyUser = async (participantId) => {
try {
console.log("Approving lobby user:", participantId);
Expand Down
Loading