fix: remove unused pptional chaining

This commit is contained in:
yassinedorbozgithub 2025-01-30 08:57:41 +01:00
parent 736ca9bc07
commit a87dd32568
2 changed files with 10 additions and 10 deletions

View File

@ -82,7 +82,7 @@ export const BroadcastChannelProvider: FC<IBroadcastChannelProps> = ({
return; return;
} }
subscribersRef.current[payload.event]?.forEach((callback) => subscribersRef.current[payload.event].forEach((callback) =>
callback(data), callback(data),
); );
}; };
@ -100,18 +100,18 @@ export const BroadcastChannelProvider: FC<IBroadcastChannelProps> = ({
callback, callback,
) => { ) => {
subscribersRef.current[event] ??= []; subscribersRef.current[event] ??= [];
subscribersRef.current[event]?.push(callback); subscribersRef.current[event].push(callback);
return () => { return () => {
const index = subscribersRef.current[event]?.indexOf(callback) ?? -1; const index = subscribersRef.current[event].indexOf(callback) ?? -1;
if (index !== -1) { if (index !== -1) {
subscribersRef.current[event]?.splice(index, 1); subscribersRef.current[event].splice(index, 1);
} }
}; };
}; };
const postMessage: IBroadcastChannelContext["postMessage"] = (payload) => { const postMessage: IBroadcastChannelContext["postMessage"] = (payload) => {
channelRef.current?.postMessage({ channelRef.current.postMessage({
tabId: tabUuid, tabId: tabUuid,
payload, payload,
}); });

View File

@ -82,7 +82,7 @@ export const BroadcastChannelProvider: FC<IBroadcastChannelProps> = ({
return; return;
} }
subscribersRef.current[payload.event]?.forEach((callback) => subscribersRef.current[payload.event].forEach((callback) =>
callback(data), callback(data),
); );
}; };
@ -102,18 +102,18 @@ export const BroadcastChannelProvider: FC<IBroadcastChannelProps> = ({
callback, callback,
) => { ) => {
subscribersRef.current[event] ??= []; subscribersRef.current[event] ??= [];
subscribersRef.current[event]?.push(callback); subscribersRef.current[event].push(callback);
return () => { return () => {
const index = subscribersRef.current[event]?.indexOf(callback) ?? -1; const index = subscribersRef.current[event].indexOf(callback) ?? -1;
if (index !== -1) { if (index !== -1) {
subscribersRef.current[event]?.splice(index, 1); subscribersRef.current[event].splice(index, 1);
} }
}; };
}; };
const postMessage: IBroadcastChannelContext["postMessage"] = (payload) => { const postMessage: IBroadcastChannelContext["postMessage"] = (payload) => {
channelRef.current?.postMessage({ channelRef.current.postMessage({
tabId: tabUuid, tabId: tabUuid,
payload, payload,
}); });