-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
388 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { isSymbol } from "src/symbols/utils"; | ||
import { SymbolAction } from "src/types/Symbols"; | ||
import { store } from "src/valtio"; | ||
|
||
export const handleSymbols = (data: SymbolAction): void => { | ||
const { type, payload } = data; | ||
|
||
if (type && payload && isSymbol(payload)) { | ||
switch (type) { | ||
case "CREATE": { | ||
store.symbols.toCreate.push(payload); | ||
break; | ||
} | ||
case "UPDATE": { | ||
const candidateIndex = store.symbols.toUpdate.findIndex( | ||
(s) => s.uid === payload.uid | ||
); | ||
|
||
if (candidateIndex === -1) { | ||
store.symbols.toUpdate.push(payload); | ||
} | ||
|
||
store.symbols.toUpdate[candidateIndex] = payload; | ||
break; | ||
} | ||
case "DELETE": { | ||
store.symbols.toDelete.push(payload); | ||
break; | ||
} | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// import { createSymbol, deleteSymbol, getSymbols, updateSymbol } from "src/api"; | ||
// import { Symbols } from "src/types/Symbols"; | ||
// import { t } from "src/utils/i18n"; | ||
|
||
// export const symbols: Symbols = { | ||
// async get(res, rej) { | ||
// try { | ||
// const data = await getSymbols(); | ||
|
||
// if (!data) { | ||
// return rej(t("Could not get symbols")); | ||
// } | ||
|
||
// res(data); | ||
// } catch (e) { | ||
// rej(t("Failed to get symbols")); | ||
// } | ||
// }, | ||
// async create(res, rej, extra) { | ||
// try { | ||
// const data = await createSymbol(extra); | ||
|
||
// if (!data.data) { | ||
// return rej(t("Could not create symbols")); | ||
// } | ||
|
||
// res(data.data); | ||
// } catch (error) { | ||
// rej(t("Failed to create symbol")); | ||
// } | ||
// }, | ||
// async update(res, rej, extra) { | ||
// try { | ||
// const data = await updateSymbol(extra); | ||
|
||
// if (!data.data) { | ||
// return rej(t("Could not update symbols")); | ||
// } | ||
|
||
// console.log("data: ", data); | ||
|
||
// res(data.data); | ||
// } catch (error) { | ||
// rej(t("Failed to update symbol")); | ||
// } | ||
// }, | ||
// async delete(res, rej, extra) { | ||
// try { | ||
// const data = await deleteSymbol(extra); | ||
|
||
// if (!data.success) { | ||
// return rej(t("Could not delete symbols")); | ||
// } | ||
|
||
// res(data.success); | ||
// } catch (error) { | ||
// rej(t("Failed to delete symbol")); | ||
// } | ||
// } | ||
// }; | ||
|
||
export {}; |
Oops, something went wrong.