aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Views/FilesView.swift
blob: d910af2a110fe4a0cdf043e2127a37c71d6f3e09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import SwiftUI

struct FilesView: View {
  @Environment(HotlineClient.self) private var hotline
  
  @State private var fetched = false
  
  var body: some View {
    List(hotline.fileList) {
      FileListView(item: $0)
    }
    .task {
      if !fetched {
        hotline.sendGetFileList() {
          fetched = true
        }
      }
    }
  }
}

#Preview {
  FilesView()
    .environment(HotlineClient())
}