@shaxpir/duiduidui-models 1.5.10 → 1.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,18 +6,27 @@ import { ConditionFilters } from './Condition';
6
6
  export interface LastSync {
7
7
  at_utc_time: CompactDateTime | null;
8
8
  }
9
+ export interface AudioDownloadQueueItem {
10
+ text: string;
11
+ added_at: CompactDateTime;
12
+ retry_count: number;
13
+ next_retry_at?: CompactDateTime;
14
+ last_error?: string;
15
+ }
9
16
  export interface DevicePayload {
10
17
  last_sync?: LastSync;
11
18
  chinese_font?: string;
12
19
  raw_search_text?: string;
13
20
  star_filter?: boolean;
14
21
  conditions?: ConditionFilters;
22
+ audio_download_queue?: AudioDownloadQueueItem[];
15
23
  }
16
24
  export interface DeviceBody extends ContentBody {
17
25
  meta: ContentMeta;
18
26
  payload: DevicePayload;
19
27
  }
20
28
  export declare class Device extends Content {
29
+ private _audioDownloadQueueView;
21
30
  static create(userId: ContentId, deviceId: ContentId): Device;
22
31
  constructor(doc: Doc, shouldAcquire: boolean, shareSync: ShareSync);
23
32
  get payload(): DevicePayload;
@@ -25,4 +34,9 @@ export declare class Device extends Content {
25
34
  setLastSyncAtUtcTime(value: CompactDateTime): void;
26
35
  get chineseFont(): string;
27
36
  setChineseFont(value: string): void;
37
+ get audioDownloadQueue(): AudioDownloadQueueItem[];
38
+ get audioDownloadQueueLength(): number;
39
+ addToAudioDownloadQueue(text: string): void;
40
+ removeFromAudioDownloadQueue(text: string): void;
41
+ updateAudioDownloadQueueItem(text: string, updates: Partial<AudioDownloadQueueItem>): void;
28
42
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = void 0;
4
4
  const shaxpir_common_1 = require("@shaxpir/shaxpir-common");
5
5
  const repo_1 = require("../repo");
6
+ const ArrayView_1 = require("./ArrayView");
6
7
  const Content_1 = require("./Content");
7
8
  const ContentKind_1 = require("./ContentKind");
8
9
  const Operation_1 = require("./Operation");
@@ -19,12 +20,14 @@ class Device extends Content_1.Content {
19
20
  updated_at: now
20
21
  },
21
22
  payload: {
22
- last_sync: { at_utc_time: null }
23
+ last_sync: { at_utc_time: null },
24
+ audio_download_queue: []
23
25
  }
24
26
  });
25
27
  }
26
28
  constructor(doc, shouldAcquire, shareSync) {
27
29
  super(doc, shouldAcquire, shareSync);
30
+ this._audioDownloadQueueView = new ArrayView_1.ArrayView(this, ['payload', 'audio_download_queue']);
28
31
  }
29
32
  get payload() {
30
33
  this.checkDisposed("Device.payload");
@@ -54,5 +57,50 @@ class Device extends Content_1.Content {
54
57
  batch.commit();
55
58
  }
56
59
  }
60
+ get audioDownloadQueue() {
61
+ this.checkDisposed("Device.audioDownloadQueue");
62
+ return this._audioDownloadQueueView.values;
63
+ }
64
+ get audioDownloadQueueLength() {
65
+ this.checkDisposed("Device.audioDownloadQueueLength");
66
+ return this._audioDownloadQueueView.length;
67
+ }
68
+ addToAudioDownloadQueue(text) {
69
+ this.checkDisposed("Device.addToAudioDownloadQueue");
70
+ // Check if item already exists in queue
71
+ const existingIndex = this._audioDownloadQueueView.values.findIndex(item => item.text === text);
72
+ if (existingIndex !== -1) {
73
+ console.log(`Audio download already queued for: ${text}`);
74
+ return;
75
+ }
76
+ const now = shaxpir_common_1.ClockService.getClock().utc();
77
+ const newItem = {
78
+ text,
79
+ added_at: now,
80
+ retry_count: 0
81
+ };
82
+ this._audioDownloadQueueView.push(newItem);
83
+ console.log(`Added to audio download queue: ${text}`);
84
+ }
85
+ removeFromAudioDownloadQueue(text) {
86
+ this.checkDisposed("Device.removeFromAudioDownloadQueue");
87
+ // Find the item index
88
+ const itemIndex = this._audioDownloadQueueView.values.findIndex(item => item.text === text);
89
+ if (itemIndex !== -1) {
90
+ this._audioDownloadQueueView.removeAt(itemIndex);
91
+ console.log(`Removed from audio download queue: ${text}`);
92
+ }
93
+ }
94
+ updateAudioDownloadQueueItem(text, updates) {
95
+ this.checkDisposed("Device.updateAudioDownloadQueueItem");
96
+ const itemIndex = this._audioDownloadQueueView.values.findIndex(item => item.text === text);
97
+ if (itemIndex !== -1) {
98
+ // Update each field in the updates object
99
+ for (const [key, value] of Object.entries(updates)) {
100
+ this._audioDownloadQueueView.setObjectValueAtIndex(itemIndex, key, value);
101
+ }
102
+ console.log(`Updated audio download queue item: ${text}`, updates);
103
+ }
104
+ }
57
105
  }
58
106
  exports.Device = Device;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.5.10",
3
+ "version": "1.5.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"