仅在“重新加载时更新”处于启用状态时才在集合中创建文档

时间:2020-07-06 10:27:14

标签: javascript google-cloud-firestore firebase-authentication progressive-web-apps service-worker

我创建了具有PWA功能的Web应用程序。在索引页面上,用户将需要首先注册或登录(Firebase身份验证)。这个想法是,一旦用户注册,便会在Firestore的“用户”集合中为该用户创建一个文档。

但是,我注意到只有打开“重新加载时更新”才能创建文档。禁用该选项后,将不会创建文档,但仍会在身份验证中创建用户,而不会出现任何错误警告。当“重新加载更新”被打勾时,它可以工作,我怀疑这与服务人员有关。但是我不知道为什么以及如何解决它。

任何帮助将不胜感激,谢谢。

这是我的代码:

int main(void)
{
    string text = get_string("Enter text: ");
    printf("Output:\n");
    int lettercount;
    int words = 0;
    int sentences = 0;
    int letters = 0;
    int inWord = 0;// Set to 1 if we are inside a (new) word!
    int length = (int)(strlen(text)); // Don't evaluate length on each loop!
    for (lettercount = 0; lettercount < length; lettercount++) {
        int testChar = text[lettercount]; // Get a local copy of the current character
        if (isalpha(testChar)) { // Don't assume that 'a' ... 'z' and 'A' ... 'Z' are in contiguous sequences
            letters++;
            if (!inWord) words++; // Any letter means that we're in a (possibly new) word...
            inWord = 1;           // ... but now set this 'flag' so as not to count others!
        }
        else if (testChar == '.' || testChar == '!' || testChar == '?') {
            sentences++;
        //  if (inWord) sentences++; // Check that we're in a word, or stuff like "..." will be wrong
            inWord = 0; // Now we are no longer inside our current word
        }
        else if (isspace(testChar)) { // We could also just assume ANY other character is a non-word
            inWord = 0; // Now we are no longer inside our current word
        }
    }
    printf("%i letter(s)\n", letters);
    printf("%i word(s)\n", words);
    printf("%i sentence(s)\n", sentences);
    return 0;
}

0 个答案:

没有答案