Adrià Vilanova Martínez | 5dd7a6f | 2023-03-04 18:32:27 +0100 | [diff] [blame] | 1 | import ThreadModel from './Thread.js'; |
| 2 | |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 3 | export default class GapModel { |
Adrià Vilanova Martínez | 5dd7a6f | 2023-03-04 18:32:27 +0100 | [diff] [blame] | 4 | constructor(data, thread) { |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 5 | this.data = data ?? {}; |
Adrià Vilanova Martínez | 5dd7a6f | 2023-03-04 18:32:27 +0100 | [diff] [blame] | 6 | this.thread = thread ?? new ThreadModel(); |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 7 | } |
| 8 | |
| 9 | getCount() { |
| 10 | const a = this.data[1] ?? null; |
| 11 | return a != null ? a : 0; |
| 12 | } |
| 13 | |
| 14 | setCount(value) { |
| 15 | this.data[1] = Number(value); |
| 16 | } |
| 17 | |
| 18 | getStartMicroseconds() { |
| 19 | return this.data[2] ?? null; |
| 20 | } |
| 21 | |
| 22 | setStartMicroseconds(value) { |
| 23 | this.data[2] = '' + value; |
| 24 | } |
| 25 | |
| 26 | getStartTimestamp() { |
Adrià Vilanova Martínez | 412b758 | 2022-12-30 01:35:30 +0100 | [diff] [blame] | 27 | let a = this.getStartMicroseconds(); |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 28 | if (a == null) a = '0'; |
| 29 | return BigInt(a); |
| 30 | } |
| 31 | |
| 32 | getEndMicroseconds() { |
| 33 | return this.data[3] ?? null; |
| 34 | } |
| 35 | |
| 36 | setEndMicroseconds(value) { |
| 37 | this.data[3] = '' + value; |
| 38 | } |
| 39 | |
| 40 | getEndTimestamp() { |
Adrià Vilanova Martínez | 412b758 | 2022-12-30 01:35:30 +0100 | [diff] [blame] | 41 | let a = this.getEndMicroseconds(); |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 42 | if (a == null) a = '0'; |
| 43 | return BigInt(a); |
| 44 | } |
| 45 | |
| 46 | getParentId() { |
| 47 | const a = this.data[4]; |
| 48 | return a ? Number(a) : 0; |
| 49 | } |
| 50 | |
| 51 | setParentId(value) { |
| 52 | this.data[4] = '' + value; |
| 53 | } |
| 54 | |
| 55 | toRawMessageOrGap() { |
| 56 | return {2: this.data}; |
| 57 | } |
| 58 | } |