File tree Expand file tree Collapse file tree 6 files changed +29
-1
lines changed
Expand file tree Collapse file tree 6 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ import {
124124import { ranges , ThisWeekRange } from ' ../utils/date' ;
125125import { useImportToCsv } from ' ../compositions/toCsv' ;
126126import { FileType , useFile } from ' ../compositions/loadFile' ;
127+ import { removeAllData } from ' ../compositions/remove-all-data' ;
127128
128129const { t } = useI18n ();
129130
@@ -195,7 +196,8 @@ async function removeAll() {
195196 needToConfirmDeleteAllData .value = true ;
196197}
197198
198- function removeAllConfirm() {
199+ async function removeAllConfirm() {
200+ await removeAllData ();
199201 needToConfirmDeleteAllData .value = false ;
200202}
201203
Original file line number Diff line number Diff line change 1+ import Browser from 'webextension-polyfill' ;
2+ import { injecStorage } from '../storage/inject-storage' ;
3+ import { Messages } from '../utils/messages' ;
4+
5+ export async function removeAllData ( ) {
6+ const storage = injecStorage ( ) ;
7+ await storage . saveIntervalList ( [ ] ) ;
8+
9+ Browser . runtime . sendMessage ( Messages . ClearAllData ) ;
10+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Tab } from '../entity/tab';
22
33export interface ITabsRepository {
44 getTabs ( ) : Tab [ ] ;
5+ removeAllTabs ( ) : void ;
56 getTodayTabs ( ) : Tab [ ] ;
67 getTab ( domain : string ) : Tab | undefined ;
78 addTab ( domain : string , favicon : string | undefined ) : Promise < Tab | undefined > ;
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ export class TabsRepository implements ITabsRepository {
2020 return this . tabs ;
2121 }
2222
23+ removeAllTabs ( ) : void {
24+ this . tabs = [ ] ;
25+ }
26+
2327 getTodayTabs ( ) : Tab [ ] {
2428 return this . tabs . filter ( x => x . days . find ( s => s . date === todayLocalDate ( ) ) ) ;
2529 }
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { convertSummaryTimeToBadgeString } from './utils/converter';
1616import { Settings } from './compositions/settings' ;
1717import { isNeedToShowNotification } from './compositions/notification-list' ;
1818import { NotificationType , showNotification } from './compositions/show-notification' ;
19+ import { Messages } from './utils/messages' ;
1920
2021const activeTabInstance = ActiveTab . getInstance ( ) ;
2122
@@ -160,3 +161,12 @@ async function saveTabs() {
160161 const tabs = repo . getTabs ( ) ;
161162 await storage . saveTabs ( tabs ) ;
162163}
164+
165+ Browser . runtime . onMessage . addListener ( async message => {
166+ if ( message == Messages . ClearAllData ) {
167+ const storage = injecStorage ( ) ;
168+ const repo = await injectTabsRepositorySingleton ( ) ;
169+ repo . removeAllTabs ( ) ;
170+ await storage . saveTabs ( [ ] ) ;
171+ }
172+ } ) ;
Original file line number Diff line number Diff line change 11export enum Messages {
22 RescheduleJobs = 'reschedule-jobs' ,
3+ ClearAllData = 'clear-data' ,
34}
You can’t perform that action at this time.
0 commit comments