Skip to content

Commit

Permalink
Add more general getPostTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed Aug 12, 2021
1 parent 956cebb commit 7c39301
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@earthstar-project/rich-threads-layer",
"version": "1.0.0",
"version": "1.1.0",
"description": "",
"main": "index.cjs",
"module": "index.js",
"scripts": {
"prepublish": "npm run build-types",
"prepare": "npm run build-types",
"build-types": "./node_modules/.bin/dts-bundle-generator --config dts-bundle.config.json"
},
"types": "index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion src/letterbox_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class LetterboxLayer {
return parseInt(rootTimestamp);
}

getPostTimestamp(postDoc: Document): number {
getReplyTimestamp(postDoc: Document): number {
const { replyTimestamp } = extractTemplateVariablesFromPath(
threadReplyTemplate,
postDoc.path,
Expand All @@ -93,6 +93,14 @@ export default class LetterboxLayer {
return parseInt(replyTimestamp);
}

getPostTimestamp(postDoc: Document): number {
if (isRootPost(postDoc)) {
return this.getThreadRootTimestamp(postDoc);
}

return this.getReplyTimestamp(postDoc);
}

_docToThreadRoot(rootDoc: Document): Post {
const { rootTimestamp } = extractTemplateVariablesFromPath(
threadRootTemplate,
Expand Down

0 comments on commit 7c39301

Please sign in to comment.