MCPcopy Index your code
hub / github.com/MALSync/MALSync / importList

Function importList

src/background/database.ts:89–124  ·  view source on GitHub ↗
(type: 'anime' | 'manga')

Source from the content-addressed store, hash-verified

87};
88
89async function importList(type: 'anime' | 'manga'): Promise<void> {
90 if (blocked[type]) {
91 logger.log('Import already running');
92 return;
93 }
94 blocked[type] = true;
95 logger.log(`Import ${type} database`);
96 try {
97 await api.settings.init();
98 const listProvider = await getList(7, type);
99 const list = await listProvider.getCompleteList();
100 await importEntries(
101 type,
102 list.map(el => ({
103 uid: el.uid,
104 type: el.type,
105 title: el.title,
106 malId: el.malId,
107 cacheKey: el.cacheKey,
108 image: el.image,
109 score: el.score,
110 status: el.status,
111 watchedEp: el.watchedEp,
112 totalEp: el.totalEp,
113 url: el.url,
114 })),
115 ).then(() => {
116 blocked[type] = false;
117 setKey(`update_${type}`, Date.now());
118 setKey(`update_mode_${type}`, api.settings.get('syncMode'));
119 });
120 } catch (e) {
121 blocked[type] = false;
122 throw e;
123 }
124}
125
126export interface Entry {
127 uid: number | string;

Callers 1

indexUpdateFunction · 0.70

Calls 5

getListFunction · 0.90
importEntriesFunction · 0.85
setKeyFunction · 0.85
getMethod · 0.65
initMethod · 0.45

Tested by

no test coverage detected