mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 19:17:48 +00:00 
			
		
		
		
	feat: Show date along with time in messages (#1748)
This commit is contained in:
		| @@ -131,7 +131,7 @@ export default { | |||||||
|       return !this.data.message_type ? 'left' : 'right'; |       return !this.data.message_type ? 'left' : 'right'; | ||||||
|     }, |     }, | ||||||
|     readableTime() { |     readableTime() { | ||||||
|       return this.messageStamp(this.data.created_at); |       return this.messageStamp(this.data.created_at, 'LLL d, h:mm a'); | ||||||
|     }, |     }, | ||||||
|     isBubble() { |     isBubble() { | ||||||
|       return [0, 1, 3].includes(this.data.message_type); |       return [0, 1, 3].includes(this.data.message_type); | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								app/javascript/dashboard/mixins/specs/time.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/javascript/dashboard/mixins/specs/time.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | import TimeMixin from '../time'; | ||||||
|  |  | ||||||
|  | describe('#messageStamp', () => { | ||||||
|  |   it('returns correct value', () => { | ||||||
|  |     expect(TimeMixin.methods.messageStamp(1612971343)).toEqual('3:35 PM'); | ||||||
|  |     expect(TimeMixin.methods.messageStamp(1612971343, 'LLL d, h:mm a')).toEqual( | ||||||
|  |       'Feb 10, 3:35 PM' | ||||||
|  |     ); | ||||||
|  |   }); | ||||||
|  | }); | ||||||
| @@ -1,13 +1,12 @@ | |||||||
| /* eslint no-console: 0 */ |  | ||||||
| import fromUnixTime from 'date-fns/fromUnixTime'; | import fromUnixTime from 'date-fns/fromUnixTime'; | ||||||
| import format from 'date-fns/format'; | import format from 'date-fns/format'; | ||||||
| import formatDistanceToNow from 'date-fns/formatDistanceToNow'; | import formatDistanceToNow from 'date-fns/formatDistanceToNow'; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   methods: { |   methods: { | ||||||
|     messageStamp(time) { |     messageStamp(time, dateFormat = 'h:mm a') { | ||||||
|       const unixTime = fromUnixTime(time); |       const unixTime = fromUnixTime(time); | ||||||
|       return format(unixTime, 'h:mm a'); |       return format(unixTime, dateFormat); | ||||||
|     }, |     }, | ||||||
|     dynamicTime(time) { |     dynamicTime(time) { | ||||||
|       const unixTime = fromUnixTime(time); |       const unixTime = fromUnixTime(time); | ||||||
|   | |||||||
| @@ -30,4 +30,5 @@ module.exports = { | |||||||
|     '**/app/javascript/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)', |     '**/app/javascript/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)', | ||||||
|   ], |   ], | ||||||
|   testURL: 'http://localhost/', |   testURL: 'http://localhost/', | ||||||
|  |   globalSetup: './jest.setup.js', | ||||||
| }; | }; | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								jest.setup.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								jest.setup.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | |||||||
|  | module.exports = async () => { | ||||||
|  |   process.env.TZ = 'UTC'; | ||||||
|  | }; | ||||||
		Reference in New Issue
	
	Block a user
	 Pranav Raj S
					Pranav Raj S