Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Our project was quite confused as to the boundaries between client and server code. This false sharing meant that it was quite hard to tell what was actually sent to the client and what was uniquely scoped to either side. Further, this meant that our compilation and build pipelines were very confused and pulled in files they should not have. This commit series tries to untangle the two. This also entails fixing quite some typing issues. It's hard to make this in sane, small, commits that still build at each step (it's impossible, as fixing one type error / any type immediately lead to further errors in a game of whack a mole). So you'll get my actual progress in small commits that can each be reviewed, however the earlier ones are in fact sometimes wrong and get cleaned up later once the picture is a bit clearer.
- Loading branch information
Showing
101 changed files
with
1,365 additions
and
1,123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {ClientChan, ClientMessage} from "./types"; | ||
import {SharedNetworkChan} from "../../shared/types/network"; | ||
import {SharedMsg} from "../../shared/types/msg"; | ||
|
||
export function toClientChan(shared: SharedNetworkChan): ClientChan { | ||
const history: string[] = [""].concat( | ||
shared.messages | ||
.filter((m) => m.self && m.text && m.type === "message") | ||
// TS is too stupid to see the nil guard on filter... so we monkey patch it | ||
.map((m): string => (m.text ? m.text : "")) | ||
.reverse() | ||
.slice(0, 99) | ||
); | ||
// filter the unused vars | ||
const {messages, totalMessages: _, ...props} = shared; | ||
const channel: ClientChan = { | ||
...props, | ||
editTopic: false, | ||
pendingMessage: "", | ||
inputHistoryPosition: 0, | ||
historyLoading: false, | ||
scrolledToBottom: true, | ||
users: [], | ||
usersOutdated: shared.type === "channel" ? true : false, | ||
moreHistoryAvailable: shared.totalMessages > shared.messages.length, | ||
inputHistory: history, | ||
messages: sharedMsgToClientMsg(messages), | ||
}; | ||
return channel; | ||
} | ||
|
||
function sharedMsgToClientMsg(shared: SharedMsg[]): ClientMessage[] { | ||
// TODO: this is a stub for now, we will want to populate client specific stuff here | ||
return shared; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.