Migrate to Vue 3 and Vite
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
32
js/src/composition/activity.ts
Normal file
32
js/src/composition/activity.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
},
|
||||
{}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user