Skip to content

Commit 4e1fe89

Browse files
committed
load username from projectMETA
1 parent 7ee178b commit 4e1fe89

3 files changed

Lines changed: 10 additions & 22 deletions

File tree

‎src/components/gui/gui.jsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const GUIComponent = props => {
186186
<React.Fragment>
187187
<TWSecurityManager securityManager={securityManager} />
188188
<TWRestorePointManager />
189-
{usernameModalVisible && <TWUsernameModal />}
189+
{/*usernameModalVisible && <TWUsernameModal />*/}
190190
{settingsModalVisible && <TWSettingsModal />}
191191
{customExtensionModalVisible && <TWCustomExtensionModal />}
192192
{fontsModalVisible && <TWFontsModal />}

‎src/lib/tw-project-meta-fetcher-hoc.jsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import log from './log';
77
const {API_HOST} = require('./brand');
88

99
import {setProjectTitle} from '../reducers/project-title';
10-
import {setAuthor, setDescription} from '../reducers/tw';
10+
import {setAuthor, setDescription,setUsername} from '../reducers/tw';
1111

1212
export const fetchProjectMeta = async projectId => {
1313
const urls = [
@@ -72,6 +72,10 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) {
7272
if (title) {
7373
this.props.onSetProjectTitle(title);
7474
}
75+
const username = data.username;
76+
if (username) {
77+
this.props.onSetUsername(username);
78+
}
7579
const authorName = data.author.username;
7680
const authorThumbnail = `https://trampoline.turbowarp.org/avatars/${data.author.id}`;
7781
this.props.onSetAuthor(authorName, authorThumbnail);
@@ -99,7 +103,8 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) {
99103
onSetAuthor,
100104
onSetDescription,
101105
onSetProjectTitle,
102-
/* eslint-enable no-unused-vars */
106+
onSetUsername,
107+
/* eslint-enable no-unused-vars */
103108
...props
104109
} = this.props;
105110
return (
@@ -127,7 +132,8 @@ const TWProjectMetaFetcherHOC = function (WrappedComponent) {
127132
instructions,
128133
credits
129134
})),
130-
onSetProjectTitle: title => dispatch(setProjectTitle(title))
135+
onSetProjectTitle: title => dispatch(setProjectTitle(title)),
136+
onSetUsername: username => dispatch(setUsername(username))
131137
});
132138
return connect(
133139
mapStateToProps,

‎src/lib/tw-state-manager-hoc.jsx‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -308,24 +308,6 @@ const TWStateManager = function (WrappedComponent) {
308308
this.props.vm.setInterpolation(true);
309309
}
310310

311-
if (urlParams.has('username')) {
312-
const username = urlParams.get('username');
313-
// Do not save username when loaded from URL
314-
this.doNotPersistUsername = username;
315-
this.props.onSetUsername(username);
316-
} else {
317-
const persistentUsername = this.props.isEmbedded ? null : getLocalStorage(USERNAME_KEY);
318-
if (persistentUsername === null) {
319-
const randomUsername = generateRandomUsername();
320-
this.props.onSetUsername(randomUsername);
321-
if (this.props.isEmbedded) {
322-
this.doNotPersistUsername = randomUsername;
323-
}
324-
} else {
325-
this.props.onSetUsername(persistentUsername);
326-
}
327-
}
328-
329311
if (urlParams.has('hqpen')) {
330312
this.props.vm.renderer.setUseHighQualityRender(true);
331313
}

0 commit comments

Comments
 (0)