Properly check if a url match is a project / repository

This commit is contained in:
Rohid
2024-08-26 16:11:15 +06:00
parent 410ccc0f78
commit 3d1038de01
17 changed files with 242 additions and 77 deletions

View File

@@ -1,8 +1,9 @@
import { AnyAction, Dispatch } from '@reduxjs/toolkit';
import { setApiKey, setLoggingEnabled, setTotalTimeLoggedToday } from '../reducers/configReducer';
import config from '../config/config';
import WakaTimeCore from '../core/WakaTimeCore';
import { setApiKey, setLoggingEnabled, setTotalTimeLoggedToday } from '../reducers/configReducer';
import { setUser } from '../reducers/currentUser';
import { getHtmlContentByTabId } from '.';
import changeExtensionState from './changeExtensionState';
export const logUserIn = async (apiKey: string): Promise<void> => {
@@ -65,7 +66,17 @@ export const fetchUserData = async (
dispatch(setLoggingEnabled(items.loggingEnabled as boolean));
dispatch(setTotalTimeLoggedToday(totalTimeLoggedTodayResponse.text));
await WakaTimeCore.recordHeartbeat();
const tabs = await browser.tabs.query({
active: true,
currentWindow: true,
});
let html = '';
const tabId = tabs[0]?.id;
if (tabId) {
html = await getHtmlContentByTabId(tabId);
}
await WakaTimeCore.recordHeartbeat(html);
} catch (err: unknown) {
await changeExtensionState('notSignedIn');
}