Skip to content

Commit

Permalink
backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
WuTheFWasThat committed Apr 9, 2017
1 parent f0ba825 commit 68458f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/assets/js/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ export default class DataStore {
return await this._set(this._lineKey_(row), line);
}

// for backwards compatibility - checks whether the line was struck through
// in the old-style format
public async _isStruckThroughOldFormat(row: Row): Promise<boolean> {
const line = await this._get<any>(this._lineKey_(row), []);
if (typeof line !== 'string' && line.length && line[0].properties.strikethrough) {
return true;
}
return false;
}

public async getParents(row: Row): Promise<Array<Row>> {
return await this._get(this._parentsKey_(row), [], decodeParents);
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/todo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ registerPlugin<void>(
});

async function isStruckThrough(session: Session, row: Row) {
// for backwards compatibility
const isStruckThroughOldStyle = await session.document.store._isStruckThroughOldFormat(row);
if (isStruckThroughOldStyle) { return true; }

const text = await session.document.getText(row);
return (text.slice(0, 2) === '~~') && (text.slice(-2) === '~~');
}
Expand Down

0 comments on commit 68458f9

Please sign in to comment.