Skip to content

Commit

Permalink
Make modal only visible to hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
NatalieWilson19 committed May 5, 2024
1 parent 9e7264f commit fddc516
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions app/src/components/Chat/ChatWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import { Client4 } from "@mattermost/client";
import { MmData } from "../../stores/Store";
import { IsChainAdmin, MmData, StoreContext } from "../../stores/Store";
import ChatInput, { SendingMsgState } from "./ChatInput";
import { Channel } from "@mattermost/types/channels";
import {
IonActionSheet,
IonAlert,
IonIcon,
useIonAlert,
} from "@ionic/react";
import {
addOutline
} from "ionicons/icons";
import { IonActionSheet, IonAlert, IonIcon, useIonAlert } from "@ionic/react";
import { addOutline } from "ionicons/icons";
import { useTranslation } from "react-i18next";
import { IonAlertCustomEvent } from "@ionic/core";
import { PostList } from "@mattermost/types/posts";
import { User } from "../../api/types";
import ChatPost from "./ChatPost";
import { useIntersectionObserver } from "@uidotdev/usehooks";
import { useEffect, useRef, useState } from "react";
import { useContext, useEffect, useRef, useState } from "react";
import { useDebouncedCallback } from "use-debounce";
import { useLongPress } from "use-long-press";
import { c } from "vitest/dist/reporters-5f784f42";
Expand All @@ -38,6 +31,7 @@ interface Props {
// This follows the controller / view component pattern
export default function ChatWindow(props: Props) {
const { t } = useTranslation();
const { isChainAdmin } = useContext(StoreContext);
const slowTriggerScrollTop = useDebouncedCallback(() => {
const lastPostId = props.postList.order.at(-1);
if (lastPostId) {
Expand Down Expand Up @@ -178,25 +172,27 @@ export default function ChatWindow(props: Props) {
</div>
);
})}
<IonActionSheet
header={t("chatRoomOptions")}
isOpen={isActionSheetOpen}
onDidDismiss={() => setIsActionSheetOpen(false)}
buttons={[
{
text: "Rename",
handler: () => handleOptionSelect("rename"),
},
{
text: "Delete",
handler: () => handleOptionSelect("delete"),
},
{
text: "Cancel",
role: "cancel",
},
]}
></IonActionSheet>
{isChainAdmin ? (
<IonActionSheet
header={t("chatRoomOptions")}
isOpen={isActionSheetOpen}
onDidDismiss={() => setIsActionSheetOpen(false)}
buttons={[
{
text: "Rename",
handler: () => handleOptionSelect("rename"),
},
{
text: "Delete",
handler: () => handleOptionSelect("delete"),
},
{
text: "Cancel",
role: "cancel",
},
]}
></IonActionSheet>
) : null}
<div key="plus" className="tw-p-2 tw-me-4 tw-flex tw-shrink-0">
<button
id="create_channel_btn"
Expand Down

0 comments on commit fddc516

Please sign in to comment.