-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: setup createAsyncThunk, added logger (#140)
* Updated branch (#129) * to be edited * Update .env.sample * Update set-local-storage.ts * fix: enhancement done for #126 * Refactored Code: Removed redundant window.androidIntract, added GetBotList and SocketComponents, implemented expired bot logic (#126) * to be edited * Update .env.sample * Update set-local-storage.ts * fix: enhancement done for #126 * style: layout modified to look similar like whatsapp (#132) * Config for components * env sample * removed unnecessary config * ui changes * chore: revert ui changes * Revert "style: layout modified to look similar like whatsapp (#132)" (#134) This reverts commit fcbb545. * chore: base setup * refactor: added socket class (#136) * feat: added class for socket * refactor: created socket * chore: new socket class tested * feat: using deployed socket package, added suppressHydrationWarning for extensions giving warning * feat: added logger, setup store using createAsyncThunk * change: reverted few changes --------- Co-authored-by: Tushar Banik <[email protected]> Co-authored-by: Saiyan Abhishek <[email protected]>
- Loading branch information
1 parent
83f47df
commit 2970d5b
Showing
37 changed files
with
30,527 additions
and
349 deletions.
There are no files selected for viewing
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
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,84 @@ | ||
import { getBotDetailsList } from "@/utils/api-handler"; | ||
import { normalizeUsers } from "@/utils/normalize-user"; | ||
import { reverse, sortBy, without } from "lodash"; | ||
import moment from "moment"; | ||
import { useEffect } from "react"; | ||
import { toast } from "react-hot-toast"; | ||
import { setUsers, setCurrentUser, setLoading } from "@/types/react-dispatch"; | ||
|
||
interface GetBotItemProp{ | ||
setUsers: setUsers, | ||
setCurrentUser: setCurrentUser, | ||
setLoading: setLoading | ||
} | ||
|
||
|
||
const GetBotList: React.FC<GetBotItemProp> = ({ setUsers, setCurrentUser, setLoading }) => { | ||
|
||
useEffect(() => { | ||
try { | ||
const checkOnline = async (): Promise<void> => { | ||
if (window.navigator.onLine) { | ||
|
||
const botIds = JSON.parse(localStorage.getItem("botList") || '{}'); | ||
getBotDetailsList() | ||
.then((response): any => { | ||
console.log({ response }) | ||
const botDetailsList = without( | ||
reverse( | ||
sortBy( | ||
response?.data?.result?.map((bot: any, index: number) => { | ||
if ( | ||
// bot?.logicIDs?.[0]?.transformers?.[0]?.meta?.type !== | ||
// "broadcast" && | ||
// includes(botIds, bot?.id) | ||
true | ||
) { | ||
if (index === 0) localStorage.setItem('userID', bot?.id); | ||
return normalizeUsers({ | ||
...bot, | ||
active: index === 0, | ||
botUuid: bot?.id, | ||
createTime: moment(bot?.createdAt).valueOf(), | ||
}); | ||
} | ||
return null; | ||
}), | ||
["createTime"] | ||
) | ||
), | ||
null | ||
); | ||
|
||
|
||
// @ts-ignore | ||
setUsers(botDetailsList); | ||
setLoading(false); | ||
|
||
if (localStorage.getItem("currentUser")) { | ||
|
||
// @ts-ignore | ||
setCurrentUser(JSON.parse(localStorage.getItem("currentUser"))); | ||
|
||
// @ts-ignore | ||
} else setCurrentUser(botDetailsList?.[0]); | ||
}) | ||
.catch((err: any) => console.log("qwerty:", { err })); | ||
} else { | ||
setLoading(false); | ||
if (localStorage.getItem("botDetails")) { | ||
setUsers(JSON.parse(localStorage.getItem("botDetails") || '[]')); | ||
setCurrentUser(JSON.parse(localStorage.getItem("botDetails") || '[]')?.[0]); | ||
} | ||
} | ||
}; | ||
checkOnline(); | ||
} catch (err: any) { | ||
toast.error(err?.message); | ||
} | ||
}, []); | ||
|
||
return null; | ||
} | ||
|
||
export default GetBotList; |
Oops, something went wrong.