This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d6dd35
commit f9ae347
Showing
15 changed files
with
108 additions
and
33 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
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
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
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,44 @@ | ||
import { getRemoteVar, StringKeys } from 'services/remote-config' | ||
import { TrackMetadata } from 'models/Track' | ||
import { waitForRemoteConfig } from 'services/remote-config/Provider' | ||
import { waitForWeb3 } from 'services/AudiusBackend' | ||
|
||
declare global { | ||
interface Window { | ||
Web3: any | ||
} | ||
} | ||
|
||
const IS_WEB_HOSTNAME = | ||
window.location.hostname === process.env.REACT_APP_PUBLIC_HOSTNAME | ||
|
||
let blockList: Set<string> | ||
|
||
const setBlocked = async <T extends TrackMetadata>(track: T) => { | ||
// Initialize the set if not present | ||
if (!blockList) { | ||
await waitForRemoteConfig() | ||
blockList = new Set( | ||
(getRemoteVar(StringKeys.CONTENT_BLOCK_LIST) || '').split(',') | ||
) | ||
} | ||
if (IS_WEB_HOSTNAME) { | ||
await waitForWeb3() | ||
const shaId = window.Web3.utils.sha3(track.track_id.toString()) | ||
if (blockList.has(shaId)) { | ||
return { | ||
...track, | ||
is_delete: true, | ||
_blocked: true | ||
} | ||
} | ||
} | ||
// Most of the time this method is a no-op | ||
return track | ||
} | ||
|
||
export const setTracksIsBlocked = async <T extends TrackMetadata>( | ||
tracks: T[] | ||
): Promise<T[]> => { | ||
return await Promise.all(tracks.map(setBlocked)) | ||
} |
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