true bucket sharing handling
This commit is contained in:
+43
-13
@@ -648,8 +648,22 @@ export const matchesFilter = (task: Task) => {
|
|||||||
) || bucketRefs.some(context => context.id === (ctx as { bucketId: string }).bucketId);
|
) || bucketRefs.some(context => context.id === (ctx as { bucketId: string }).bucketId);
|
||||||
if (!inCurrentBucket) return false;
|
if (!inCurrentBucket) return false;
|
||||||
} else {
|
} else {
|
||||||
if (hasHandoffBucket) return false;
|
const targetUserId = (ctx as { userId: string }).userId;
|
||||||
if (task.ownerId !== (ctx as { userId: string }).userId) return false;
|
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;
|
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;
|
if (!currentUserId || task.ownerId !== currentUserId) return updates;
|
||||||
|
|
||||||
const refs = updates.shareRefs || task.shareRefs;
|
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) {
|
for (const ref of refs) {
|
||||||
const context = getContextByRef(ref);
|
const context = getContextByRef(ref);
|
||||||
if (!context || context.policy !== "handoff") continue;
|
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) {
|
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 {
|
return {
|
||||||
...updates,
|
...updates,
|
||||||
ownerId: context.targetUserId,
|
ownerId: context.targetUserId,
|
||||||
@@ -2071,6 +2089,14 @@ const checkForHandoffs = (task: Task, updates: Partial<Task>): Partial<Task> =>
|
|||||||
tags: buildTaskTags(labelTags, nextShareRefs, noteRefs, favoriteTag)
|
tags: buildTaskTags(labelTags, nextShareRefs, noteRefs, favoriteTag)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context.kind === "bucket") {
|
||||||
|
return {
|
||||||
|
...updates,
|
||||||
|
shareRefs: nextShareRefs,
|
||||||
|
tags: buildTaskTags(labelTags, nextShareRefs, noteRefs, favoriteTag)
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return updates;
|
return updates;
|
||||||
@@ -2689,8 +2715,12 @@ export const loadTasksForOwner = async (userId: string) => {
|
|||||||
if (!pb.authStore.isValid || !userId) return;
|
if (!pb.authStore.isValid || !userId) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const targetPersonalContext = getPersonalContext(userId);
|
||||||
|
const filter = targetPersonalContext
|
||||||
|
? `tags ~ "${buildShareTag(targetPersonalContext.displayName)}"`
|
||||||
|
: relationFilter("user", userId);
|
||||||
const records = await pb.collection(TASGRID_COLLECTION).getFullList({
|
const records = await pb.collection(TASGRID_COLLECTION).getFullList({
|
||||||
filter: relationFilter("user", userId),
|
filter,
|
||||||
sort: '-created',
|
sort: '-created',
|
||||||
fields: LIST_FIELDS,
|
fields: LIST_FIELDS,
|
||||||
requestKey: `owner-context-${userId}`
|
requestKey: `owner-context-${userId}`
|
||||||
|
|||||||
Reference in New Issue
Block a user