Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/reactant-router/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable consistent-return */
import React, { PropsWithChildren, FunctionComponent } from 'react';
import { PluginModule, injectable, inject, storeKey } from 'reactant-module';
import { ReducersMapObject, Store } from 'redux';
import type { ReducersMapObject, Store } from 'redux';
import {
connectRouter,
ConnectedRouter,
Expand Down
10 changes: 5 additions & 5 deletions packages/reactant-share/src/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type LockCallBack = (lock: {
}) => Promise<void>;
type LockQueue = { tabId: string; lockId: string }[];

const lockMap: Record<LockName, Record<LockId, LockCallBack>> = {};
const lockMap: Map<LockName, Map<LockId, LockCallBack>> = new Map();
const tabId = createId();
const lockStorageKey = 'reactant:lock';
const tabStorageKey = 'reactant:tab';
Expand Down Expand Up @@ -97,8 +97,8 @@ const simpleLock = (name: LockName, callback: LockCallBack) => {

return new Promise((resolve, reject) => {
const lockId = createId();
lockMap[name] ??= {};
lockMap[name][lockId] = callback;
lockMap.set(name, lockMap.get(name) ?? new Map());
lockMap.get(name)!.set(lockId, callback);
const storageKey = `${lockStorageKey}:${name}`;
const oldStorageValue = localStorage.getItem(storageKey);
const lockQueue: LockQueue = JSON.parse(oldStorageValue ?? '[]');
Expand All @@ -109,15 +109,15 @@ const simpleLock = (name: LockName, callback: LockCallBack) => {
if (lock?.tabId === tabId && lock?.lockId === lockId) {
window.removeEventListener('storage', listener);
try {
const result = await lockMap[name][lockId]({
const result = await lockMap.get(name)!.get(lockId)!({
name,
mode: 'exclusive',
});
resolve(result);
} catch (e) {
reject(e);
}
delete lockMap[name][lockId];
lockMap.get(name)!.delete(lockId);
const currentLockQueue: LockQueue = JSON.parse(
localStorage.getItem(storageKey) ?? '[]'
);
Expand Down