fix: Timestamps being broken
Don't even know how this happened, I think my computer was just having a stroke of some sort when I was initally doing this.
This commit is contained in:
parent
c5b1d76954
commit
a33437cac6
@ -28,7 +28,7 @@ io.on('connection', async (socket) => {
|
|||||||
message: msg.content,
|
message: msg.content,
|
||||||
imageSrc: sender.image,
|
imageSrc: sender.image,
|
||||||
channel: msg.channel,
|
channel: msg.channel,
|
||||||
timestamp: timestamp.getTime(),
|
timestamp: timestamp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<span class="font-bold">{user}</span>
|
<span class="font-bold">{user}</span>
|
||||||
<span>·</span>
|
<span>·</span>
|
||||||
<span class="text-muted-foreground"
|
<span class="text-muted-foreground"
|
||||||
>{new Date(timestamp).toLocaleDateString('en-US', {
|
>{timestamp.toLocaleDateString('en-US', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
|
@ -29,12 +29,13 @@ class Websocket {
|
|||||||
|
|
||||||
// Add message to local messages array
|
// Add message to local messages array
|
||||||
private loadMessage(newMsg: TypeMessage) {
|
private loadMessage(newMsg: TypeMessage) {
|
||||||
|
console.log(newMsg.timestamp);
|
||||||
this.messages = [
|
this.messages = [
|
||||||
{
|
{
|
||||||
message: newMsg.message,
|
message: newMsg.message,
|
||||||
imageSrc: newMsg.imageSrc,
|
imageSrc: newMsg.imageSrc,
|
||||||
user: newMsg.user,
|
user: newMsg.user,
|
||||||
timestamp: newMsg.timestamp,
|
timestamp: new Date(newMsg.timestamp),
|
||||||
},
|
},
|
||||||
...this.messages,
|
...this.messages,
|
||||||
];
|
];
|
||||||
|
@ -36,7 +36,7 @@ export function startupSocketIOServer(httpServer: HttpServer | null) {
|
|||||||
message: msg.content,
|
message: msg.content,
|
||||||
imageSrc: sender.image,
|
imageSrc: sender.image,
|
||||||
channel: msg.channel,
|
channel: msg.channel,
|
||||||
timestamp: timestamp.getTime(),
|
timestamp: timestamp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -6,12 +6,6 @@ interface Messages {
|
|||||||
error: Error | null;
|
error: Error | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CassandraTimestamp {
|
|
||||||
low: number;
|
|
||||||
high: number;
|
|
||||||
unsigned: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createDelay(ms: number) {
|
function createDelay(ms: number) {
|
||||||
return new Promise((res) => setTimeout(res, ms));
|
return new Promise((res) => setTimeout(res, ms));
|
||||||
}
|
}
|
||||||
@ -135,13 +129,6 @@ class Db {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timestamp to Epoch method
|
|
||||||
tsEpoch(ts: CassandraTimestamp) {
|
|
||||||
const low = ts.low >>> 0;
|
|
||||||
const high = ts.high >>> 0;
|
|
||||||
return high * 2 ** 32 + low;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = new Db();
|
const db = new Db();
|
||||||
|
@ -2,7 +2,7 @@ export interface TypeMessage {
|
|||||||
message: string;
|
message: string;
|
||||||
imageSrc: string;
|
imageSrc: string;
|
||||||
user: string;
|
user: string;
|
||||||
timestamp: number;
|
timestamp: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TypeFullMessage {
|
export interface TypeFullMessage {
|
||||||
@ -10,5 +10,5 @@ export interface TypeFullMessage {
|
|||||||
message: string;
|
message: string;
|
||||||
imageSrc: string;
|
imageSrc: string;
|
||||||
user: string;
|
user: string;
|
||||||
timestamp: number;
|
timestamp: Date;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ export async function load({ params, request }): Promise<ChannelLoad> {
|
|||||||
user: sender.username,
|
user: sender.username,
|
||||||
imageSrc: sender.image,
|
imageSrc: sender.image,
|
||||||
channel: value.channel,
|
channel: value.channel,
|
||||||
timestamp: db.tsEpoch(value.timestamp),
|
timestamp: new Date(value.timestamp),
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
|
Loading…
Reference in New Issue
Block a user