Skip to content

fix: use latest appsync 3.1.5 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions EventsApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,19 @@
"${PODS_ROOT}/Target Support Files/Pods-EventsApp/Pods-EventsApp-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/AWSAppSync/AWSAppSync.framework",
"${BUILT_PRODUCTS_DIR}/AWSCore/AWSCore.framework",
"${BUILT_PRODUCTS_DIR}/AppSyncRealTimeClient/AppSyncRealTimeClient.framework",
"${BUILT_PRODUCTS_DIR}/ReachabilitySwift/Reachability.framework",
"${BUILT_PRODUCTS_DIR}/SQLite.swift/SQLite.framework",
"${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSAppSync.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AppSyncRealTimeClient.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SQLite.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Starscream.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
27 changes: 15 additions & 12 deletions EventsApp/AddEventViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ class AddEventViewController: UIViewController {

// MARK: - Click handlers

@IBAction func addNewPost(_ sender: Any) {
@IBAction func addNewPost(_: Any) {
guard let nameText = nameInput.text, !nameText.isEmpty,
let whenText = whenInput.text, !whenText.isEmpty,
let whereText = whereInput.text, !whereText.isEmpty,
let descriptionText = descriptionInput.text, !descriptionText.isEmpty else {
// Server won't accept empty strings
let alertController = UIAlertController(title: "Error",
message: "Missing values.",
preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default)
alertController.addAction(okAction)
present(alertController, animated: true)
let descriptionText = descriptionInput.text, !descriptionText.isEmpty
else {
// Server won't accept empty strings
let alertController = UIAlertController(title: "Error",
message: "Missing values.",
preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default)
alertController.addAction(okAction)
present(alertController, animated: true)

return
return
}

// We set up a temporary ID so we can reconcile the server-provided ID when `addEventMutation` returns
Expand Down Expand Up @@ -82,8 +83,10 @@ class AddEventViewController: UIViewController {
defer {
self.navigationController?.popViewController(animated: true)

// swiftlint:disable opening_brace
if let eventListViewController =
self.navigationController?.viewControllers.last as? EventListViewController {
self.navigationController?.viewControllers.last as? EventListViewController
{
eventListViewController.needUpdateList = true
}
}
Expand Down Expand Up @@ -129,7 +132,7 @@ class AddEventViewController: UIViewController {
}
}

@IBAction func onCancel(_ sender: Any) {
@IBAction func onCancel(_: Any) {
dismiss(animated: true, completion: nil)
}
}
16 changes: 9 additions & 7 deletions EventsApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appSyncClient: AWSAppSyncClient?

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// swiftlint:disable opening_brace
func application(_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.

// You can choose the directory in which AppSync stores its persistent cache databases:
Expand Down Expand Up @@ -46,7 +48,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

func applicationWillResignActive(_ application: UIApplication) {
func applicationWillResignActive(_: UIApplication) {
// Sent when the application is about to move from active to inactive state. This
// can occur for certain types of temporary interruptions (such as an incoming
// phone call or SMS message) or when the user quits the application and it begins
Expand All @@ -56,7 +58,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
func applicationDidEnterBackground(_: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers,
// and store enough application state information to restore your application to
// its current state in case it is terminated later.
Expand All @@ -65,18 +67,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
func applicationWillEnterForeground(_: UIApplication) {
// Called as part of the transition from the background to the active state; here
// you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
func applicationDidBecomeActive(_: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application
// was inactive. If the application was previously in the background, optionally
// refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
func applicationWillTerminate(_: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate.
// See also applicationDidEnterBackground:.
}
Expand Down
13 changes: 8 additions & 5 deletions EventsApp/EventDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class EventDetailsViewController: UIViewController {
}
}

override func viewWillDisappear(_ animated: Bool) {
override func viewWillDisappear(_: Bool) {
super.viewWillDisappear(true)
print("Cancelling subscription")
newCommentsSubscriptionWatcher?.cancel()
Expand All @@ -93,8 +93,10 @@ class EventDetailsViewController: UIViewController {
return
}

// swiftlint:disable opening_brace
if let eventListViewController = navigationController?.viewControllers[controllersCount - 2]
as? EventListViewController {
as? EventListViewController
{
eventListViewController.eventList[eventListViewController.lastOpenedIndex]?.fragments.event = event
}
}
Expand Down Expand Up @@ -263,14 +265,15 @@ class EventDetailsViewController: UIViewController {
// MARK: - Table view delegates

extension EventDetailsViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
comments.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "CommentCell", for: indexPath)
as? CommentCell else {
return UITableViewCell()
as? CommentCell
else {
return UITableViewCell()
}

guard let content = comments[indexPath.row]?.content else {
Expand Down
25 changes: 15 additions & 10 deletions EventsApp/EventListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EventListViewController: UIViewController {
return refreshControl
}()

@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
@objc func handleRefresh(_: UIRefreshControl) {
nextToken = nil
fetchAllEventsUsingCachePolicy(.fetchIgnoringCacheData)
}
Expand Down Expand Up @@ -142,7 +142,7 @@ class EventListViewController: UIViewController {
// MARK: - Table view delegates

extension EventListViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
eventList.count
}

Expand All @@ -161,14 +161,16 @@ extension EventListViewController: UITableViewDataSource, UITableViewDelegate {
}

// editing check
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
func tableView(_: UITableView, canEditRowAt _: IndexPath) -> Bool {
true
}

// editing action
func tableView(_ tableView: UITableView,
// swiftlint:disable opening_brace
func tableView(_: UITableView,
commit editingStyle: UITableViewCell.EditingStyle,
forRowAt indexPath: IndexPath) {
forRowAt indexPath: IndexPath)
{
if editingStyle == UITableViewCell.EditingStyle.delete {
guard let eventId = eventList[indexPath.row]?.id else {
return
Expand Down Expand Up @@ -203,26 +205,29 @@ extension EventListViewController: UITableViewDataSource, UITableViewDelegate {
}

// click handlers
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
lastOpenedIndex = indexPath.row

guard let event = eventList[indexPath.row] else {
return
}
let storyboard = UIStoryboard(name: "Main", bundle: nil)
guard let controller = storyboard.instantiateViewController(withIdentifier: "EventDetailsViewController")
as? EventDetailsViewController else {
return
as? EventDetailsViewController
else {
return
}
controller.event = event.fragments.event
navigationController?.pushViewController(controller, animated: true)
}

// pagination
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
func tableView(_: UITableView, willDisplay _: UITableViewCell, forRowAt indexPath: IndexPath) {
// swiftlint:disable opening_brace
if !isLoadInProgress,
indexPath.row > eventList.count - 2,
nextToken?.count ?? 0 > 0 {
nextToken?.count ?? 0 > 0
{
fetchAllEventsUsingCachePolicy(.fetchIgnoringCacheData)
}
}
Expand Down
Loading