Skip to content

Commit

Permalink
Insert Debug messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
manud99 committed Jan 18, 2024
1 parent 0c98a49 commit fe2df9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/google/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,25 @@ function forgetTokenAfterTimeout() {

function handleCodeResponse(res: google.accounts.oauth2.TokenResponse) {
if (res.error !== undefined) {
console.error("google answered with an error", res.error);
console.error("Google answered with an error", res.error);
throw res;
}

const accessToken = res.access_token;
console.log("[DEBUG] handleCodeResponse - Got code response", accessToken);
window.localStorage.setItem(ACCESS_TOKEN_KEY, accessToken);
// access token is valid for one hour
window.localStorage.setItem(ACCESS_TOKEN_TIMEOUT_KEY, (new Date().valueOf() + 3600000).toString());
forgetTokenAfterTimeout();
ready.value = true;
retryRequests().then(() => (readyToFetch.value = !readyToFetch.value));
retryRequests().then(() => {
console.log("[DEBUG] handleCodeResponse - Ready to fetch");
readyToFetch.value = !readyToFetch.value;
});
}

export function forgetToken() {
console.log("[DEBUG] forgetToken", new Date());
window.localStorage.removeItem(ACCESS_TOKEN_KEY);
window.localStorage.removeItem(ACCESS_TOKEN_TIMEOUT_KEY);
ready.value = false;
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ onMounted(() => {
calendarId.value = getCalendarId();
getTimeEntries();
console.log("[DEBUG] Dashboard - onMounted");
document.addEventListener("keypress", onKeyPress);
});
Expand All @@ -126,6 +127,7 @@ onUnmounted(() => {
if (readyToFetch) {
watch(readyToFetch, () => {
console.log("[DEBUG] Dashboard - readyToFetch watcher called");
getTimeEntries();
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/utils/timeEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export function makeSureCalendarIdExists() {
}

export async function getTimeEntries() {
console.log("[DEBUG] Get Time Entries - Start", ready?.value);
if (!makeSureCalendarIdExists() || !ready || !ready.value) return;

loading.value = true;

timeEntries.value = await fetchEvents(calendarId.value!, weekStart.value, weekEnd.value);
console.log("[DEBUG] Get Time Entries - Got " + timeEntries.value.length);

loading.value = false;
}
Expand Down

0 comments on commit fe2df9f

Please sign in to comment.