Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #60 from pvzig/ios-fix
Browse files Browse the repository at this point in the history
Fix iOS crash + Swift 3 style changes
  • Loading branch information
pvzig authored Nov 24, 2016
2 parents cb542da + 5d7064e commit 0ebd3cb
Show file tree
Hide file tree
Showing 13 changed files with 425 additions and 421 deletions.
4 changes: 2 additions & 2 deletions Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git "https://github.com/daltoniam/Starscream" == 2.0.0
git "https://github.com/pvzig/swifter.git" == 3.0.4
github "https://github.com/daltoniam/Starscream" == 2.0.2
github "https://github.com/pvzig/swifter.git" == 3.0.4
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git "https://github.com/daltoniam/Starscream" "2.0.0"
git "https://github.com/pvzig/swifter.git" "3.0.4"
github "daltoniam/Starscream" "2.0.2"
github "pvzig/swifter" "3.0.4"
12 changes: 6 additions & 6 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'SlackKit OS X' do
pod 'Starscream', '~> 2.0.0'
pod 'Swifter', '~> 1.3.2'
pod 'Starscream', '~> 2.0.2'
pod 'Swifter', :git => 'https://github.com/pvzig/swifter.git', :tag => '3.0.4'
end

target 'SlackKit iOS' do
pod 'Starscream', '~> 2.0.0'
pod 'Swifter', '~> 1.3.2'
pod 'Starscream', '~> 2.0.2'
pod 'Swifter', :git => 'https://github.com/pvzig/swifter.git', :tag => '3.0.4'
end

target 'SlackKit tvOS' do
pod 'Starscream', '~> 2.0.0'
pod 'Swifter', '~> 1.3.2'
pod 'Starscream', '~> 2.0.2'
pod 'Swifter', :git => 'https://github.com/pvzig/swifter.git', :tag => '3.0.4'
end
20 changes: 15 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
PODS:
- Starscream (2.0.0)
- Starscream (2.0.2)
- Swifter (1.3.2)

DEPENDENCIES:
- Starscream (~> 2.0.0)
- Swifter (~> 1.3.2)
- Starscream (~> 2.0.2)
- Swifter (from `https://github.com/pvzig/swifter.git`, tag `3.0.4`)

EXTERNAL SOURCES:
Swifter:
:git: https://github.com/pvzig/swifter.git
:tag: 3.0.4

CHECKOUT OPTIONS:
Swifter:
:git: https://github.com/pvzig/swifter.git
:tag: 3.0.4

SPEC CHECKSUMS:
Starscream: 947c865596f0d6bb3f0203fee23228ed2d471468
Starscream: 6c135a34e0a6e60cedaa0b30db67a4c05cf7cd38
Swifter: dd1800ba8eb3e28b22b8bd20f91a8561a0110fac

PODFILE CHECKSUM: 3d4e92bde92fd20d6fe672ad26f677fcbfafda1f
PODFILE CHECKSUM: cd86ea0f8422027c9d5fa3c40243ae7a816fb79a

