From 68458f91e2f56f2f08d2b8192a14a0e4bbd43688 Mon Sep 17 00:00:00 2001 From: Jeff Wu Date: Sat, 8 Apr 2017 17:41:59 -0700 Subject: [PATCH] backwards compatible --- src/assets/js/datastore.ts | 10 ++++++++++ src/plugins/todo/index.tsx | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/assets/js/datastore.ts b/src/assets/js/datastore.ts index 79a68773..e8583c6c 100644 --- a/src/assets/js/datastore.ts +++ b/src/assets/js/datastore.ts @@ -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 { + const line = await this._get(this._lineKey_(row), []); + if (typeof line !== 'string' && line.length && line[0].properties.strikethrough) { + return true; + } + return false; + } + public async getParents(row: Row): Promise> { return await this._get(this._parentsKey_(row), [], decodeParents); } diff --git a/src/plugins/todo/index.tsx b/src/plugins/todo/index.tsx index 03b339b5..acd9e71d 100644 --- a/src/plugins/todo/index.tsx +++ b/src/plugins/todo/index.tsx @@ -33,6 +33,10 @@ registerPlugin( }); 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) === '~~'); }