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 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C-939] Refactor discord modal (#1838)
- Loading branch information
1 parent
b76854f
commit f4160e9
Showing
24 changed files
with
239 additions
and
174 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { call, put, select, takeLatest } from 'typed-redux-saga' | ||
|
||
import { getContext } from '../../effects' | ||
import { setVisibility } from '../modals/slice' | ||
|
||
import { getDiscordCode } from './selectors' | ||
import { pressDiscord, setDiscordCode } from './slice' | ||
|
||
const getSignableData = () => { | ||
const vals = 'abcdefghijklmnopqrstuvwxyz123456789' | ||
return vals.charAt(Math.floor(Math.random() * vals.length)) | ||
} | ||
|
||
function* fetchDiscordCode() { | ||
const discordCode = yield* select(getDiscordCode) | ||
if (!discordCode) { | ||
const audiusBackendInstance = yield* getContext('audiusBackendInstance') | ||
yield* call(audiusBackendInstance.waitForWeb3) | ||
const data = getSignableData() | ||
const signature = yield* call(audiusBackendInstance.getSignature, data) | ||
const appended = `${signature}:${data}` | ||
yield* put(setDiscordCode({ code: appended })) | ||
} | ||
|
||
yield* put(setVisibility({ modal: 'VipDiscord', visible: true })) | ||
} | ||
|
||
function* watchPressDiscord() { | ||
yield* takeLatest(pressDiscord.type, fetchDiscordCode) | ||
} | ||
|
||
export default function sagas() { | ||
return [watchPressDiscord] | ||
} |
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,4 @@ | ||
import { CommonState } from '../../commonStore' | ||
|
||
export const getDiscordCode = (state: CommonState) => | ||
state.ui.vipDiscordModal.discordCode |
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,27 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit' | ||
|
||
import { Nullable } from '../../../utils/typeUtils' | ||
|
||
import { VipDiscordModalState } from './types' | ||
|
||
const initialState: VipDiscordModalState = { | ||
discordCode: null | ||
} | ||
|
||
const slice = createSlice({ | ||
name: 'ui/vipDiscordModal', | ||
initialState, | ||
reducers: { | ||
pressDiscord: (_state, _action: PayloadAction<undefined>) => {}, | ||
setDiscordCode: ( | ||
state, | ||
{ payload: { code } }: PayloadAction<{ code: Nullable<string> }> | ||
) => { | ||
state.discordCode = code | ||
} | ||
} | ||
}) | ||
|
||
export const { pressDiscord, setDiscordCode } = slice.actions | ||
export const actions = slice.actions | ||
export default slice.reducer |
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,5 @@ | ||
import { Nullable } from '../../../utils/typeUtils' | ||
|
||
export type VipDiscordModalState = { | ||
discordCode: Nullable<string> | ||
} |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './VipDiscordDrawer' |
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 |
---|---|---|
|
@@ -59,10 +59,6 @@ | |
fill: var(--neutral-light-4); | ||
} | ||
|
||
.discordDrawerTitle { | ||
margin-top: 24px; | ||
} | ||
|
||
.converting { | ||
margin-right: 6px; | ||
} |
Oops, something went wrong.