mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: remove unused pptional chaining
This commit is contained in:
parent
736ca9bc07
commit
a87dd32568
@ -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,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user