unstable sharing refactor
This commit is contained in:
@@ -8,6 +8,7 @@ import { getThemeAdjustedColor } from "@/lib/colors";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger } from "@/components/ui/select";
|
||||
import { getStatusOptionsForTask } from "@/lib/constants";
|
||||
import { getRecurrenceProgress } from "@/lib/recurrence";
|
||||
import { buildShareTag } from "@/lib/tags";
|
||||
import { StatusCircle } from "./StatusCircle";
|
||||
|
||||
export const TaskCard: Component<{ task: Task, isShaking?: boolean }> = (props) => {
|
||||
@@ -33,9 +34,8 @@ export const TaskCard: Component<{ task: Task, isShaking?: boolean }> = (props)
|
||||
const ctx = currentTaskContext();
|
||||
|
||||
if (typeof ctx === 'object' && 'bucketId' in ctx) {
|
||||
// We are in a bucket view. Hide the tag that matches this bucket's name.
|
||||
// Buckets are now tagged with '@' + name.
|
||||
const bucketTagName = `@${(ctx as { name: string }).name.toLowerCase()}`;
|
||||
const bucketContext = store.contexts.find(context => context.id === ctx.bucketId);
|
||||
const bucketTagName = buildShareTag(bucketContext?.displayName || ctx.name).toLowerCase();
|
||||
return tags.filter(t => t.toLowerCase() !== bucketTagName && !t.endsWith("_favorite__"));
|
||||
}
|
||||
|
||||
@@ -139,23 +139,13 @@ export const TaskCard: Component<{ task: Task, isShaking?: boolean }> = (props)
|
||||
<span class="text-[0.625rem] font-medium">P{props.task.priority}</span>
|
||||
</div>
|
||||
|
||||
{/* Shared Indicator - shows for individual shares OR tag-based ShareRules */}
|
||||
{/* Shared Indicator - driven by @tag share contexts */}
|
||||
{(() => {
|
||||
const hasIndividualShares = props.task.sharedWith && props.task.sharedWith.length > 0;
|
||||
// Check if any tag-based ShareRules match this task's tags (exclude 'all' type)
|
||||
const hasTagRuleShares = store.shareRules.some(rule =>
|
||||
rule.type === 'tag' &&
|
||||
rule.tagName &&
|
||||
props.task.tags?.includes(rule.tagName)
|
||||
);
|
||||
const isShared = hasIndividualShares || hasTagRuleShares;
|
||||
if (props.task.shareRefs.length === 0) return null;
|
||||
|
||||
if (!isShared) return null;
|
||||
|
||||
const shareCount = (props.task.sharedWith?.length || 0);
|
||||
const tooltip = hasIndividualShares
|
||||
? `Shared with ${shareCount} user${shareCount > 1 ? 's' : ''}`
|
||||
: 'Shared via tag rule';
|
||||
const tooltip = props.task.shareRefs.length === 1
|
||||
? 'Shared via 1 @context'
|
||||
: `Shared via ${props.task.shareRefs.length} @contexts`;
|
||||
|
||||
return (
|
||||
<div class="flex items-center gap-1 shrink-0" title={tooltip}>
|
||||
|
||||
Reference in New Issue
Block a user