Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Expiration time support#2

Open
cafercangundogdu wants to merge 9 commits into
mainfrom
expiration_time_support
Open

Expiration time support#2
cafercangundogdu wants to merge 9 commits into
mainfrom
expiration_time_support

Conversation

@cafercangundogdu
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@m-ali-akbay m-ali-akbay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I have some questions in my mind to be answered before having the approve.

Comment thread src/bot/global-shortcut.ts Outdated
},
accessory: {
type: "datepicker",
initial_date: "2021-12-17",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about having 1 day later from now always as the initial_date and the same behaviour for the initial_time?
Also, I wonder if it complaint with different timezones.

@cafercangundogdu
Copy link
Copy Markdown
Author

The date-time is now calculated dynamically based on the user's timezone.

const userInfo = await app.client.users.info({user: user.id})
if(!userInfo.ok) {
    return
}

const momentTodayNextHourUTC = moment.tz(userInfo?.user.tz).add(1, "day").add(1, "hour").startOf('hour')
const initialDateStr = momentTodayNextHourUTC.format("YYYY-MM-DD")
const initialTimeStr = momentTodayNextHourUTC.format("HH:mm")

Copy link
Copy Markdown
Contributor

@m-ali-akbay m-ali-akbay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moment.js is not maintained anymore, DateFns is another good alternative. It also uses builtin Date object, which is better to use.

And, what about showing the time left in the message instead of the date-time, and updating it periodically?

Comment thread package.json
"dependencies": {
"@slack/bolt": "^3.8.1",
"dotenv": "^10.0.0",
"moment": "^2.29.1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moment is being deprecated, please use the successor, date-fns.

@m-ali-akbay
Copy link
Copy Markdown
Contributor

The date-time is now calculated dynamically based on the user's timezone.

const userInfo = await app.client.users.info({user: user.id})
if(!userInfo.ok) {
    return
}

const momentTodayNextHourUTC = moment.tz(userInfo?.user.tz).add(1, "day").add(1, "hour").startOf('hour')
const initialDateStr = momentTodayNextHourUTC.format("YYYY-MM-DD")
const initialTimeStr = momentTodayNextHourUTC.format("HH:mm")

Is any new permission required to access the user info?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants