Skip to content

Commit

Permalink
add tasks listener query: sort updateTime desc.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgr-ksmt committed Sep 29, 2019
1 parent 2452a6d commit 1c9c0f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FireTodo/Firebase/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import FireSnapshot
import SwiftUI

extension Model {
struct Task: Codable, HasTimestamps, Equatable {
struct Task: HasTimestamps, Codable, Equatable{
var title: String = ""
var desc: String = ""
var completed: Bool = false
Expand Down
4 changes: 3 additions & 1 deletion FireTodo/Redux/Tasks/TasksAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ enum TasksAction: Action {

static func subscribe(userID: String) -> AppThunkAction {
AppThunkAction { dispatch, _ in
let listener = Snapshot<Model.Task>.listen(Model.Path.tasks(userID: userID)) { result in
let listener = Snapshot<Model.Task>.listen(Model.Path.tasks(userID: userID), queryBuilder: {
$0.order(by: "updateTime", descending: true).limit(to: 30)
}) { result in
switch result {
case let .success(tasks):
dispatch(TasksAction.updateTasks(tasks: tasks))
Expand Down

0 comments on commit 1c9c0f7

Please sign in to comment.