Skip to content

Commit 0d53469

Browse files
committed
test: fix
1 parent a8e635d commit 0d53469

9 files changed

Lines changed: 122 additions & 59 deletions

File tree

.github/actions/build-and-test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ runs:
3535
sudo wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/microsoft.gpg
3636
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main"
3737
sudo apt-get update
38-
sudo apt-get install -y microsoft-edge-stable=138.0.3351.109-1
38+
sudo apt-get install -y microsoft-edge-stable=143.0.3650.96-1
3939
microsoft-edge --version
4040
EDGE_PATH=$(which microsoft-edge)
4141
echo "edge-path=$EDGE_PATH" >> $GITHUB_OUTPUT

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"lodash": "^4.17.21",
6969
"mocha": "^11.7.1",
7070
"prettier": "^3.3.2",
71-
"puppeteer": "^24.15.0",
71+
"puppeteer": "^24.34.0",
7272
"resolve": "^1.22.10",
7373
"rimraf": "^6.0.1",
7474
"sign-addon": "^6.4.0",

pnpm-lock.yaml

Lines changed: 64 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pages/background/core/task.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { apply as applyJsonLogic } from 'json-logic-js';
22
import { cloneDeep, pick } from 'lodash-es';
3-
import { TABLE_NAME_TASKS } from '@/share/core/constant';
3+
import { APIs, EVENTs, TABLE_NAME_TASKS } from '@/share/core/constant';
44
import emitter from '@/share/core/emitter';
55
import logger from '@/share/core/logger';
6+
import notify from '@/share/core/notify';
67
import { getLocal, getSession, readStorage } from '@/share/core/storage';
78
import type { Task, TaskRun } from '@/share/core/types';
89
import { sleep } from '@/share/core/utils';
@@ -86,7 +87,12 @@ export async function saveTask(taskInfo: Task) {
8687
);
8788
Object.assign(original, copy);
8889
await pifyIDBRequest(os.put(original));
89-
emitter.emit(emitter.INNER_TASK_UPDATE, { task: original });
90+
emitter.emit(emitter.INNER_TASK_UPDATE, original);
91+
notify.other({
92+
method: APIs.ON_EVENT,
93+
event: EVENTs.TASK_SAVE,
94+
task: original,
95+
});
9096
if (cachedTasks[taskInfo.key]) {
9197
cachedTasks[taskInfo.key] = taskInfo;
9298
}
@@ -95,7 +101,12 @@ export async function saveTask(taskInfo: Task) {
95101

96102
// Create
97103
await pifyIDBRequest(os.add(taskInfo));
98-
emitter.emit(emitter.INNER_TASK_UPDATE, { task: taskInfo });
104+
emitter.emit(emitter.INNER_TASK_UPDATE, taskInfo);
105+
notify.other({
106+
method: APIs.ON_EVENT,
107+
event: EVENTs.TASK_SAVE,
108+
task: taskInfo,
109+
});
99110
if (cachedTasks[taskInfo.key]) {
100111
cachedTasks[taskInfo.key] = taskInfo;
101112
}
@@ -126,6 +137,11 @@ export async function removeTask(key: string) {
126137
if (k.length > 0) getLocal().remove(k);
127138
});
128139
}
140+
notify.other({
141+
method: APIs.ON_EVENT,
142+
event: EVENTs.TASK_DELETE,
143+
key,
144+
});
129145
emitter.emit(emitter.INNER_TASK_REMOVE, { key });
130146
}
131147

src/pages/options/sections/tasks/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ import { css } from '@emotion/css';
2222
import { useRequest } from 'ahooks';
2323
import dayjs from 'dayjs';
2424
import { cloneDeep } from 'lodash-es';
25-
import { useState } from 'react';
25+
import { useEffect, useState } from 'react';
2626
import Modal from '@/share/components/modal';
27+
import { EVENTs } from '@/share/core/constant';
28+
import notify from '@/share/core/notify';
2729
import type { Task } from '@/share/core/types';
2830
import { t } from '@/share/core/utils';
2931
import Api from '@/share/pages/api';
@@ -125,6 +127,16 @@ const Tasks = () => {
125127
manual: false,
126128
});
127129

130+
useEffect(() => {
131+
notify.event.on(EVENTs.TASK_SAVE, refresh);
132+
notify.event.on(EVENTs.TASK_DELETE, refresh);
133+
134+
return () => {
135+
notify.event.off(EVENTs.TASK_SAVE, refresh);
136+
notify.event.off(EVENTs.TASK_DELETE, refresh);
137+
};
138+
}, []);
139+
128140
return (
129141
<Layout
130142
title={t('tasks')}

src/share/core/constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export enum IS_MATCH {
7575
export enum EVENTs {
7676
RULE_UPDATE = 'rule_update',
7777
RULE_DELETE = 'rule_delete',
78+
TASK_SAVE = 'task_save',
79+
TASK_DELETE = 'task_del',
7880
}
7981

8082
export const ALL_RESOURCE_TYPES: DeclarativeNetRequest.ResourceType[] = [

0 commit comments

Comments
 (0)