forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
favorite_list.go
68 lines (56 loc) · 1.6 KB
/
favorite_list.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2015 Keybase, Inc. All rights reserved. Use of
// this source code is governed by the included BSD license.
package engine
import (
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol"
)
// FavoriteList is an engine.
type FavoriteList struct {
libkb.Contextified
result FavoritesResult
}
// NewFavoriteList creates a FavoriteList engine.
func NewFavoriteList(g *libkb.GlobalContext) *FavoriteList {
return &FavoriteList{
Contextified: libkb.NewContextified(g),
}
}
// Name is the unique engine name.
func (e *FavoriteList) Name() string {
return "FavoriteList"
}
// GetPrereqs returns the engine prereqs.
func (e *FavoriteList) Prereqs() Prereqs {
return Prereqs{
Device: true,
}
}
// RequiredUIs returns the required UIs.
func (e *FavoriteList) RequiredUIs() []libkb.UIKind {
return []libkb.UIKind{}
}
// SubConsumers returns the other UI consumers for this engine.
func (e *FavoriteList) SubConsumers() []libkb.UIConsumer {
return nil
}
type FavoritesResult struct {
Status libkb.AppStatus `json:"status"`
Favorites []keybase1.Folder `json:"favorites"`
Ignored []keybase1.Folder `json:"ignored"`
}
func (f *FavoritesResult) GetAppStatus() *libkb.AppStatus {
return &f.Status
}
// Run starts the engine.
func (e *FavoriteList) Run(ctx *Context) error {
return e.G().API.GetDecode(libkb.APIArg{
Endpoint: "kbfs/favorite/list",
NeedSession: true,
Args: libkb.HTTPArgs{},
}, &e.result)
}
// Favorites returns the list of favorites that Run generated.
func (e *FavoriteList) Favorites() []keybase1.Folder {
return e.result.Favorites
}