true bucket sharing handling

This commit is contained in:
2026-03-19 18:39:35 -05:00
parent b72980ad89
commit b246f2da78
+43 -13
View File
@@ -648,8 +648,22 @@ export const matchesFilter = (task: Task) => {
) || bucketRefs.some(context => context.id === (ctx as { bucketId: string }).bucketId);
if (!inCurrentBucket) return false;
} else {
if (hasHandoffBucket) return false;
if (task.ownerId !== (ctx as { userId: string }).userId) return false;
const targetUserId = (ctx as { userId: string }).userId;
const targetPersonalContext = getPersonalContext(targetUserId);
const inTargetPersonalContext = !!targetPersonalContext && task.shareRefs.some(ref =>
ref.kind === "user" &&
(
ref.contextId === targetPersonalContext.id ||
ref.key === targetPersonalContext.key ||
normalizeContextKey(targetPersonalContext.displayName) === ref.key
)
);
if (targetPersonalContext) {
if (!inTargetPersonalContext) return false;
} else if (task.ownerId !== targetUserId) {
return false;
}
}
if (isPersonalView && inAnyBucket && !inPinnedBucket && task.ownerId !== currentUserId) return false;
@@ -2050,20 +2064,24 @@ const checkForHandoffs = (task: Task, updates: Partial<Task>): Partial<Task> =>
if (!currentUserId || task.ownerId !== currentUserId) return updates;
const refs = updates.shareRefs || task.shareRefs;
const senderPersonalContext = getPersonalContext(currentUserId);
const stripSenderPersonalContext = (inputRefs: TaskShareRef[]) =>
senderPersonalContext
? inputRefs.filter(existingRef => !(
existingRef.kind === "user" &&
(existingRef.contextId === senderPersonalContext.id || existingRef.key === senderPersonalContext.key)
))
: inputRefs;
for (const ref of refs) {
const context = getContextByRef(ref);
if (!context || context.policy !== "handoff") continue;
const nextShareRefs = stripSenderPersonalContext(refs);
const labelTags = updates.labelTags || task.labelTags;
const noteRefs = updates.noteRefs || task.noteRefs;
const favoriteTag = (updates.tags || task.tags || []).find(tag => tag.endsWith("_favorite__"));
if (context.kind === "user" && context.targetUserId) {
const senderPersonalContext = getPersonalContext(currentUserId);
const nextShareRefs = senderPersonalContext
? refs.filter(existingRef => !(
existingRef.kind === "user" &&
(existingRef.contextId === senderPersonalContext.id || existingRef.key === senderPersonalContext.key)
))
: refs;
const labelTags = updates.labelTags || task.labelTags;
const noteRefs = updates.noteRefs || task.noteRefs;
const favoriteTag = (updates.tags || task.tags || []).find(tag => tag.endsWith("_favorite__"));
return {
...updates,
ownerId: context.targetUserId,
@@ -2071,6 +2089,14 @@ const checkForHandoffs = (task: Task, updates: Partial<Task>): Partial<Task> =>
tags: buildTaskTags(labelTags, nextShareRefs, noteRefs, favoriteTag)
};
}
if (context.kind === "bucket") {
return {
...updates,
shareRefs: nextShareRefs,
tags: buildTaskTags(labelTags, nextShareRefs, noteRefs, favoriteTag)
};
}
}
return updates;
@@ -2689,8 +2715,12 @@ export const loadTasksForOwner = async (userId: string) => {
if (!pb.authStore.isValid || !userId) return;
try {
const targetPersonalContext = getPersonalContext(userId);
const filter = targetPersonalContext
? `tags ~ "${buildShareTag(targetPersonalContext.displayName)}"`
: relationFilter("user", userId);
const records = await pb.collection(TASGRID_COLLECTION).getFullList({
filter: relationFilter("user", userId),
filter,
sort: '-created',
fields: LIST_FIELDS,
requestKey: `owner-context-${userId}`