Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AmolSoans committed Nov 26, 2024
1 parent 7ad802f commit 09f82ff
Show file tree
Hide file tree
Showing 30 changed files with 594 additions and 1,010 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,4 @@ dist
node_modules/
package-lock.json
.DS_Store
.env
37 changes: 35 additions & 2 deletions background/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NseIndia } from 'stock-nse-india';
//import { NseIndia } from 'stock-nse-india';
import { createClient } from '@supabase/supabase-js'
//const nseIndia = new NseIndia();
// Constants
const CACHE_DURATION = 24 * 60 * 60 * 1000; // 24 hours in milliseconds
Expand All @@ -9,12 +10,44 @@ const CACHE_CONFIG = {
version: '1.0',
maxItems: 500 // Limit cache size
};

const supabase = createClient(
'YOUR_SUPABASE_URL',
'YOUR_SUPABASE_ANON_KEY'
)
// Initialize extension
chrome.runtime.onInstalled.addListener(async () => {
console.log('Trade Call Widget installed/updated');
await initializeCache();
await cacheAllStockSymbols(); // Cache stock symbols on installation
await checkAuth();
});

// Check auth state when extension opens
chrome.runtime.onStartup.addListener(async() => {
await checkAuth();
});

async function checkAuth() {
const { data: { session }, error } = await supabase.auth.getSession();

if (error || !session) {
// If not authenticated, open auth popup
chrome.windows.create({
url: 'auth.html',
type: 'popup',
width: 400,
height: 600
});
}
}

// Listen for messages from auth popup
chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => {
if (message.type === 'AUTH_SUCCESS') {
// Close auth window and refresh main extension
chrome.windows.remove(sender.tab.windowId);
chrome.runtime.reload();
}
});

// Function to cache all stock symbols
Expand Down
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"permissions": [
"storage",
"clipboardWrite",
"sidePanel"
"sidePanel",
"identity"
],
"web_accessible_resources": [{
"resources": ["dist/popup.css"],
Expand Down
Loading

0 comments on commit 09f82ff

Please sign in to comment.