Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/components/SavedItemPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ export default class SavedItemPane extends Component {
super(props);
this.items = [];
this.state = {
searchText: null
searchText: null,
};
}
componentWillUpdate(nextProps) {
console.log('component will update');
if (this.props.items !== nextProps.items) {
this.items = Object.values(nextProps.items);
this.items.sort(function(a, b) {
this.items.sort(function (a, b) {
return b.updatedOn - a.updatedOn;
});
}
Expand Down Expand Up @@ -90,7 +89,7 @@ export default class SavedItemPane extends Component {
var file = e.target.files[0];

var reader = new FileReader();
reader.addEventListener('load', progressEvent => {
reader.addEventListener('load', (progressEvent) => {
var items;
try {
items = JSON.parse(progressEvent.target.result);
Expand Down Expand Up @@ -123,13 +122,17 @@ export default class SavedItemPane extends Component {
console.log('search input handler');
const text = e.target.value;
await this.setState({
searchText: text
searchText: text,
});
trackEvent('ui', 'searchInputType');
}

filteredItems() {
return this.items.filter(item => !this.state.searchText || item.title.toLowerCase().indexOf(this.state.searchText) !== -1);
return this.items.filter(
(item) =>
!this.state.searchText ||
item.title.toLowerCase().indexOf(this.state.searchText) !== -1
);
}

render() {
Expand Down Expand Up @@ -178,7 +181,7 @@ export default class SavedItemPane extends Component {
{!this.filteredItems().length && this.items.length ? (
<div class="mt-1">No match found.</div>
) : null}
{this.filteredItems().map(item => (
{this.filteredItems().map((item) => (
<ItemTile
item={item}
onClick={this.itemClickHandler.bind(this, item)}
Expand Down
12 changes: 1 addition & 11 deletions src/components/SharePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ export class SharePanel extends Component {
}

async componentDidMount() {
await this.syncDiagram(this.props.currentItem);
}

async componentDidUpdate(prevProps) {
if (prevProps.currentItem !== this.props.currentItem) {
await this.syncDiagram(this.props.currentItem);
}
}

async syncDiagram(currentItem) {
const result = await syncDiagram(currentItem);
const result = await syncDiagram(this.props.currentItem);
if (!result) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/services/syncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import firebase from 'firebase/app';
async function syncDiagram(currentItem) {
const { id, title, js, imageBase64 } = currentItem;
if (!js || !title || !imageBase64) {
console.warn('Cannot sync diagram because of missing data');
return null;
}

Expand Down