diff --git a/locales/en.yml b/locales/en.yml index c69dc22b1..4eae82507 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -13,6 +13,15 @@ common: months_ago: "{}month(s) ago" years_ago: "{}year(s) ago" + weekday-short: + sunday: "S" + monday: "M" + tuesday: "T" + wednesday: "W" + thursday: "T" + friday: "F" + satruday: "S" + reactions: like: "Like" love: "Love" diff --git a/locales/ja.yml b/locales/ja.yml index 782b87bd8..82589aadf 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -13,6 +13,15 @@ common: months_ago: "{}ヶ月前" years_ago: "{}年前" + weekday-short: + sunday: "日" + monday: "月" + tuesday: "火" + wednesday: "水" + thursday: "木" + friday: "金" + satruday: "土" + reactions: like: "いいね" love: "ハート" diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts index 7af435e82..0d08b9546 100644 --- a/src/api/endpoints/posts/timeline.ts +++ b/src/api/endpoints/posts/timeline.ts @@ -29,9 +29,17 @@ module.exports = async (params, user, app) => { const [maxId, maxIdErr] = $(params.max_id).optional.id().$; if (maxIdErr) throw 'invalid max_id param'; - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - throw 'cannot set since_id and max_id'; + // Get 'since_date' parameter + const [sinceDate, sinceDateErr] = $(params.since_date).optional.number().$; + if (sinceDateErr) throw 'invalid since_date param'; + + // Get 'max_date' parameter + const [maxDate, maxDateErr] = $(params.max_date).optional.number().$; + if (maxDateErr) throw 'invalid max_date param'; + + // Check if only one of since_id, max_id, since_date, max_date specified + if ([sinceId, maxId, sinceDate, maxDate].filter(x => x != null).length > 1) { + throw 'only one of since_id, max_id, since_date, max_date can be specified'; } const { followingIds, watchingChannelIds } = await rap({ @@ -81,6 +89,15 @@ module.exports = async (params, user, app) => { query._id = { $lt: maxId }; + } else if (sinceDate) { + sort._id = 1; + query.created_at = { + $gt: new Date(sinceDate) + }; + } else if (maxDate) { + query.created_at = { + $lt: new Date(maxDate) + }; } //#endregion diff --git a/src/web/app/desktop/tags/home-widgets/timeline.tag b/src/web/app/desktop/tags/home-widgets/timeline.tag index 08d96ad71..735783049 100644 --- a/src/web/app/desktop/tags/home-widgets/timeline.tag +++ b/src/web/app/desktop/tags/home-widgets/timeline.tag @@ -70,7 +70,13 @@ }; this.load = (cb) => { - this.api('posts/timeline').then(posts => { + this.update({ + isLoading: true + }); + + this.api('posts/timeline', { + max_date: this.date ? this.date.getTime() : undefined + }).then(posts => { this.update({ isLoading: false, isEmpty: posts.length == 0 @@ -114,5 +120,15 @@ const current = window.scrollY + window.innerHeight; if (current > document.body.offsetHeight - 8) this.more(); }; + + this.warp = date => { + console.log(date); + + this.update({ + date: date + }); + + this.load(); + }; diff --git a/src/web/app/desktop/tags/home-widgets/timemachine.tag b/src/web/app/desktop/tags/home-widgets/timemachine.tag new file mode 100644 index 000000000..b6c53e028 --- /dev/null +++ b/src/web/app/desktop/tags/home-widgets/timemachine.tag @@ -0,0 +1,165 @@ + + +

{ year }/{ month }

+ + +
+
{ weekdayText[i] }
+
+
{ i + 1 }
+
+ + +
diff --git a/src/web/app/desktop/tags/home.tag b/src/web/app/desktop/tags/home.tag index ecfe23ade..452499d70 100644 --- a/src/web/app/desktop/tags/home.tag +++ b/src/web/app/desktop/tags/home.tag @@ -5,6 +5,7 @@