Skip to content

Commit

Permalink
Populate share link if it's already saved
Browse files Browse the repository at this point in the history
  • Loading branch information
whimet committed Nov 4, 2023
1 parent 34bf6e8 commit a9dfadb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions firebase-functions/paddle-webhook/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LARASITE_HOST=18.139.29.58
LARASITE_PORT=8000
LARASITE_HOST=sequence-diagram.zenuml.com
LARASITE_PORT=80
4 changes: 2 additions & 2 deletions firebase-functions/paddle-webhook/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ exports.sync_diagram = functions.https.onRequest(async (req, res) => {
const user = {name: decoded.name, id: decoded.user_id, email: decoded.email, email_verified: decoded.email_verified, picture: decoded.picture};

const options = {
hostname: process.env.LARASITE_HOST || '18.139.29.58',
port: process.env.LARASITE_PORT || 8000,
hostname: process.env.LARASITE_HOST || '18.141.198.134',
port: process.env.LARASITE_PORT || 80,
path: '/diagrams',
method: 'POST',
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ContentWrap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ export default class ContentWrap extends Component {
</Button>
}
content={
<SharePanel id={0} dsl={''} image={''} />
<SharePanel id={0} dsl={''} image={''} shareLink={this.props.currentItem.shareLink} />
}
/>
<Button
Expand Down
20 changes: 13 additions & 7 deletions src/components/SharePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ export class SharePanel extends Component {
}

componentDidMount() {
// TODO: API call to get the link
setTimeout(() => {
this.setState({
isLoading: false,
link: 'https://sequencediagram.zenuml.com/preview/1234',
})
}, 3000);
this.setState({
isLoading: false,
link: this.props.shareLink || 'https://sequencediagram.zenuml.com/preview/1234',
});

// TODO: API call to get the link if props.shareLink is not present
// setTimeout(() => {
// this.setState({
// isLoading: false,
// link: props.shareLink || 'https://sequencediagram.zenuml.com/preview/1234',
// })
// }, 3000);
}

handleCopyLink = () => {
Expand Down Expand Up @@ -74,4 +79,5 @@ SharePanel.propTypes = {
dsl: PropTypes.string,
email: PropTypes.string,
image: PropTypes.string,
shareLink: PropTypes.string,
};
14 changes: 2 additions & 12 deletions src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
handleDownloadsPermission,
downloadFile,
getCompleteHtml,
getFilenameFromUrl
getFilenameFromUrl,
blobToBase64
} from '../utils';
import { itemService } from '../itemService';
import '../db';
Expand Down Expand Up @@ -740,17 +741,6 @@ BookLibService.Borrow(id) {
}

async saveCode(key) {

const blobToBase64 = (blob) => {
const reader = new FileReader();
reader.readAsDataURL(blob);
return new Promise(resolve => {
reader.onloadend = () => {
resolve(reader.result);
};
});
};

const imageBlob = await this.contentWrap.getPngBlob();

this.state.currentItem.imageBase64 = await blobToBase64(imageBlob);
Expand Down
10 changes: 10 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,16 @@ export function getFilenameFromUrl(url) {
return url.match(/\/([^/]*)$/)[1];
}

export function blobToBase64(blob) {
const reader = new FileReader();
reader.readAsDataURL(blob);
return new Promise(resolve => {
reader.onloadend = () => {
resolve(reader.result);
};
});
}

if (window.IS_EXTENSION) {
document.body.classList.add('is-extension');
} else {
Expand Down

0 comments on commit a9dfadb

Please sign in to comment.