1
1
import type {
2
2
APIErrorResponse ,
3
+ AppSettingsAPIResponse ,
3
4
ChannelAPIResponse ,
4
5
ChannelFilters ,
5
6
ChannelSort ,
@@ -28,6 +29,12 @@ export type UpsertChannelsType = {
28
29
sort ?: ChannelSort ;
29
30
} ;
30
31
32
+ export type UpsertAppSettingsType = {
33
+ appSettings : AppSettingsAPIResponse ;
34
+ userId : string ;
35
+ flush ?: boolean ;
36
+ } ;
37
+
31
38
export type UpsertUserSyncStatusType = {
32
39
userId : string ;
33
40
lastSyncedAt : string ;
@@ -50,6 +57,10 @@ export type GetLastSyncedAtType = {
50
57
51
58
export type GetPendingTasksType = { messageId ?: string } ;
52
59
60
+ export type GetAppSettingsType = {
61
+ userId : string ;
62
+ } ;
63
+
53
64
export type DeletePendingTaskType = { id : number } ;
54
65
55
66
export type DeleteReactionType = {
@@ -68,20 +79,22 @@ export interface OfflineDBApi {
68
79
upsertCidsForQuery : ( options : UpsertCidsForQueryType ) => Promise < unknown > ;
69
80
upsertChannels : ( options : UpsertChannelsType ) => Promise < unknown > ;
70
81
upsertUserSyncStatus : ( options : UpsertUserSyncStatusType ) => Promise < unknown > ;
82
+ upsertAppSettings : ( options : UpsertAppSettingsType ) => Promise < unknown > ;
71
83
getChannels : ( options : GetChannelsType ) => Promise < unknown > ;
72
84
getChannelsForQuery : (
73
85
options : GetChannelsForQueryType ,
74
86
) => Promise < Omit < ChannelAPIResponse , 'duration' > [ ] | null > ;
75
87
getAllChannelCids : ( ) => Promise < string [ ] > ;
76
88
getLastSyncedAt : ( options : GetLastSyncedAtType ) => Promise < number | undefined > ;
77
- resetDB : ( ) => Promise < unknown > ;
89
+ getAppSettings : ( options : GetAppSettingsType ) => Promise < unknown > ;
78
90
executeSqlBatch : ( queries : ExecuteBatchQueriesType ) => Promise < unknown > ;
79
91
addPendingTask : ( task : PendingTask ) => Promise < ( ) => Promise < void > > ;
80
92
getPendingTasks : ( conditions ?: GetPendingTasksType ) => Promise < PendingTask [ ] > ;
81
93
deletePendingTask : ( options : DeletePendingTaskType ) => Promise < unknown > ;
82
94
deleteReaction : ( options : DeleteReactionType ) => Promise < unknown > ;
83
- hardDeleteMessage : ( optins : DeleteMessageType ) => Promise < unknown > ;
84
- softDeleteMessage : ( optins : DeleteMessageType ) => Promise < unknown > ;
95
+ hardDeleteMessage : ( options : DeleteMessageType ) => Promise < unknown > ;
96
+ softDeleteMessage : ( options : DeleteMessageType ) => Promise < unknown > ;
97
+ resetDB : ( ) => Promise < unknown > ;
85
98
}
86
99
87
100
export abstract class AbstractOfflineDB implements OfflineDBApi {
@@ -97,6 +110,10 @@ export abstract class AbstractOfflineDB implements OfflineDBApi {
97
110
98
111
abstract upsertChannels : OfflineDBApi [ 'upsertChannels' ] ;
99
112
113
+ abstract upsertUserSyncStatus : OfflineDBApi [ 'upsertUserSyncStatus' ] ;
114
+
115
+ abstract upsertAppSettings : OfflineDBApi [ 'upsertAppSettings' ] ;
116
+
100
117
abstract getChannels : OfflineDBApi [ 'getChannels' ] ;
101
118
102
119
abstract getChannelsForQuery : OfflineDBApi [ 'getChannelsForQuery' ] ;
@@ -105,16 +122,14 @@ export abstract class AbstractOfflineDB implements OfflineDBApi {
105
122
106
123
abstract getLastSyncedAt : OfflineDBApi [ 'getLastSyncedAt' ] ;
107
124
108
- abstract resetDB : OfflineDBApi [ 'resetDB ' ] ;
125
+ abstract getPendingTasks : OfflineDBApi [ 'getPendingTasks ' ] ;
109
126
110
- abstract executeSqlBatch : OfflineDBApi [ 'executeSqlBatch ' ] ;
127
+ abstract getAppSettings : OfflineDBApi [ 'getAppSettings ' ] ;
111
128
112
- abstract upsertUserSyncStatus : OfflineDBApi [ 'upsertUserSyncStatus ' ] ;
129
+ abstract executeSqlBatch : OfflineDBApi [ 'executeSqlBatch ' ] ;
113
130
114
131
abstract addPendingTask : OfflineDBApi [ 'addPendingTask' ] ;
115
132
116
- abstract getPendingTasks : OfflineDBApi [ 'getPendingTasks' ] ;
117
-
118
133
abstract deletePendingTask : OfflineDBApi [ 'deletePendingTask' ] ;
119
134
120
135
abstract deleteReaction : OfflineDBApi [ 'deleteReaction' ] ;
@@ -123,6 +138,8 @@ export abstract class AbstractOfflineDB implements OfflineDBApi {
123
138
124
139
abstract softDeleteMessage : OfflineDBApi [ 'softDeleteMessage' ] ;
125
140
141
+ abstract resetDB : OfflineDBApi [ 'resetDB' ] ;
142
+
126
143
public queueTask = async ( { task } : { task : PendingTask } ) => {
127
144
let response ;
128
145
try {
0 commit comments