Skip to content

Commit 0b9361f

Browse files
authored
Use numbers instead of strings for the DBActions and SyncEvents constants (#6815)
* Use numbers instead of strings for the DBActions and SyncEvents constants * Fix duplicate number * Start offset numbers at 20
1 parent cb06628 commit 0b9361f

File tree

1 file changed

+46
-40
lines changed

1 file changed

+46
-40
lines changed

src/constants.js

+46-40
Original file line numberDiff line numberDiff line change
@@ -53,76 +53,82 @@ const IpcChannels = {
5353
}
5454

5555
const DBActions = {
56+
// The constants in the GENERAL group are usally intermingeled with the ones in other groups, so they need unique values.
57+
// The other groups however are usually not mixed (e.g. HISTORY and PROFILES),
58+
// so they can have similar values (as long as they don't overlap with the GENERAL group).
5659
GENERAL: {
57-
CREATE: 'db-action-create',
58-
FIND: 'db-action-find',
59-
UPSERT: 'db-action-upsert',
60-
DELETE: 'db-action-delete',
61-
DELETE_MULTIPLE: 'db-action-delete-multiple',
62-
DELETE_ALL: 'db-action-delete-all'
60+
CREATE: 0,
61+
FIND: 1,
62+
UPSERT: 2,
63+
DELETE: 3,
64+
DELETE_MULTIPLE: 4,
65+
DELETE_ALL: 5
6366
},
6467

6568
HISTORY: {
66-
OVERWRITE: 'db-action-history-overwrite',
67-
UPDATE_WATCH_PROGRESS: 'db-action-history-update-watch-progress',
68-
UPDATE_PLAYLIST: 'db-action-history-update-playlist',
69+
OVERWRITE: 20,
70+
UPDATE_WATCH_PROGRESS: 21,
71+
UPDATE_PLAYLIST: 22,
6972
},
7073

7174
PROFILES: {
72-
ADD_CHANNEL: 'db-action-profiles-add-channel',
73-
REMOVE_CHANNEL: 'db-action-profiles-remove-channel'
75+
ADD_CHANNEL: 20,
76+
REMOVE_CHANNEL: 21
7477
},
7578

7679
PLAYLISTS: {
77-
UPSERT_VIDEO: 'db-action-playlists-upsert-video-by-playlist-name',
78-
UPSERT_VIDEOS: 'db-action-playlists-upsert-videos-by-playlist-name',
79-
DELETE_VIDEO_ID: 'db-action-playlists-delete-video-by-playlist-name',
80-
DELETE_VIDEO_IDS: 'db-action-playlists-delete-video-ids',
81-
DELETE_ALL_VIDEOS: 'db-action-playlists-delete-all-videos',
80+
UPSERT_VIDEO: 20,
81+
UPSERT_VIDEOS: 21,
82+
DELETE_VIDEO_ID: 22,
83+
DELETE_VIDEO_IDS: 23,
84+
DELETE_ALL_VIDEOS: 24,
8285
},
8386

8487
SUBSCRIPTION_CACHE: {
85-
UPDATE_VIDEOS_BY_CHANNEL: 'db-action-subscriptions-update-videos-by-channel',
86-
UPDATE_LIVE_STREAMS_BY_CHANNEL: 'db-action-subscriptions-update-live-streams-by-channel',
87-
UPDATE_SHORTS_BY_CHANNEL: 'db-action-subscriptions-update-shorts-by-channel',
88-
UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL: 'db-action-subscriptions-update-shorts-with-channel-page-shorts-by-channel',
89-
UPDATE_COMMUNITY_POSTS_BY_CHANNEL: 'db-action-subscriptions-update-community-posts-by-channel',
88+
UPDATE_VIDEOS_BY_CHANNEL: 20,
89+
UPDATE_LIVE_STREAMS_BY_CHANNEL: 21,
90+
UPDATE_SHORTS_BY_CHANNEL: 22,
91+
UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL: 23,
92+
UPDATE_COMMUNITY_POSTS_BY_CHANNEL: 24,
9093
},
9194
}
9295

9396
const SyncEvents = {
97+
// The constants in the GENERAL group are usally intermingeled with the ones in other groups, so they need unique values.
98+
// The other groups however are usually not mixed (e.g. HISTORY and PROFILES),
99+
// so they can have similar values (as long as they don't overlap with the GENERAL group).
94100
GENERAL: {
95-
CREATE: 'sync-create',
96-
UPSERT: 'sync-upsert',
97-
DELETE: 'sync-delete',
98-
DELETE_MULTIPLE: 'sync-delete-multiple',
99-
DELETE_ALL: 'sync-delete-all'
101+
CREATE: 0,
102+
UPSERT: 1,
103+
DELETE: 2,
104+
DELETE_MULTIPLE: 3,
105+
DELETE_ALL: 4
100106
},
101107

102108
HISTORY: {
103-
OVERWRITE: 'sync-history-overwrite',
104-
UPDATE_WATCH_PROGRESS: 'sync-history-update-watch-progress',
105-
UPDATE_PLAYLIST: 'sync-history-update-playlist',
109+
OVERWRITE: 20,
110+
UPDATE_WATCH_PROGRESS: 21,
111+
UPDATE_PLAYLIST: 22,
106112
},
107113

108114
PROFILES: {
109-
ADD_CHANNEL: 'sync-profiles-add-channel',
110-
REMOVE_CHANNEL: 'sync-profiles-remove-channel'
115+
ADD_CHANNEL: 20,
116+
REMOVE_CHANNEL: 21
111117
},
112118

113119
PLAYLISTS: {
114-
UPSERT_VIDEO: 'sync-playlists-upsert-video',
115-
UPSERT_VIDEOS: 'sync-playlists-upsert-videos',
116-
DELETE_VIDEO: 'sync-playlists-delete-video',
117-
DELETE_VIDEOS: 'sync-playlists-delete-videos',
120+
UPSERT_VIDEO: 20,
121+
UPSERT_VIDEOS: 21,
122+
DELETE_VIDEO: 22,
123+
DELETE_VIDEOS: 23,
118124
},
119125

120126
SUBSCRIPTION_CACHE: {
121-
UPDATE_VIDEOS_BY_CHANNEL: 'sync-subscriptions-update-videos-by-channel',
122-
UPDATE_LIVE_STREAMS_BY_CHANNEL: 'sync-subscriptions-update-live-streams-by-channel',
123-
UPDATE_SHORTS_BY_CHANNEL: 'sync-subscriptions-update-shorts-by-channel',
124-
UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL: 'sync-subscriptions-update-shorts-with-channel-page-shorts-by-channel',
125-
UPDATE_COMMUNITY_POSTS_BY_CHANNEL: 'sync-subscriptions-update-community-posts-by-channel',
127+
UPDATE_VIDEOS_BY_CHANNEL: 20,
128+
UPDATE_LIVE_STREAMS_BY_CHANNEL: 21,
129+
UPDATE_SHORTS_BY_CHANNEL: 22,
130+
UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL: 23,
131+
UPDATE_COMMUNITY_POSTS_BY_CHANNEL: 24,
126132
},
127133
}
128134

0 commit comments

Comments
 (0)