Skip to content

Commit 021fa4f

Browse files
committed
fix: fixed trello tick running even when context arent there triggering sentry errors
1 parent ef91849 commit 021fa4f

File tree

2 files changed

+50
-68
lines changed

2 files changed

+50
-68
lines changed

src/capabilities/card-back-section/view.vue

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -253,37 +253,64 @@ const displayedMembers = computed(() => {
253253
});
254254
255255
const trelloTick = async () => {
256-
if (!cardId) {
257-
cardId = (await getTrelloCard().card('id')).id;
258-
}
256+
try {
257+
// Check if we have valid board context before proceeding
258+
const context = getTrelloCard().getContext();
259+
if (!context.board) {
260+
console.debug(
261+
'[activity-timer] Board context missing, skipping trelloTick'
262+
);
263+
return;
264+
}
259265
260-
canWrite.value = await getTrelloCard().memberCanWriteToModel('card');
261-
visible.value = await isVisible();
262-
hasEstimates.value = await hasEstimateFeature();
266+
if (!cardId) {
267+
cardId = (await getTrelloCard().card('id')).id;
268+
}
263269
264-
const memberId = await getMemberId();
265-
const card = getCardModel();
270+
canWrite.value = await getTrelloCard().memberCanWriteToModel('card');
271+
visible.value = await isVisible();
272+
hasEstimates.value = await hasEstimateFeature();
266273
267-
isTracking.value = await card.isRunning();
268-
trackedTime.value = await card.getTimeSpent();
274+
const memberId = await getMemberId();
275+
const card = getCardModel();
269276
270-
const estimates = await card.getEstimates();
271-
totalEstimate.value = estimates.totalEstimate;
277+
isTracking.value = await card.isRunning();
278+
trackedTime.value = await card.getTimeSpent();
272279
273-
const ownEstimateItem = estimates.getByMemberId(memberId);
280+
const estimates = await card.getEstimates();
281+
totalEstimate.value = estimates.totalEstimate;
274282
275-
if (ownEstimateItem) {
276-
ownEstimate.value = ownEstimateItem.time;
277-
} else {
278-
ownEstimate.value = 0;
279-
}
283+
const ownEstimateItem = estimates.getByMemberId(memberId);
280284
281-
// Load member summary
282-
await loadMemberSummary();
285+
if (ownEstimateItem) {
286+
ownEstimate.value = ownEstimateItem.time;
287+
} else {
288+
ownEstimate.value = 0;
289+
}
283290
284-
// Resize iframe after data changes
285-
await nextTick();
286-
setTimeout(resizeTrelloFrame, 100);
291+
// Load member summary
292+
await loadMemberSummary();
293+
294+
// Resize iframe after data changes
295+
await nextTick();
296+
setTimeout(resizeTrelloFrame, 100);
297+
} catch (e) {
298+
// Silently handle context errors when board is no longer available
299+
// This commonly occurs when the card is closed or user navigates away
300+
const errorStr = String(e);
301+
if (
302+
errorStr.includes('Invalid context') ||
303+
errorStr.includes('missing board')
304+
) {
305+
console.debug(
306+
'[activity-timer] Board context lost during trelloTick, ignoring'
307+
);
308+
return;
309+
}
310+
311+
// Re-throw unexpected errors
312+
throw e;
313+
}
287314
};
288315
289316
const loadMemberSummary = async () => {

src/components/trello.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -177,48 +177,3 @@ export async function getTokenDetails(): Promise<TrelloToken | undefined> {
177177

178178
return undefined;
179179
}
180-
181-
/**
182-
* Shows a native Trello confirmation popup.
183-
* Returns a promise that resolves to true if confirmed, false if cancelled.
184-
*
185-
* @param title - The title of the confirmation dialog
186-
* @param message - The message/body text
187-
* @param options - Optional configuration
188-
* @param options.confirmText - Text for the confirm button (default: "Confirm")
189-
* @param options.confirmStyle - Style of the confirm button: 'primary' | 'danger' (default: 'primary')
190-
* @param options.cancelText - Text for the cancel button (default: "Cancel")
191-
* @param options.mouseEvent - Mouse event for positioning the popup
192-
*/
193-
export function showConfirm(
194-
title: string,
195-
message: string,
196-
options?: {
197-
confirmText?: string;
198-
confirmStyle?: 'primary' | 'danger';
199-
cancelText?: string;
200-
mouseEvent?: MouseEvent;
201-
}
202-
): Promise<boolean> {
203-
return new Promise((resolve) => {
204-
const t = getTrelloCard();
205-
206-
t.popup({
207-
type: 'confirm',
208-
title,
209-
message,
210-
confirmText: options?.confirmText ?? 'Confirm',
211-
confirmStyle: options?.confirmStyle ?? 'primary',
212-
cancelText: options?.cancelText ?? 'Cancel',
213-
mouseEvent: options?.mouseEvent,
214-
onConfirm: () => {
215-
resolve(true);
216-
return Promise.resolve();
217-
},
218-
onCancel: () => {
219-
resolve(false);
220-
return Promise.resolve();
221-
}
222-
});
223-
});
224-
}

0 commit comments

Comments
 (0)