debianize-mobilizon/js/src/composition/activity.ts
Thomas Citharel ee20e03cc2
Migrate to Vue 3 and Vite
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2022-08-11 16:46:31 +02:00

33 lines
950 B
TypeScript

import { IActivity } from "@/types/activity.model";
import { IMember } from "@/types/actor/member.model";
import { useCurrentActorClient } from "./apollo/actor";
export function useIsActivityAuthorCurrentActor() {
const { currentActor } = useCurrentActorClient();
return (activity: IActivity): boolean => {
return (
activity.author.id === currentActor.value?.id &&
currentActor.value?.id !== undefined
);
};
}
export function useIsActivityObjectCurrentActor() {
const { currentActor } = useCurrentActorClient();
return (activity: IActivity): boolean =>
(activity?.object as IMember)?.actor?.id === currentActor.value?.id &&
currentActor.value?.id !== undefined;
}
export function useActivitySubjectParams() {
return (activity: IActivity) =>
activity.subjectParams.reduce(
(acc: Record<string, string>, { key, value }) => {
acc[key] = value;
return acc;
},
{}
);
}