Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomatree committed May 29, 2024
1 parent 1507641 commit c8e4bef
Show file tree
Hide file tree
Showing 12 changed files with 457 additions and 113 deletions.
14 changes: 1 addition & 13 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
},
"Channel Icon" : {

},
"Click the join button to connect" : {

},
"Code or link" : {

Expand Down Expand Up @@ -244,18 +241,12 @@
},
"Join by invite code or link" : {

},
"Join Call" : {

},
"Joined" : {

},
"Language" : {

},
"Leave Call" : {

},
"Let's fix that" : {

Expand Down Expand Up @@ -313,9 +304,6 @@
},
"New Password" : {

},
"Not Connected" : {

},
"Offline" : {

Expand Down Expand Up @@ -467,7 +455,7 @@
"unknown" : {

},
"Unknown Channel" : {
"Unknown Channel :(" : {

},
"Unknown message" : {
Expand Down
149 changes: 75 additions & 74 deletions Revolt.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Revolt/Api/Payloads.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct ServerEdit: Encodable {
var description: String?
var icon: String?
var banner: String?
var categories: [Category]?
var categories: [Types.Category]?
var system_messages: SystemMessages?
var flags: Int?
var discoverable: Bool?
Expand Down
12 changes: 11 additions & 1 deletion Revolt/Api/Websocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum WsMessage {
case channel_stop_typing(ChannelTyping)
case message_delete(MessageDeleteEvent)
case channel_ack(ChannelAckEvent)
case message_react(MessageReactEvent)
}

struct ReadyEvent: Decodable {
Expand Down Expand Up @@ -56,9 +57,16 @@ struct ChannelAckEvent: Decodable {
var message_id: String
}

struct MessageReactEvent: Decodable {
var id: String
var channel_id: String
var user_id: String
var emoji_id: String
}

extension WsMessage: Decodable {
enum CodingKeys: String, CodingKey { case type }
enum Tag: String, Decodable { case Authenticated, InvalidSession, Ready, Message, MessageUpdate, ChannelStartTyping, ChannelStopTyping, MessageDelete, ChannelAck }
enum Tag: String, Decodable { case Authenticated, InvalidSession, Ready, Message, MessageUpdate, ChannelStartTyping, ChannelStopTyping, MessageDelete, ChannelAck, MessageReact }

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
Expand All @@ -83,6 +91,8 @@ extension WsMessage: Decodable {
self = .message_delete(try singleValueContainer.decode(MessageDeleteEvent.self))
case .ChannelAck:
self = .channel_ack(try singleValueContainer.decode(ChannelAckEvent.self))
case .MessageReact:
self = .message_react(try singleValueContainer.decode(MessageReactEvent.self))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Revolt/Components/Home/ServerChannelScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct ServerChannelScrollView: View {

var body: some View {
let maybeSelectedServer: Server? = switch currentSelection {
case .server(let serverId): viewState.servers[serverId]!
case .server(let serverId): viewState.servers[serverId]
default: nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct MessageContentsView: View {
.sheet(isPresented: $showReactSheet) {
EmojiPicker(background: AnyView(viewState.theme.background)) { emoji in
Task {
showReactSheet = false
await viewState.http.reactMessage(channel: message.channel, message: message.id, emoji: emoji.id)
}
}
Expand Down
26 changes: 15 additions & 11 deletions Revolt/Pages/HomeRewritten.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ struct MaybeChannelView: View {
var body: some View {
switch currentChannel {
case .channel(let channelId):
let channel = viewState.channels[channelId]!
let messages = Binding($viewState.channelMessages[channelId])!
if let channel = viewState.channels[channelId] {
let messages = Binding($viewState.channelMessages[channelId])!

MessageableChannelView(
viewModel: MessageableChannelViewModel(
viewState: viewState,
channel: channel,
server: currentServer,
messages: messages
),
showSidebar: $showSidebar
)
MessageableChannelView(
viewModel: MessageableChannelViewModel(
viewState: viewState,
channel: channel,
server: currentServer,
messages: messages
),
showSidebar: $showSidebar
)

} else {
Text("Unknown Channel :(")
}
case .home:
HomeWelcome(showSidebar: $showSidebar)
case .friends:
Expand Down
Loading

0 comments on commit c8e4bef

Please sign in to comment.