File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " commitcrawler " : patch
3+ ---
4+
5+ 다중 탭 정보 읽기 데이터 불일치 문제 수정
Original file line number Diff line number Diff line change @@ -15,11 +15,18 @@ const commitInterceptorService = new CommitInterceptorService(
1515 debuggerService
1616) ;
1717
18- // 디버거 설정 및 페이지 리로드
1918chrome . runtime . onMessage . addListener (
20- ( message : MessagePayload , sender , sendResponse ) => {
19+ ( message : MessagePayload < { targetTabId : number } > , sender , sendResponse ) => {
2120 if ( message . action === "START_INTERCEPTOR_COMMIT" ) {
22- commitInterceptorService . initializeCommitInterceptor ( sendResponse ) ;
21+ const targetTabId = message . data ?. targetTabId ;
22+ if ( ! targetTabId ) {
23+ sendResponse ( { status : "error" , message : "탭 ID가 없습니다." } ) ;
24+ return true ;
25+ }
26+ commitInterceptorService . initializeCommitInterceptor (
27+ sendResponse ,
28+ targetTabId
29+ ) ;
2330 return true ;
2431 }
2532 }
Original file line number Diff line number Diff line change @@ -323,17 +323,21 @@ const showToast = (
323323const handleStartInterceptorCommit = async (
324324 elements : StatusElements
325325) : Promise < void > => {
326- const { button, status } = elements ;
326+ const { button } = elements ;
327327 button . disabled = true ;
328328
329329 try {
330330 const [ tab ] = await chrome . tabs . query ( {
331331 active : true ,
332332 currentWindow : true ,
333333 } ) ;
334+ if ( ! tab ?. id ) {
335+ throw new Error ( "활성 탭을 찾을 수 없습니다." ) ;
336+ }
334337
335338 const response = await MessageDispatcher . sendSuccess (
336- "START_INTERCEPTOR_COMMIT"
339+ "START_INTERCEPTOR_COMMIT" ,
340+ { targetTabId : tab . id }
337341 ) ;
338342
339343 if ( response . status === "success" ) {
Original file line number Diff line number Diff line change @@ -12,40 +12,21 @@ export class CommitInterceptorService {
1212 return this . taskExecutionController . isTaskExecution ;
1313 }
1414
15- async initializeCommitInterceptor ( sendResponse : ( response : any ) => void ) {
15+ async initializeCommitInterceptor (
16+ sendResponse : ( response : any ) => void ,
17+ tabId : number
18+ ) {
1619 try {
17- const tab = await this . getActiveTab ( ) ;
18- await this . initializeDebugger ( tab . id ) ;
19- this . setupTimeoutHandler ( tab . id ) ;
20- await this . reloadTab ( tab . id ) ;
20+ await this . initializeDebugger ( tabId ) ;
21+ this . setupTimeoutHandler ( tabId ) ;
22+ await this . reloadTab ( tabId ) ;
2123
2224 sendResponse ( { status : "success" } ) ;
2325 } catch ( error ) {
2426 this . handleError ( error ) ;
2527 }
2628 }
2729
28- private async getActiveTab ( ) : Promise < chrome . tabs . Tab > {
29- return new Promise ( ( resolve , reject ) => {
30- chrome . windows . getCurrent ( async ( window ) => {
31- try {
32- const [ tab ] = await chrome . tabs . query ( {
33- active : true ,
34- windowId : window . id ,
35- } ) ;
36-
37- if ( ! tab ?. id ) {
38- throw new Error ( "활성 탭을 찾을 수 없습니다." ) ;
39- }
40-
41- resolve ( tab ) ;
42- } catch ( error ) {
43- reject ( error ) ;
44- }
45- } ) ;
46- } ) ;
47- }
48-
4930 private async initializeDebugger ( tabId : number ) {
5031 this . taskExecutionController . startTaskExecution ( ) ;
5132 await this . debuggerService . attach ( tabId ) ;
Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ interface MessageResponse {
1313 error ?: string ;
1414}
1515
16- interface SuccessPayload {
16+ interface SuccessPayload < T = unknown > {
1717 type : "success" ;
1818 action : SuccessMessageType ;
19- data ?: unknown ;
19+ data ?: T ;
2020}
2121
2222interface ErrorPayload {
@@ -25,13 +25,13 @@ interface ErrorPayload {
2525 error ?: string ;
2626}
2727
28- export type MessagePayload = SuccessPayload | ErrorPayload ;
28+ export type MessagePayload < T = unknown > = SuccessPayload < T > | ErrorPayload ;
2929
3030/**
3131 * Chrome 확장 프로그램의 메시지 통신을 처리
3232 */
3333export class MessageDispatcher {
34- static sendSuccess ( action : SuccessMessageType , data ?: unknown ) {
34+ static sendSuccess < T = unknown > ( action : SuccessMessageType , data ?: T ) {
3535 return this . dispatch ( {
3636 type : "success" ,
3737 action,
@@ -47,7 +47,9 @@ export class MessageDispatcher {
4747 } ) ;
4848 }
4949
50- private static dispatch ( payload : MessagePayload ) {
51- return chrome . runtime . sendMessage < MessagePayload , MessageResponse > ( payload ) ;
50+ private static dispatch < T = unknown > ( payload : MessagePayload < T > ) {
51+ return chrome . runtime . sendMessage < MessagePayload < T > , MessageResponse > (
52+ payload
53+ ) ;
5254 }
5355}
You can’t perform that action at this time.
0 commit comments