Skip to content

Commit

Permalink
fix: disable selecting a section
Browse files Browse the repository at this point in the history
  • Loading branch information
tealbathingsuit committed May 18, 2022
1 parent 286dcd0 commit a2830f1
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 20 deletions.
1 change: 0 additions & 1 deletion Accord/App/AccordApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import UserNotifications
var reachability: Reachability? = {
var reachability = try? Reachability()
reachability?.whenReachable = { status in
print("reconnecting reachable")
concurrentQueue.async {
if wss?.connection?.state != .preparing {
wss?.reset()
Expand Down
3 changes: 0 additions & 3 deletions Accord/App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ struct ContentView: View {
}
}
}
.onDisappear {
print("uh bye")
}
} else if let serverListView = serverListView {
serverListView
} else {
Expand Down
4 changes: 1 addition & 3 deletions Accord/Backend/Gateway/Gateway.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ final class Gateway {
) throws {
if compress {
socketEndpoint = NWEndpoint.url(URL(string: "wss://gateway.discord.gg?v=9&encoding=json&compress=zlib-stream")!)
print(socketEndpoint)
print("Connecting with stream compression enabled")
} else {
socketEndpoint = NWEndpoint.url(url)
}
Expand Down Expand Up @@ -320,7 +320,6 @@ final class Gateway {
}
case .cont: break
case .binary:
print("binary packet")
self?.decompressor.decompressionQueue.async {
guard let data = try? self?.decompressor.decompress(data: data, large: true) else { return }
wssThread.async {
Expand Down Expand Up @@ -361,7 +360,6 @@ final class Gateway {

func updatePresence(status: String, since: Int, activities: [Activity]) throws {
self.presences = activities
print(activities.map(\.dictValue))
let packet: [String: Any] = [
"op": 3,
"d": [
Expand Down
20 changes: 14 additions & 6 deletions Accord/Backend/Gateway/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,31 @@ extension Gateway {
})
}

func reset(function: String = #function) {
print("resetting from function", function, wss.connection?.state as Any)
func reset() {
print("resetting from function")

if let state = wss.connection?.state, case NWConnection.State.failed = state {
close(.protocolCode(.protocolError))
}
concurrentQueue.async {
guard let new = try? Gateway(url: Gateway.gatewayURL, session_id: wss.sessionID, seq: wss.seq) else { return }
guard let new = try? Gateway(
url: Gateway.gatewayURL,
session_id: wss.sessionID,
seq: wss.seq,
compress: UserDefaults.standard.value(forKey: "CompressGateway") as? Bool ?? true
) else { return }
wss = new
}
}

func hardReset(function: String = #function) {
print("hard resetting from function", function)
func hardReset() {
print("hard resetting from function")
close(.protocolCode(.normalClosure))
concurrentQueue.async {
guard let new = try? Gateway(url: Gateway.gatewayURL) else { return }
guard let new = try? Gateway(
url: Gateway.gatewayURL,
compress: UserDefaults.standard.value(forKey: "CompressGateway") as? Bool ?? true
) else { return }
new.ready().sink(receiveCompletion: doNothing, receiveValue: doNothing).store(in: &new.bag)
wss = new
}
Expand Down
1 change: 0 additions & 1 deletion Accord/Objects/DiscordTypes/Status.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ final class Activity: Identifiable {
if let details = details {
dict["details"] = details
}
print(dict)
return dict
}
}
Expand Down
5 changes: 5 additions & 0 deletions Accord/UI/Base/GuildView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ struct GuildView: View {
.fontWeight(.bold)
.foregroundColor(Color.secondary)
.font(.system(size: 10))
.onChange(of: self.selection, perform: { [selection] new in
if let selection = selection, new == Int(channel.id) {
self.selection = selection
}
})
} else {
NavigationLink(
destination: NavigationLazyView(ChannelView(channel, guild.name).equatable()),
Expand Down
1 change: 1 addition & 0 deletions Accord/UI/Base/PrivateChannelsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct PrivateChannelsView: View {
ForEach(privateChannels, id: \.id) { channel in
NavigationLink(destination: NavigationLazyView(ChannelView(channel).equatable()), tag: Int(channel.id) ?? 0, selection: self.$selection) {
ServerListViewCell(channel: channel, updater: self.viewUpdater)
.animation(nil, value: UUID())
.onChange(of: self.selection, perform: { [selection] new in
if new == Int(channel.id) {
channel.read_state?.mention_count = 0
Expand Down
8 changes: 2 additions & 6 deletions Accord/UI/Base/ServerListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ struct NavigationLazyView<Content: View>: View {
}

enum Emotes {
public static var emotes: [String: [DiscordEmote]] = [:] {
didSet {
print(#function)
}
}
public static var emotes: [String: [DiscordEmote]] = [:]
}

struct GuildHoverAnimation: ViewModifier {
Expand Down Expand Up @@ -227,6 +223,7 @@ struct ServerListView: View {
selection: self.$selection,
viewUpdater: self.viewUpdater
)
.animation(nil, value: UUID())
}
.padding(.top, 5)
.listStyle(.sidebar)
Expand Down Expand Up @@ -284,7 +281,6 @@ struct ServerListView: View {
Toggle(isOn: Binding.constant(false)) {
Image(systemName: "bell.badge.fill")
}
.hidden()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Accord/UI/Base/ServerListViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct ServerListViewCell: View {
}
}
Text(channel.computedName)
.animation(nil, value: UUID())
}
}

Expand Down

0 comments on commit a2830f1

Please sign in to comment.