Skip to content

Commit 31ab4f8

Browse files
authored
Merge pull request #1 from jwklong/new-api-integration
just,,, ingetragte
2 parents 37903d1 + bfff2d6 commit 31ab4f8

File tree

11 files changed

+686
-31
lines changed

11 files changed

+686
-31
lines changed

src/components/menu-bar/share-button.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ const getProjectUri = () => new Promise(resolve => {
2828
const isUploadAvailable = async () => {
2929
let res = null;
3030
try {
31-
res = await fetch('https://projects.penguinmod.com/api');
31+
res = await fetch('https://projects.penguinmod.com/api/v1/projects/canuploadprojects').then(res => res.json());
3232
} catch {
3333
// failed to fetch entirely
3434
return false;
3535
}
36-
return res.ok;
36+
return res.canUpload;
3737
};
3838

3939
class ShareButton extends React.Component {
@@ -60,7 +60,7 @@ class ShareButton extends React.Component {
6060
this.handleMessageEvent(e);
6161
}
6262
async handleMessageEvent(e) {
63-
if (!e.origin.startsWith(`https://penguinmod.com`)) {
63+
if (!e.origin.startsWith(`https://penguinmod-home-git-new-backend-live-penguinmod.vercel.app/`)) {
6464
return;
6565
}
6666

@@ -148,7 +148,7 @@ class ShareButton extends React.Component {
148148
}
149149

150150
const url = location.origin;
151-
window.open(`https://penguinmod.com/${targetPage}?name=${this.props.projectTitle}${editPiece}${remixPiece}&external=${url}`, '_blank');
151+
window.open(`https://penguinmod-home-git-new-backend-live-penguinmod.vercel.app//${targetPage}?name=${this.props.projectTitle}${editPiece}${remixPiece}&external=${url}`, '_blank');
152152
});
153153
}
154154
render() {

src/components/tw-studioview/studioview.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import classNames from 'classnames';
1111
/**
1212
* @class
1313
*/
14-
var StudioView = function (studioId) {
15-
this.studioId = studioId;
14+
var StudioView = function () {
1615
this.offset = 0;
1716
this.ended = false;
1817
this.loadingPage = false;
@@ -243,7 +242,7 @@ StudioView.prototype.loadNextPage = function () {
243242
var xhr = new XMLHttpRequest();
244243
xhr.responseType = 'json';
245244
xhr.onload = function () {
246-
var rawProjects = xhr.response.projects;
245+
var rawProjects = xhr.response;
247246
if (!Array.isArray(rawProjects)) {
248247
xhr.onerror();
249248
return;
@@ -253,7 +252,7 @@ StudioView.prototype.loadNextPage = function () {
253252
var p = rawProjects[i];
254253
projects.push({
255254
id: p.id,
256-
title: p.name,
255+
title: p.title,
257256
author: p.author.username,
258257
featured: p.featured,
259258
});
@@ -287,7 +286,7 @@ StudioView.prototype.loadNextPage = function () {
287286
this.ended = true;
288287
}.bind(this);
289288

290-
var url = StudioView.STUDIO_API + "/pmWrapper/projects"
289+
var url = StudioView.STUDIO_API + "/projects/getprojects"
291290
xhr.open('GET', url);
292291
xhr.send();
293292
};
@@ -300,11 +299,11 @@ StudioView.prototype.onselect = function (id, el) { };
300299
StudioView.prototype.onpageload = function () { };
301300
StudioView.prototype.onend = function () { };
302301

303-
StudioView.STUDIO_API = 'https://projects.penguinmod.com/api';
302+
StudioView.STUDIO_API = 'https://projects.penguinmod.com/api/v1';
304303

305304
// The URL to download thumbnails from.
306305
// $id is replaced with the project's ID.
307-
StudioView.THUMBNAIL_SRC = 'https://projects.penguinmod.com/api/pmWrapper/iconUrl?id=$id';
306+
StudioView.THUMBNAIL_SRC = 'https://projects.penguinmod.com/api/v1/projects/getproject?projectID=$id&requestType=thumbnail';
308307

309308
// The URL for project pages.
310309
// $id is replaced with the project ID.

src/components/tw-studioview/studioview.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class StudioViewComponent extends React.Component {
3434
]);
3535
}
3636
componentDidMount () {
37-
this.studioView = new StudioView(this.props.id);
37+
this.studioView = new StudioView();
3838
this.studioView.messages.AUTHOR_ATTRIBUTION = this.props.intl.formatMessage(messages.authorAttribution, {
3939
// studioview uses $-based variables
4040
author: '$author'
@@ -77,7 +77,6 @@ class StudioViewComponent extends React.Component {
7777
}
7878

7979
StudioViewComponent.propTypes = {
80-
id: PropTypes.string.isRequired,
8180
intl: intlShape.isRequired,
8281
placeholder: PropTypes.bool,
8382
onSelect: PropTypes.func.isRequired

src/containers/home-communication.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {connect} from 'react-redux';
55
import {setUsername, setUsernameInvalid, setUsernameLoggedIn} from '../reducers/tw';
66

77
let origin = "https://penguinmod.com";
8-
// origin = 'http://localhost:5173';
8+
// origin = 'https://penguinmod-home-git-new-backend-live-penguinmod.vercel.app/';
99

1010
class HomeCommunication extends React.Component {
1111
constructor (props) {

src/containers/tw-security-manager.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const isTrustedExtension = url => (
3434
url.startsWith('http://localhost:8000') ||
3535
url.startsWith('http://localhost:6000') || // Launcher Home
3636
url.startsWith('http://localhost:6001') || // Launcher Extensions
37-
url.startsWith('http://localhost:5173') || // Local Home or Extensions
37+
url.startsWith('https://penguinmod-home-git-new-backend-live-penguinmod.vercel.app/') || // Local Home or Extensions
3838
url.startsWith('http://localhost:5174') || // Local Home or Extensions
3939

4040
extensionsTrustedByUser.has(url)

src/lib/pbf.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)