MCPcopy
hub / github.com/ChatGPTNextWeb/NextChat / getLatestVersion

Function getLatestVersion

app/store/update.ts:71–134  ·  view source on GitHub ↗
(force = false)

Source from the content-addressed store, hash-verified

69 },
70
71 async getLatestVersion(force = false) {
72 const versionType = get().versionType;
73 let version =
74 versionType === "date"
75 ? getClientConfig()?.commitDate
76 : getClientConfig()?.version;
77
78 set(() => ({ version }));
79
80 const shouldCheck = Date.now() - get().lastUpdate > 2 * 60 * ONE_MINUTE;
81 if (!force && !shouldCheck) return;
82
83 set(() => ({
84 lastUpdate: Date.now(),
85 }));
86
87 try {
88 const remoteId = await getVersion(versionType);
89 set(() => ({
90 remoteVersion: remoteId,
91 }));
92 if (window.__TAURI__?.notification && isApp) {
93 // Check if notification permission is granted
94 await window.__TAURI__?.notification
95 .isPermissionGranted()
96 .then((granted) => {
97 if (!granted) {
98 return;
99 } else {
100 // Request permission to show notifications
101 window.__TAURI__?.notification
102 .requestPermission()
103 .then((permission) => {
104 if (permission === "granted") {
105 if (version === remoteId) {
106 // Show a notification using Tauri
107 window.__TAURI__?.notification.sendNotification({
108 title: "NextChat",
109 body: `${Locale.Settings.Update.IsLatest}`,
110 icon: `${ChatGptIcon.src}`,
111 sound: "Default",
112 });
113 } else {
114 const updateMessage =
115 Locale.Settings.Update.FoundUpdate(`${remoteId}`);
116 // Show a notification for the new version using Tauri
117 window.__TAURI__?.notification.sendNotification({
118 title: "NextChat",
119 body: updateMessage,
120 icon: `${ChatGptIcon.src}`,
121 sound: "Default",
122 });
123 clientUpdate();
124 }
125 }
126 });
127 }
128 });

Callers

nothing calls this directly

Calls 6

getClientConfigFunction · 0.90
clientUpdateFunction · 0.90
getVersionFunction · 0.85
errorMethod · 0.80
getFunction · 0.70
setFunction · 0.50

Tested by

no test coverage detected