COCOAPODS: 1.1.0.rc.3
126 changes: 62 additions & 64 deletions SlackKit/Sources/Client+EventDispatching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,137 +24,135 @@
internal extension Client {

func dispatch(_ event: [String: Any]) {
let event = Event(event: event)
guard let type = event.type else {
return
}
let event = Event(event)
let type = event.type ?? .error
switch type {
case .Hello:
case .hello:
connected = true
connectionEventsDelegate?.connected(self)
case .Ok:
case .ok:
messageSent(event)
case .Message:
case .message:
if (event.subtype != nil) {
messageDispatcher(event)
} else {
messageReceived(event)
}
case .UserTyping:
case .userTyping:
userTyping(event)
case .ChannelMarked, .IMMarked, .GroupMarked:
case .channelMarked, .imMarked, .groupMarked:
channelMarked(event)
case .ChannelCreated, .IMCreated:
case .channelCreated, .imCreated:
channelCreated(event)
case .ChannelJoined, .GroupJoined:
case .channelJoined, .groupJoined:
channelJoined(event)
case .ChannelLeft, .GroupLeft:
case .channelLeft, .groupLeft:
channelLeft(event)
case .ChannelDeleted:
case .channelDeleted:
channelDeleted(event)
case .ChannelRenamed, .GroupRename:
case .channelRenamed, .groupRename:
channelRenamed(event)
case .ChannelArchive, .GroupArchive:
case .channelArchive, .groupArchive:
channelArchived(event, archived: true)
case .ChannelUnarchive, .GroupUnarchive:
case .channelUnarchive, .groupUnarchive:
channelArchived(event, archived: false)
case .ChannelHistoryChanged, .IMHistoryChanged, .GroupHistoryChanged:
case .channelHistoryChanged, .imHistoryChanged, .groupHistoryChanged:
channelHistoryChanged(event)
case .DNDUpdated:
case .dndUpdated:
doNotDisturbUpdated(event)
case .DNDUpatedUser:
case .dndUpatedUser:
doNotDisturbUserUpdated(event)
case .IMOpen, .GroupOpen:
case .imOpen, .groupOpen:
open(event, open: true)
case .IMClose, .GroupClose:
case .imClose, .groupClose:
open(event, open: false)
case .FileCreated:
case .fileCreated:
processFile(event)
case .FileShared:
case .fileShared:
processFile(event)
case .FileUnshared:
case .fileUnshared:
processFile(event)
case .FilePublic:
case .filePublic:
processFile(event)
case .FilePrivate:
case .filePrivate:
filePrivate(event)
case .FileChanged:
case .fileChanged:
processFile(event)
case .FileDeleted:
case .fileDeleted:
deleteFile(event)
case .FileCommentAdded:
case .fileCommentAdded:
fileCommentAdded(event)
case .FileCommentEdited:
case .fileCommentEdited:
fileCommentEdited(event)
case .FileCommentDeleted:
case .fileCommentDeleted:
fileCommentDeleted(event)
case .PinAdded:
case .pinAdded:
pinAdded(event)
case .PinRemoved:
case .pinRemoved:
pinRemoved(event)
case .Pong:
case .pong:
pong(event)
case .PresenceChange:
case .presenceChange:
presenceChange(event)
case .ManualPresenceChange:
case .manualPresenceChange:
manualPresenceChange(event)
case .PrefChange:
case .prefChange:
changePreference(event)
case .UserChange:
case .userChange:
userChange(event)
case .TeamJoin:
case .teamJoin:
teamJoin(event)
case .StarAdded:
case .starAdded:
itemStarred(event, star: true)
case .StarRemoved:
case .starRemoved:
itemStarred(event, star: false)
case .ReactionAdded:
case .reactionAdded:
addedReaction(event)
case .ReactionRemoved:
case .reactionRemoved:
removedReaction(event)
case .EmojiChanged:
case .emojiChanged:
emojiChanged(event)
case .CommandsChanged:
case .commandsChanged:
// This functionality is only used by our web client.
// The other APIs required to support slash command metadata are currently unstable.
// Until they are released other clients should ignore this event.
break
case .TeamPlanChange:
case .teamPlanChange:
teamPlanChange(event)
case .TeamPrefChange:
case .teamPrefChange:
teamPreferenceChange(event)
case .TeamRename:
case .teamRename:
teamNameChange(event)
case .TeamDomainChange:
case .teamDomainChange:
teamDomainChange(event)
case .EmailDomainChange:
case .emailDomainChange:
emailDomainChange(event)
case .TeamProfileChange:
case .teamProfileChange:
teamProfileChange(event)
case .TeamProfileDelete:
case .teamProfileDelete:
teamProfileDeleted(event)
case .TeamProfileReorder:
case .teamProfileReorder:
teamProfileReordered(event)
case .BotAdded:
case .botAdded:
bot(event)
case .BotChanged:
case .botChanged:
bot(event)
case .AccountsChanged:
case .accountsChanged:
// The accounts_changed event is used by our web client to maintain a list of logged-in accounts.
// Other clients should ignore this event.
break
case .TeamMigrationStarted:
case .teamMigrationStarted:
connect(options: options ?? ClientOptions())
case .ReconnectURL:
case .reconnectURL:
// The reconnect_url event is currently unsupported and experimental.
break
case .SubteamCreated, .SubteamUpdated:
case .subteamCreated, .subteamUpdated:
subteam(event)
case .SubteamSelfAdded:
case .subteamSelfAdded:
subteamAddedSelf(event)
case.SubteamSelfRemoved:
case .subteamSelfRemoved:
subteamRemovedSelf(event)
case .Error:
case .error:
print("Error: \(event)")
}
}
Expand All @@ -164,9 +162,9 @@ internal extension Client {
return
}
switch subtype {
case .MessageChanged:
case .messageChanged:
messageChanged(event)
case .MessageDeleted:
case .messageDeleted:
messageDeleted(event)
default:
messageReceived(event)
Expand Down
Loading

0 comments on commit 0ebd3cb

Please sign in to comment.