Skip to content

Commit

Permalink
Merge pull request #41057 from bernhardoj/fix/40536-quick-action-not-…
Browse files Browse the repository at this point in the history
…updated-dynamically

Fix group chat name and avatar of quick action does not update dynamically
  • Loading branch information
marcaaron authored Apr 26, 2024
2 parents 7727e0e + 05fd715 commit d0c2551
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ type FloatingActionButtonAndPopoverOnyxProps = {
/** Information on the last taken action to display as Quick Action */
quickAction: OnyxEntry<OnyxTypes.QuickAction>;

/** The report data of the quick action */
quickActionReport: OnyxEntry<OnyxTypes.Report>;

/** The policy data of the quick action */
quickActionPolicy: OnyxEntry<OnyxTypes.Policy>;

/** The current session */
session: OnyxEntry<OnyxTypes.Session>;

Expand Down Expand Up @@ -141,7 +147,18 @@ const getQuickActionTitle = (action: QuickActionName): TranslationPaths => {
* FAB that can open or close the menu.
*/
function FloatingActionButtonAndPopover(
{onHideCreateMenu, onShowCreateMenu, isLoading = false, allPolicies, quickAction, session, personalDetails, hasSeenTrackTraining}: FloatingActionButtonAndPopoverProps,
{
onHideCreateMenu,
onShowCreateMenu,
isLoading = false,
allPolicies,
quickAction,
quickActionReport,
quickActionPolicy,
session,
personalDetails,
hasSeenTrackTraining,
}: FloatingActionButtonAndPopoverProps,
ref: ForwardedRef<FloatingActionButtonAndPopoverRef>,
) {
const styles = useThemeStyles();
Expand All @@ -154,10 +171,6 @@ function FloatingActionButtonAndPopover(
const prevIsFocused = usePrevious(isFocused);
const {isOffline} = useNetwork();

const quickActionReport: OnyxEntry<OnyxTypes.Report> = useMemo(() => (quickAction ? ReportUtils.getReport(quickAction.chatReportID) : null), [quickAction]);

const quickActionPolicy = allPolicies ? allPolicies[`${ONYXKEYS.COLLECTION.POLICY}${quickActionReport?.policyID}`] : undefined;

const quickActionAvatars = useMemo(() => {
if (quickActionReport) {
const avatars = ReportUtils.getIcons(quickActionReport, personalDetails);
Expand Down Expand Up @@ -418,6 +431,12 @@ export default withOnyx<FloatingActionButtonAndPopoverProps & RefAttributes<Floa
quickAction: {
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
},
quickActionReport: {
key: ({quickAction}) => `${ONYXKEYS.COLLECTION.REPORT}${quickAction?.chatReportID}`,
},
quickActionPolicy: {
key: ({quickActionReport}) => `${ONYXKEYS.COLLECTION.POLICY}${quickActionReport?.policyID}`,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
Expand Down

0 comments on commit d0c2551

Please sign in to comment.