-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from dhilt/issue-39-first-last-visible-wanted-…
…part-2 Adapter "wanted" container fixes. Part 2
- Loading branch information
Showing
19 changed files
with
285 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
dist | ||
node_modules | ||
.vscode | ||
*.tgz | ||
*.tgz | ||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { IAdapterProp } from '../../interfaces/index'; | ||
import { AdapterPropName } from './props'; | ||
|
||
interface IWanted { | ||
box: { [key: string]: boolean }; | ||
block: boolean; | ||
} | ||
|
||
const getBox = (id?: number): IWanted['box'] | undefined => { | ||
return wantedStorage.get(id || -1)?.box; | ||
}; | ||
|
||
const setBox = ({ name, wanted }: IAdapterProp, id?: number): boolean => { | ||
const Wanted = wantedStorage.get(id || -1); | ||
if (wanted && Wanted && !Wanted.box[name] && !Wanted.block) { | ||
const { firstVisible: a, firstVisible$: a$ } = AdapterPropName; | ||
const { lastVisible: b, lastVisible$: b$ } = AdapterPropName; | ||
Wanted.box[a] = Wanted.box[a$] = [a, a$].some(n => n === name) || Wanted.box[a]; | ||
Wanted.box[b] = Wanted.box[b$] = [b, b$].some(n => n === name) || Wanted.box[b]; | ||
return true; | ||
} | ||
return false; | ||
}; | ||
|
||
const setBlock = (value: boolean, id?: number): void => { | ||
const Wanted = wantedStorage.get(id || -1); | ||
if (Wanted) { | ||
Wanted.block = value; | ||
} | ||
}; | ||
|
||
export const wantedUtils = { | ||
getBox, | ||
setBox, | ||
setBlock | ||
}; | ||
|
||
export const wantedStorage = new Map<number, IWanted>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.