Skip to content

Commit

Permalink
Version 3.27.1
Browse files Browse the repository at this point in the history
  • Loading branch information
webim committed Sep 1, 2019
1 parent 1acd503 commit 53296d3
Show file tree
Hide file tree
Showing 13 changed files with 467 additions and 27 deletions.
418 changes: 418 additions & 0 deletions Documentation/FAQ methods documentation.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Example/Tests/SQLiteHistoryStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class SQLiteHistoryStorageTests: XCTestCase {
keyboard: nil,
keyboardRequest: nil,
operatorID: "1",
quote: nil,
senderAvatarURLString: nil,
senderName: "Name",
type: MessageType.OPERATOR,
Expand All @@ -112,7 +113,8 @@ class SQLiteHistoryStorageTests: XCTestCase {
internalID: String(index),
rawText: nil,
read: true,
messageCanBeEdited: false))
messageCanBeEdited: false,
messageCanBeReplied: false))
}

return messages
Expand Down
4 changes: 4 additions & 0 deletions Example/WebimClientLibrary.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
11EFE7D3231AC33500B64EFA /* FAQ methods documentation.md in Resources */ = {isa = PBXBuildFile; fileRef = 11EFE7D2231AC33500B64EFA /* FAQ methods documentation.md */; };
3BD523E036E5E0145C40A893 /* Pods_WebimClientLibrary_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75BFCD5FB1955EE77D987E3C /* Pods_WebimClientLibrary_Tests.framework */; };
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
607FACD81AFB9204008FA782 /* StartViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* StartViewController.swift */; };
Expand Down Expand Up @@ -97,6 +98,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
11EFE7D2231AC33500B64EFA /* FAQ methods documentation.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = "FAQ methods documentation.md"; sourceTree = "<group>"; };
188E01CE8A86B2460C60C156 /* Pods-WebimClientLibrary_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WebimClientLibrary_Tests.release.xcconfig"; path = "Target Support Files/Pods-WebimClientLibrary_Tests/Pods-WebimClientLibrary_Tests.release.xcconfig"; sourceTree = "<group>"; };
607FACD01AFB9204008FA782 /* WebimClientLibrary_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WebimClientLibrary_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -409,6 +411,7 @@
children = (
CE24A015203ADC2D009EE7E7 /* Images */,
CE54B2511FC452B9009C05BD /* Index.md */,
11EFE7D2231AC33500B64EFA /* FAQ methods documentation.md */,
);
name = Documentation;
path = ../Documentation;
Expand Down Expand Up @@ -567,6 +570,7 @@
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
CE5A03BA1FDEB756009D320A /* Localizable.strings in Resources */,
CE324E631FDECBD2004BB116 /* RatingViewController.xib in Resources */,
11EFE7D3231AC33500B64EFA /* FAQ methods documentation.md in Resources */,
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
);
Expand Down
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.27.0</string>
<string>3.27.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ This library provides [_Webim SDK_ for _iOS_](https://webim.ru/integration/mobil

Add following line for your target in your **Podfile**:
```
pod 'WebimClientLibrary', :git => 'https://github.com/webim/webim-client-sdk-ios.git', :branch => 'master', :tag => '3.27.0'
pod 'WebimClientLibrary', :git => 'https://github.com/webim/webim-client-sdk-ios.git', :branch => 'master', :tag => '3.27.1'
```
`use_frameworks!` must be specified.

### Carthage

Add following line to your **Cartfile**:
```
github "webim/webim-client-sdk-ios" ~> 3.27.0
github "webim/webim-client-sdk-ios" ~> 3.27.1
```

### Additional notes
Expand All @@ -38,7 +38,8 @@ Trying to integrate _WebimClientLibrary_ into your _Objective-C_ code? Try out o
Previous _Objective-C_ version (version numbers 2.x.x) can be reached from **version2** branch.

## Release notes
* New FAQ functions.
* DB index bug fixes.
* UserDefaults bug fixes.

## Example

Expand Down
2 changes: 1 addition & 1 deletion WebimClientLibrary.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'WebimClientLibrary'
s.version = '3.27.0'
s.version = '3.27.1'

s.author = { 'Webim.ru Ltd.' => '[email protected]' }
s.homepage = 'https://webim.ru/integration/mobile-sdk/ios-sdk-howto/'
Expand Down
2 changes: 1 addition & 1 deletion WebimClientLibrary/Backend/AbstractRequestLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class AbstractRequestLoop {

func perform(request: URLRequest) throws -> Data {
var requestWithUesrAngent = request
requestWithUesrAngent.setValue("iOS: Webim-Client 3.27.0; (\(UIDevice.current.model); \(UIDevice.current.systemVersion)); Bundle ID and version: \(Bundle.main.bundleIdentifier ?? "none") \(Bundle.main.infoDictionary?["CFBundleVersion"] ?? "none")", forHTTPHeaderField: "User-Agent")
requestWithUesrAngent.setValue("iOS: Webim-Client 3.27.1; (\(UIDevice.current.model); \(UIDevice.current.systemVersion)); Bundle ID and version: \(Bundle.main.bundleIdentifier ?? "none") \(Bundle.main.infoDictionary?["CFBundleVersion"] ?? "none")", forHTTPHeaderField: "User-Agent")

var errorCounter = 0
var lastHTTPCode = -1
Expand Down
18 changes: 9 additions & 9 deletions WebimClientLibrary/Backend/DeltaCallback.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ final class DeltaCallback {
// MARK: - Properties
private let currentChatMessageMapper: MessageMapper
private var currentChat: ChatItem?
private let readBeforeTimestampString = "read_before_timestamp"
private let userDefaultsKey: String
private weak var messageHolder: MessageHolder?
private weak var messageStream: MessageStreamImpl?
private weak var historyPoller: HistoryPoller?

// MARK: - Initialization
init(currentChatMessageMapper: MessageMapper) {
init(currentChatMessageMapper: MessageMapper,
userDefaultsKey: String) {
self.currentChatMessageMapper = currentChatMessageMapper
self.userDefaultsKey = userDefaultsKey
}

// MARK: - Methods
Expand Down Expand Up @@ -156,15 +158,14 @@ final class DeltaCallback {
if let message = currentChatMessageMapper.map(message: messageItem) {
if (message.getType() == MessageType.FILE_FROM_VISITOR || message.getType() != MessageType.VISITOR) && message.isReadByOperator() {
let time = message.getTimeInMicrosecond()
if time > Int64(UserDefaults.standard.integer(forKey: readBeforeTimestampString)) {
UserDefaults.standard.set(time, forKey: readBeforeTimestampString)
historyPoller?.updateReadBeforeTimestamp(timestamp: time)
if time > historyPoller?.getReadBeforeTimestamp(byUserDefaultsKey: userDefaultsKey) ?? -1 {
historyPoller?.updateReadBeforeTimestamp(timestamp: time, byUserDefaultsKey: userDefaultsKey)
}
}
}
}
} else {
UserDefaults.standard.set(-1, forKey: readBeforeTimestampString)
historyPoller?.updateReadBeforeTimestamp(timestamp: -1, byUserDefaultsKey: userDefaultsKey)
}
}

Expand Down Expand Up @@ -254,9 +255,8 @@ final class DeltaCallback {
currentChat?.set(messages: currentChatMessages)
messageHolder?.changed(message: message)
let time = message.getTimeInMicrosecond()
if time > UserDefaults.standard.integer(forKey: "readBeforeTimestampString") {
UserDefaults.standard.set(time, forKey: "readBeforeTimestampString")
historyPoller?.updateReadBeforeTimestamp(timestamp: time)
if time > historyPoller?.getReadBeforeTimestamp(byUserDefaultsKey: userDefaultsKey) ?? -1 {
historyPoller?.updateReadBeforeTimestamp(timestamp: time, byUserDefaultsKey: userDefaultsKey)
}
break
}
Expand Down
3 changes: 2 additions & 1 deletion WebimClientLibrary/Backend/SQLiteHistoryStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ final class SQLiteHistoryStorage: HistoryStorage {
_ = try db?.run(SQLiteHistoryStorage
.history
.createIndex(SQLiteHistoryStorage.timestamp,
unique: true))
unique: true,
ifNotExists: true))
} catch {
WebimInternalLogger.shared.log(entry: error.localizedDescription,
verbosityLevel: .VERBOSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class DepartmentFactory {
// MARK: - Methods

func convert(departmentItem: DepartmentItem) -> DepartmentImpl {
var fullLogoURL: URL? = nil
var fullLogoURL: URL?
if let logoURLString = departmentItem.getLogoURLString() {
fullLogoURL = URL(string: serverURLString + logoURLString)
}
Expand Down
2 changes: 1 addition & 1 deletion WebimClientLibrary/Backend/Utilities/InternalUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class InternalUtils {
static func createServerURLStringBy(accountName: String) -> String {
var serverURLstring = accountName

if serverURLstring.range(of: "://") != nil {
if let _ = serverURLstring.range(of: "://") {
if serverURLstring.last! == "/" {
serverURLstring.removeLast()
}
Expand Down
7 changes: 4 additions & 3 deletions WebimClientLibrary/Backend/Utilities/OperatorFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ final class OperatorFactory {

// MARK: - Methods
func createOperatorFrom(operatorItem: OperatorItem?) -> OperatorImpl? {
return ((operatorItem == nil) ? nil : OperatorImpl(id: operatorItem!.getID(),
name: operatorItem!.getFullName(),
avatarURLString: ((operatorItem!.getAvatarURLString() == nil) ? nil : (serverURLString + operatorItem!.getAvatarURLString()!))))
guard let operatorItem = operatorItem else { return nil }
return OperatorImpl(id: operatorItem.getID(),
name: operatorItem.getFullName(),
avatarURLString: ((operatorItem.getAvatarURLString() == nil) ? nil : (serverURLString + operatorItem.getAvatarURLString()!)))
}

}
23 changes: 18 additions & 5 deletions WebimClientLibrary/Implementation/WebimSessionImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ final class WebimSessionImpl {
let authorizationData = AuthorizationData(pageID: pageID,
authorizationToken: authorizationToken)

let deltaCallback = DeltaCallback(currentChatMessageMapper: currentChatMessageMapper)
let deltaCallback = DeltaCallback(currentChatMessageMapper: currentChatMessageMapper,
userDefaultsKey: userDefaultsKey)

let webimClient = WebimClientBuilder()
.set(baseURL: serverURLString)
Expand Down Expand Up @@ -165,7 +166,7 @@ final class WebimSessionImpl {
var dbName = userDefaults?[UserDefaultsMainPrefix.historyDBname.rawValue] as? String

if dbName == nil {
dbName = "webim_" + ClientSideID.generateClientSideID() + ".db"
dbName = "webim_\(ClientSideID.generateClientSideID()).db"
if let userDefaults = userDefaults {
var renewedUserDefaults = userDefaults
renewedUserDefaults[UserDefaultsMainPrefix.historyDBname.rawValue] = dbName
Expand All @@ -184,7 +185,7 @@ final class WebimSessionImpl {
webimClient: webimClient,
reachedHistoryEnd: historyMetaInformationStoragePreferences.isHistoryEnded(),
queue: queue,
readBeforeTimestamp: Int64(UserDefaults.standard.integer(forKey: UserDefaultsMainPrefix.readBeforeTimestamp.rawValue)))
readBeforeTimestamp: (userDefaults?[UserDefaultsMainPrefix.readBeforeTimestamp.rawValue] ?? Int64(-1)) as! Int64)
historyStorage = sqlhistoryStorage

let historyMajorVersion = historyStorage.getMajorVersion()
Expand All @@ -200,7 +201,7 @@ final class WebimSessionImpl {
}
}
} else {
historyStorage = MemoryHistoryStorage(readBeforeTimestamp: Int64(UserDefaults.standard.integer(forKey: UserDefaultsMainPrefix.readBeforeTimestamp.rawValue)))
historyStorage = MemoryHistoryStorage(readBeforeTimestamp: (userDefaults?[UserDefaultsMainPrefix.readBeforeTimestamp.rawValue] ?? Int64(-1)) as! Int64)
historyMetaInformationStoragePreferences = MemoryHistoryMetaInformationStorage()
}

Expand Down Expand Up @@ -484,8 +485,20 @@ final class HistoryPoller {
self.hasHistoryRevision = hasHistoryRevision
}

func updateReadBeforeTimestamp(timestamp: Int64) {
func updateReadBeforeTimestamp(timestamp: Int64, byUserDefaultsKey userDefaultsKey: String) {
self.messageHolder.updateReadBeforeTimestamp(timestamp: timestamp)
if var userDefaults = UserDefaults.standard.dictionary(forKey: userDefaultsKey) {
userDefaults[UserDefaultsMainPrefix.readBeforeTimestamp.rawValue] = timestamp
UserDefaults.standard.set(userDefaults, forKey: userDefaultsKey)
}
}

func getReadBeforeTimestamp(byUserDefaultsKey userDefaultsKey: String) -> Int64 {
let userDefaults = UserDefaults.standard.dictionary(forKey: userDefaultsKey)
if let readBeforeTimestamp = userDefaults?[UserDefaultsMainPrefix.readBeforeTimestamp.rawValue] {
return readBeforeTimestamp as! Int64
}
return Int64(-1)
}

// MARK: Private methods
Expand Down

0 comments on commit 53296d3

Please sign in to comment.