Fix to show item id only if is moderator

This commit is contained in:
Snaiker 2022-03-18 22:25:38 +00:00
parent be92aede93
commit 1a3b9154a1
3 changed files with 12 additions and 3 deletions

View File

@ -7,16 +7,23 @@ export class RoomWidgetChooserContentEvent extends RoomWidgetUpdateEvent
public static FURNI_CHOOSER_CONTENT: string = 'RWCCE_FURNI_CHOOSER_CONTENT'; public static FURNI_CHOOSER_CONTENT: string = 'RWCCE_FURNI_CHOOSER_CONTENT';
private _items: RoomObjectItem[]; private _items: RoomObjectItem[];
private _isModerator: boolean;
constructor(type: string, items: RoomObjectItem[]) constructor(type: string, items: RoomObjectItem[], isModerator: boolean = false)
{ {
super(type); super(type);
this._items = items; this._items = items;
this._isModerator = isModerator;
} }
public get items(): RoomObjectItem[] public get items(): RoomObjectItem[]
{ {
return this._items; return this._items;
} }
public get isModerator(): boolean
{
return this._isModerator;
}
} }

View File

@ -72,7 +72,7 @@ export class FurniChooserWidgetHandler extends RoomWidgetHandler
return (a.name < b.name) ? -1 : 1; return (a.name < b.name) ? -1 : 1;
}); });
this.container.eventDispatcher.dispatchEvent(new RoomWidgetChooserContentEvent(RoomWidgetChooserContentEvent.FURNI_CHOOSER_CONTENT, items)); this.container.eventDispatcher.dispatchEvent(new RoomWidgetChooserContentEvent(RoomWidgetChooserContentEvent.FURNI_CHOOSER_CONTENT, items, GetSessionDataManager().isModerator));
} }
private selectRoomObject(message: RoomWidgetRoomObjectMessage): void private selectRoomObject(message: RoomWidgetRoomObjectMessage): void

View File

@ -8,6 +8,7 @@ export const FurniChooserWidgetView: FC<{}> = props =>
{ {
const [ isVisible, setIsVisible ] = useState(false); const [ isVisible, setIsVisible ] = useState(false);
const [ items, setItems ] = useState<RoomObjectItem[]>(null); const [ items, setItems ] = useState<RoomObjectItem[]>(null);
const [ isModerator, setIsmModerator ] = useState<boolean>(false);
const [ refreshTimeout, setRefreshTimeout ] = useState<ReturnType<typeof setTimeout>>(null); const [ refreshTimeout, setRefreshTimeout ] = useState<ReturnType<typeof setTimeout>>(null);
const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
@ -28,6 +29,7 @@ export const FurniChooserWidgetView: FC<{}> = props =>
BatchUpdates(() => BatchUpdates(() =>
{ {
setItems(event.items); setItems(event.items);
setIsmModerator(event.isModerator);
setIsVisible(true); setIsVisible(true);
}); });
}, []); }, []);
@ -61,5 +63,5 @@ export const FurniChooserWidgetView: FC<{}> = props =>
if(!items) return null; if(!items) return null;
return <ChooserWidgetView title={ LocalizeText('widget.chooser.furni.title') } displayItemId={ true } items={ items } onCloseClick={ close } />; return <ChooserWidgetView title={ LocalizeText('widget.chooser.furni.title') } displayItemId={ isModerator } items={ items } onCloseClick={ close } />;
} }