true bucket sharing handling
This commit is contained in:
+40
-10
@@ -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;
|
||||
for (const ref of refs) {
|
||||
const context = getContextByRef(ref);
|
||||
if (!context || context.policy !== "handoff") continue;
|
||||
if (context.kind === "user" && context.targetUserId) {
|
||||
const senderPersonalContext = getPersonalContext(currentUserId);
|
||||
const nextShareRefs = senderPersonalContext
|
||||
? refs.filter(existingRef => !(
|
||||
const stripSenderPersonalContext = (inputRefs: TaskShareRef[]) =>
|
||||
senderPersonalContext
|
||||
? inputRefs.filter(existingRef => !(
|
||||
existingRef.kind === "user" &&
|
||||
(existingRef.contextId === senderPersonalContext.id || existingRef.key === senderPersonalContext.key)
|
||||
))
|
||||
: refs;
|
||||
: 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) {
|
||||
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}`
|
||||
|
||||
Reference in New Issue
Block a user