From 877bfe4b6c83baba068f31aadabfadbff51752a9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 14 Nov 2017 08:21:19 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=AA=E3=82=93=E3=81=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/endpoints/users/posts.ts | 28 +- src/web/app/desktop/tags/calendar.tag | 241 +++++++++ .../desktop/tags/home-widgets/timemachine.tag | 231 +-------- src/web/app/desktop/tags/index.ts | 6 +- src/web/app/desktop/tags/user-graphs.tag | 41 -- src/web/app/desktop/tags/user-header.tag | 147 ------ src/web/app/desktop/tags/user-home.tag | 46 -- src/web/app/desktop/tags/user-photos.tag | 91 ---- src/web/app/desktop/tags/user-profile.tag | 102 ---- src/web/app/desktop/tags/user-timeline.tag | 9 + src/web/app/desktop/tags/user.tag | 457 +++++++++++++++++- 11 files changed, 727 insertions(+), 672 deletions(-) create mode 100644 src/web/app/desktop/tags/calendar.tag delete mode 100644 src/web/app/desktop/tags/user-graphs.tag delete mode 100644 src/web/app/desktop/tags/user-header.tag delete mode 100644 src/web/app/desktop/tags/user-home.tag delete mode 100644 src/web/app/desktop/tags/user-photos.tag delete mode 100644 src/web/app/desktop/tags/user-profile.tag diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts index d8204b8b8..fe821cf17 100644 --- a/src/api/endpoints/users/posts.ts +++ b/src/api/endpoints/users/posts.ts @@ -46,9 +46,17 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [maxId, maxIdErr] = $(params.max_id).optional.id().$; if (maxIdErr) return rej('invalid max_id param'); - // Check if both of since_id and max_id is specified - if (sinceId && maxId) { - return rej('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 q = userId !== undefined @@ -66,13 +74,15 @@ module.exports = (params, me) => new Promise(async (res, rej) => { return rej('user not found'); } - // Construct query + //#region Construct query const sort = { _id: -1 }; + const query = { user_id: user._id } as any; + if (sinceId) { sort._id = 1; query._id = { @@ -82,6 +92,15 @@ module.exports = (params, me) => new Promise(async (res, rej) => { 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) + }; } if (!includeReplies) { @@ -94,6 +113,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => { $ne: null }; } + //#endregion // Issue query const posts = await Post diff --git a/src/web/app/desktop/tags/calendar.tag b/src/web/app/desktop/tags/calendar.tag new file mode 100644 index 000000000..3535e8190 --- /dev/null +++ b/src/web/app/desktop/tags/calendar.tag @@ -0,0 +1,241 @@ + + + +

{ '%i18n:desktop.tags.mk-calendar.title%'.replace('{1}', year).replace('{2}', month) }

+ +
+ +
+
{ weekdayText[i] }
+
+
{ i + 1 }
+
+ + +
diff --git a/src/web/app/desktop/tags/home-widgets/timemachine.tag b/src/web/app/desktop/tags/home-widgets/timemachine.tag index 984258d2b..2199cf4c6 100644 --- a/src/web/app/desktop/tags/home-widgets/timemachine.tag +++ b/src/web/app/desktop/tags/home-widgets/timemachine.tag @@ -1,139 +1,10 @@ - - - -

{ '%i18n:desktop.tags.mk-timemachine-home-widget.title%'.replace('{1}', year).replace('{2}', month) }

- -
- -
-
{ weekdayText[i] }
-
-
{ i + 1 }
-
+ + - diff --git a/src/web/app/desktop/tags/user-header.tag b/src/web/app/desktop/tags/user-header.tag deleted file mode 100644 index ea7ea6bb3..000000000 --- a/src/web/app/desktop/tags/user-header.tag +++ /dev/null @@ -1,147 +0,0 @@ - - avatar -
-

{ user.name }

-

@{ user.username }

-

{ user.profile.location }

-
- - - -
diff --git a/src/web/app/desktop/tags/user-home.tag b/src/web/app/desktop/tags/user-home.tag deleted file mode 100644 index a879db5bb..000000000 --- a/src/web/app/desktop/tags/user-home.tag +++ /dev/null @@ -1,46 +0,0 @@ - -
- - -
-
- -
- - -
diff --git a/src/web/app/desktop/tags/user-photos.tag b/src/web/app/desktop/tags/user-photos.tag deleted file mode 100644 index dce1e50ad..000000000 --- a/src/web/app/desktop/tags/user-photos.tag +++ /dev/null @@ -1,91 +0,0 @@ - -

フォト

-

読み込んでいます

-
0 }> - -
-
-
-

写真はありません

- - -
diff --git a/src/web/app/desktop/tags/user-profile.tag b/src/web/app/desktop/tags/user-profile.tag deleted file mode 100644 index 7472a4780..000000000 --- a/src/web/app/desktop/tags/user-profile.tag +++ /dev/null @@ -1,102 +0,0 @@ - -
- -

フォローされています

-
-
{ user.description }
-
-

{ user.profile.birthday.replace('-', '年').replace('-', '月') + '日' } ({ age(user.profile.birthday) }歳)

-
- -
-

{ user.posts_count }ポスト

-

{ user.following_count }人をフォロー

-

{ user.followers_count }人のフォロワー

-
- - -
diff --git a/src/web/app/desktop/tags/user-timeline.tag b/src/web/app/desktop/tags/user-timeline.tag index 08ab47b16..5df13c436 100644 --- a/src/web/app/desktop/tags/user-timeline.tag +++ b/src/web/app/desktop/tags/user-timeline.tag @@ -91,6 +91,7 @@ this.fetch = cb => { this.api('users/posts', { user_id: this.user.id, + max_date: this.date ? this.date.getTime() : undefined, with_replies: this.mode == 'with-replies' }).then(posts => { this.update({ @@ -132,5 +133,13 @@ }); this.fetch(); }; + + this.warp = date => { + this.update({ + date: date + }); + + this.fetch(); + }; diff --git a/src/web/app/desktop/tags/user.tag b/src/web/app/desktop/tags/user.tag index 2e69872b7..c9bb53fed 100644 --- a/src/web/app/desktop/tags/user.tag +++ b/src/web/app/desktop/tags/user.tag @@ -3,10 +3,8 @@
-
- - -
+ + + + + + avatar +
+

{ user.name }

+

@{ user.username }

+

{ user.profile.location }

+
+ + + +
+ + +
+ +

フォローされています

+
+
{ user.description }
+
+

{ user.profile.birthday.replace('-', '年').replace('-', '月') + '日' } ({ age(user.profile.birthday) }歳)

+
+ +
+

{ user.posts_count }ポスト

+

{ user.following_count }人をフォロー

+

{ user.followers_count }人のフォロワー

+
+ + +
+ + +

フォト

+

読み込んでいます

+
0 }> + +
+
+
+

写真はありません

+ + +
+ + +
+ + +
+
+ +
+
+ +
+ + +
+ + +
+

投稿

+ +
+
+

フォロー/フォロワー

+ +
+
+

いいね

+ +
+ + +