Security handening
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { selectedSheet, currentStep, columnMapping } from '$lib/stores';
|
||||
import type { ColumnMappingType, SheetInfoType } from '$lib/stores';
|
||||
import { getSheetNames, getSheetData } from '$lib/google';
|
||||
import { getSheetNames, getSheetData, ensureToken } from '$lib/google';
|
||||
import { onMount } from 'svelte';
|
||||
import Navigator from './subcomponents/Navigator.svelte';
|
||||
|
||||
@@ -35,13 +35,16 @@
|
||||
{ key: 'alreadyPrinted', label: 'Already Printed', required: false }
|
||||
];
|
||||
|
||||
const RECENT_SHEETS_KEY = 'recentSheets';
|
||||
|
||||
// Load available sheets when component mounts
|
||||
onMount(async () => {
|
||||
ensureToken();
|
||||
if ($selectedSheet) {
|
||||
console.log('Selected sheet on mount:', $selectedSheet);
|
||||
|
||||
// Check if we already have saved mapping data
|
||||
const recentSheetsData = localStorage.getItem('recent-sheets');
|
||||
const recentSheetsData = localStorage.getItem(RECENT_SHEETS_KEY);
|
||||
|
||||
if (recentSheetsData) {
|
||||
try {
|
||||
@@ -245,8 +248,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
const recentSheetsKey = 'recent-sheets';
|
||||
const existingData = localStorage.getItem(recentSheetsKey);
|
||||
const existingData = localStorage.getItem(RECENT_SHEETS_KEY);
|
||||
|
||||
if (existingData) {
|
||||
const recentSheets = JSON.parse(existingData);
|
||||
@@ -331,8 +333,7 @@
|
||||
|
||||
// Save column mapping to localStorage for the selected sheet
|
||||
try {
|
||||
const recentSheetsKey = 'recent-sheets';
|
||||
const existingData = localStorage.getItem(recentSheetsKey);
|
||||
const existingData = localStorage.getItem(RECENT_SHEETS_KEY);
|
||||
let recentSheets = existingData ? JSON.parse(existingData) : [];
|
||||
|
||||
// Find the current sheet in recent sheets and update its column mapping
|
||||
@@ -374,7 +375,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
localStorage.setItem(recentSheetsKey, JSON.stringify(recentSheets));
|
||||
localStorage.setItem(RECENT_SHEETS_KEY, JSON.stringify(recentSheets));
|
||||
} catch (err) {
|
||||
console.error('Failed to save column mapping to localStorage:', err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user