1
1
import { Messages , WordMap , WordInfoMap , WordContext , StorageKey , LevelKey } from '../constant'
2
2
import { explainWord } from '../lib/openai'
3
- import { syncUpKnowns , getLocalValue , getAllKnownSync , addLocalKnownsLogs , removeLocalKnownsLogs } from '../lib/storage'
3
+ import { syncUpKnowns , getLocalValue , getAllKnownSync } from '../lib/storage'
4
4
import { settings } from '../lib/settings'
5
5
import { triggerGoogleDriveSyncJob , syncWithDrive } from '../lib/backup/sync'
6
6
@@ -98,9 +98,11 @@ const checkOffscreenDocumentExist = async (offscreenUrl: string) => {
98
98
if ( chrome . runtime . getContexts ) {
99
99
// @ts -ignore
100
100
const existingContexts = await chrome . runtime . getContexts ( {
101
+ // @ts -ignore
101
102
contextTypes : [ 'OFFSCREEN_DOCUMENT' ] ,
102
103
documentUrls : [ offscreenUrl ]
103
104
} )
105
+ // @ts -ignore
104
106
return existingContexts . length > 0
105
107
// @ts -ignore
106
108
} else if ( globalThis . clients ) {
@@ -173,7 +175,6 @@ chrome.runtime.onConnect.addListener(async port => {
173
175
updateBadge ( knowns )
174
176
sendMessageToAllTabs ( { action, word } )
175
177
triggerGoogleDriveSyncJob ( )
176
- addLocalKnownsLogs ( [ word ] )
177
178
break
178
179
case Messages . set_all_known :
179
180
const addedWords = words . reduce ( ( acc : WordMap , cur : string ) => ( { ...acc , [ cur ] : 'o' } ) , { } )
@@ -182,7 +183,6 @@ chrome.runtime.onConnect.addListener(async port => {
182
183
updateBadge ( knowns )
183
184
sendMessageToAllTabs ( { action, words } )
184
185
triggerGoogleDriveSyncJob ( )
185
- addLocalKnownsLogs ( words )
186
186
break
187
187
case Messages . add_context : {
188
188
const contexts = ( await getLocalValue ( StorageKey . context ) ) ?? { }
@@ -219,11 +219,6 @@ chrome.runtime.onConnect.addListener(async port => {
219
219
case Messages . play_audio :
220
220
playAudio ( msg . audio , word )
221
221
break
222
- case Messages . open_youglish :
223
- chrome . tabs . create ( {
224
- url : chrome . runtime . getURL ( 'youglish.html' ) + `?word=${ encodeURIComponent ( word ) } `
225
- } )
226
- break
227
222
case Messages . fetch_html : {
228
223
const { url, uuid } = msg
229
224
const htmlRes = await fetch ( url , {
@@ -321,7 +316,6 @@ chrome.contextMenus.onClicked.addListener(async (info, tab) => {
321
316
updateBadge ( knowns )
322
317
sendMessageToAllTabs ( { action : Messages . set_unknown , word : originFormWord } )
323
318
triggerGoogleDriveSyncJob ( )
324
- removeLocalKnownsLogs ( originFormWord )
325
319
}
326
320
}
327
321
} )
0 commit comments